Need help coding a monte carlo simulation.

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)

답변 (0개)

카테고리

도움말 센터File Exchange에서 Econometrics Toolbox에 대해 자세히 알아보기

질문:

2018년 3월 27일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by