50 likes | 187 Views
Consequences of non-constant variance. /* ======================================================================== Consequence of non-constant variance Written by Ming-Yuan Leon Li ========================================================================= */ new; format /m1 /rd 9,3;
E N D
/* • ======================================================================== • Consequence of non-constant variance • Written by Ming-Yuan Leon Li • ========================================================================= • */ • new; • format /m1 /rd 9,3; • n=10000; @simulation number @ • beta=2; • Beta_OLS=zeros(n,1); • Beta_WLS=zeros(n,1); • x=2*Rndn(20,1); • z=1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20;
i=1; • do until i>n; • @ Data Gerneration Process: Y=beta*X1+u@ • u=Rndn(20,1); u=z.*u; • Y=beta*x+u; • @ OLS @ • Beta_OLS[i,.]=olsqr(Y,x); • @ WLS @ • Y_star=Y./z; X_star=X./Z; • Beta_WLS[i,.]=olsqr(Y_star,X_star)'; • i=i+1; • endo;
print " Mean of OLS beta estimates "; • meanc(Beta_OLS[.,1]); • print " Variance OLS beta estimates "; • stdc(Beta_OLS[.,1])^2; • print " "; • print " Mean of WLS beta estimates "; • meanc(Beta_WLS[.,1]); • print " Variance WLS beta estimates "; • stdc(Beta_WLS[.,1])^2;