summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-12 15:08:13 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-05-12 15:08:13 +0200
commitcc8b965d52177eb45185d0b1ead65b55f113a687 (patch)
tree001196466bcd005283e4a7b56a1a48b1f7232bac
parentc44e670ebbb1e1690398ac2837e5e79e17a19c7b (diff)
downloaddmc-cc8b965d52177eb45185d0b1ead65b55f113a687.tar.gz
dmc-cc8b965d52177eb45185d0b1ead65b55f113a687.tar.bz2
dmc-cc8b965d52177eb45185d0b1ead65b55f113a687.zip
Fold log_regress_pred into regress_pred
By adding a pre-filter function pointer.
-rw-r--r--log_regress_pred.m15
-rw-r--r--regress_frequency_removal.m2
-rw-r--r--regress_pred.m6
-rw-r--r--run_tests.m4
4 files changed, 6 insertions, 21 deletions
diff --git a/log_regress_pred.m b/log_regress_pred.m
deleted file mode 100644
index e6cfe05..0000000
--- a/log_regress_pred.m
+++ /dev/null
@@ -1,15 +0,0 @@
-function pred = log_regress_pred(price, quantity)
-
- days = size(price, 1) - size(quantity, 1);
- product_count = size(price, 2);
- test_count = size(quantity, 1);
- test_set = 1:test_count;
- pred_set = test_count+1:size(price, 1);
-
- pred = zeros(days, product_count);
- for i = 1:product_count
- ab = regress(log(price(test_set, i)), quantity(test_set, i));
- pred(:, i) = polyval(ab, log(price(pred_set, i)));
- end
-
-endfunction
diff --git a/regress_frequency_removal.m b/regress_frequency_removal.m
index 8c3c696..4b7624b 100644
--- a/regress_frequency_removal.m
+++ b/regress_frequency_removal.m
@@ -7,7 +7,7 @@ function pred = regress_frequency_removal(price, quantity)
pred_set = size(quantity, 1)+1:size(price, 1);
[q2, removed] = remove_sevenday_frequency(quantity(test_set, :));
- pred = regress_pred(price([test_set pred_set],:), q2);
+ pred = regress_pred(price([test_set pred_set],:), q2, @(x)x);
pred = fft(pred);
%pred = (pred .* (removed == 0)) + removed;
pred = pred + removed;
diff --git a/regress_pred.m b/regress_pred.m
index 2992471..119738c 100644
--- a/regress_pred.m
+++ b/regress_pred.m
@@ -1,4 +1,4 @@
-function pred = regress_pred(price, quantity)
+function pred = regress_pred(price, quantity, prefunc)
days = size(price, 1) - size(quantity, 1);
product_count = size(price, 2);
@@ -8,8 +8,8 @@ function pred = regress_pred(price, quantity)
pred = zeros(days, product_count);
for i = 1:product_count
- mn = regress(price(test_set, i), quantity(test_set, i));
- pred(:, i) = polyval(mn, price(pred_set, i));
+ mn = regress(prefunc(price(test_set, i)), quantity(test_set, i));
+ pred(:, i) = polyval(mn, prefunc(price(pred_set, i)));
end
endfunction
diff --git a/run_tests.m b/run_tests.m
index 4a49d52..3ef7aeb 100644
--- a/run_tests.m
+++ b/run_tests.m
@@ -10,9 +10,9 @@ real_data = q(29:42, :);
m = @(n,f) struct('name', n, 'func', f );
pred_methods = [
m('mean', @mean_pred)
- m('regress', @regress_pred)
+ m('regress', @(p,q) regress_pred(p, q, @(x)x))
m('quad', @quad_regress_pred)
- m('log reg.', @log_regress_pred)
+ m('log reg.', @(p,q) regress_pred(p, q, @log))
m('sevenday', @sevenday_pred)
% m('norm rand.',@rand_pred)
% m('chi rand.',@chi_pred)