Need help coding a monte carlo simulation.
Show older comments
I need to have a "random walk" data generated process. Then fit an ols regress of yt-yt-1 on yt-1, saving the t-statistic from the ols. I have the code for step one and two, I am having a hard time simulation all of this 10,000 times, while saving all 10,000 t-statistics, the code I have for the dgp and the ols are below:
time=49;
y=NaN*ones(time,1);
y(1)=normrnd(0,1);
sigma=1
phi=1
for t=1:time
y(t+1)=phi*y(t)+normrnd(0,1);
end
yt=diff(y);
yt_1=y(1:time);
mdl = fitlm(yt_1,yt,'Intercept',false)
Answers (0)
Categories
Find more on Econometrics Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!