-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimulate_Model.m
29 lines (19 loc) · 991 Bytes
/
simulate_Model.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
% This code simulates the OLS with rolling window, saves the output and plots price and expected price
% it is important to note that that we simulate model plenty of times for 1000 times. Then we create
% matrix where each column is the simulation result. Then we calculate average for each row and plot it.
tic
simulation = 20000;
P_mean = zeros(1,simulation); % matrix of simulated prices
Pe_mean = zeros(1,simulation); % matrix of simulated expexted prices
A_mean = zeros(1,simulation); % matrix of simulated alpha coefficient
B_mean = zeros(1,simulation); % matrix of simulated beta coefficient
time_period = 0;
for zi = 1:simulation
OLS_learning_9;
P_mean(1,zi) = mean(p_roll); % save price
Pe_mean(1,zi) = mean(a_roll); % save expected price
A_mean(1,zi) = mean(alpha_2_roll); % save alpha coefficient
B_mean(1,zi) = mean(beta_2_roll); % save beta coefficient
time_period = time_period + 1 %print time index
end
toc