50 likes | 170 Vues
This document examines the implications of non-constant variance in regression analysis, focusing on Ordinary Least Squares (OLS) and Weighted Least Squares (WLS) methods. It details a simulation with a dataset of 10,000 observations, where varying error structures are implemented to demonstrate the differences in beta estimates between OLS and WLS. The findings emphasize the importance of accounting for heteroscedasticity in modeling to ensure reliable statistical inferences.
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;