' Initialize a bunch of things rndseed 123 !nrep=5000 ' Number of Monte Carlo replications !n=25 ' Change this for the desired sample size, T smpl 1 !n series x=0 series y=0 series z=0 series e2 series r3 series r4 vector(!nrep) bhat vector(!nrep) t1 vector(!nrep) r2 vector(!nrep) durbwat vector(!nrep) jbera vector(!nrep) bpgod vector(!nrep) ftest '========================== ' Start of the Monte Carlo loop for !i=1 to !nrep smpl 2 !n+1000 x=x(-1)+2*@rnorm y=y(-1)+@rnorm z=z(-1)+@rnorm smpl 1001 !n+1000 ' Drop the first 1,000 obs. equation eq3.ls y c x z bhat(!i)=c(2) t1(!i)=abs(@tstats(2)) r2(!i)=eq3.@r2 ftest(!i)=(@r2/2)/((1-@r2)/(!n-3)) durbwat(!i)=eq3.@dw e2=resid*resid r3= ( resid/@stdevp(resid) )^3 r4=( resid/@stdevp(resid) )^4 jbera(!i)=(@obssmpl/6)*(@mean(r3)^2 + 0.25*(@mean(r4)-3)^2) equation eq4.ls e2 c x z bpgod(!i)=!n*eq4.@r2 next ' End of the Monte Carlo loop 'Convert vectors to series so we can plot the results smpl 1 !nrep mtos(bhat,b) mtos(t1, tstat) mtos(r2, rsq) mtos(ftest,f) mtos(durbwat, dw) mtos(jbera,jb) mtos(bpgod,bpg) show b hist b show tstat hist tstat show f hist f show dw hist dw show rsq hist rsq show jb hist jb show bpg hist bpg