'Simulation 1 !N=1000 'Number of draws !T=500 'Sample size rndseed 123 'Seed create u !T 'Creating workspace vector(!N) tc1vs0= 0 vector(!N) tphi1vs0 = 0 vector(!N) tc2vs0 = 0 vector(!N) tphi2vs0 = 0 vector(!N) tc3vs0 = 0 vector(!N) tphi3vs0 = 0 vector(!N) tc1 = 0 vector(!N) tphi1 = 0 vector(!N) tc2 = 0 vector(!N) tphi2 = 0 vector(!N) tc3 = 0 vector(!N) tphi3 = 0 vector(!N) c1 = 0 vector(!N) phi1 = 0 vector(!N) c2 = 0 vector(!N) phi2 = 0 vector(!N) c3 = 0 vector(!N) phi3 = 0 smpl 1 !T 'Range to work for !i = 1 to !N '4 DGP '************************************************** ' y1 is AR(1) 'Parameters: !c1=1 !phi=0.2 genr y1= !c1 + nrnd smpl 2 !T genr y1= !c1 + !phi*y1(-1) + nrnd smpl @all '************************************************** '************************************************** ' y2 is AR(2) 'Parameters: !c2=1 !phi1=0.2 !phi2=0.5 genr y2= !c2 + nrnd smpl 3 !T genr y2= !c2 + !phi1*y2(-1) + !phi2*y2(-2) + nrnd smpl @all '************************************************** '************************************************** ' y3 is MA(1) 'Parameters: !c3=1 !theta=0.2 genr e=nrnd genr y3=!c3 + e + !theta*e(-1) '************************************************** ' Estimation AR(1) model equation eq1.ls y1 c y1(-1) equation eq2.ls y2 c y2(-1) equation eq3.ls y3 c y3(-1) tc1vs0(!i)=eq1.@tstats(1) tphi1vs0(!i) = eq1.@tstats(2) tc1(!i)=(eq1.@coef(1)-!c1)/eq1.@stderrs(1) tphi1(!i) = (eq1.@coef(2)-!phi)/eq1.@stderrs(2) c1(!i)=eq1.@coef(1) phi1(!i) = eq1.@coef(2) tc2vs0(!i) = eq2.@tstats(1) tphi2vs0(!i) = eq2.@tstats(2) tc2(!i) =(eq2.@coef(1)-!c2)/eq2.@stderrs(1) tphi2(!i) = (eq2.@coef(2)-!phi1)/eq2.@stderrs(2) c2(!i)=eq2.@coef(1) phi2(!i) = eq2.@coef(2) tc3vs0(!i) = eq3.@tstats(1) tphi3vs0(!i) = eq3.@tstats(2) tc3(!i) =(eq3.@coef(1)-!c3)/eq3.@stderrs(1) tphi3(!i) = (eq3.@coef(2)-!theta)/eq3.@stderrs(2) c3(!i)=eq3.@coef(1) phi3(!i) = eq3.@coef(2) next range 1 !N 'Simulation results range mtos(tc1vs0,tsc1vs0) 'Matrix to series mtos(tc2vs0,tsc2vs0) mtos(tc3vs0,tsc3vs0) mtos(tphi1vs0,tsphi1vs0) mtos(tphi2vs0,tsphi2vs0) mtos(tphi3vs0,tsphi3vs0) mtos(tc1,tsc1) 'Matrix to series mtos(tc2,tsc2) mtos(tc3,tsc3) mtos(tphi1,tsphi1) mtos(tphi2,tsphi2) mtos(tphi3,tsphi3) mtos(c1,bc1) 'Matrix to series mtos(c2,bc2) mtos(c3,bc3) mtos(phi1,bphi1) mtos(phi2,bphi2) mtos(phi3,bphi3) delete tc1vs0 tc2vs0 tc3vs0 tphi1vs0 tphi2vs0 tphi3vs0 tc1 tc2 tc3 tphi1 tphi2 tphi3 c1 c2 c3 phi1 phi2 phi3 y1 y2 y3 eq1 eq2 eq3 group cs bc1 tsc1vs0 tsc1 bc2 tsc2vs0 tsc2 bc3 tsc3vs0 tsc3 cs.distplot group phis bphi1 tsphi1vs0 tsphi1 bphi2 tsphi2vs0 tsphi2 bphi3 tsphi3vs0 tsphi3 phis.distplot