Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Simulating Heteroscedasticity and correcting it

From   Veit Böckers <>
Subject   st: Simulating Heteroscedasticity and correcting it
Date   Wed, 06 Jun 2012 12:33:55 +0200




I really hope you can help me out on this. I  want to simulate heteroscedasticity and then correct  under the two regimes  a) known heteroscedasticity factor  b) unknown heteroscedasticity factor (i.e. white-robust). My question concerns the correction of heteroscedasticity if  the factor causing the heteroscedasticity, Omega, is known. Omega is defined as:

 Var(Residual)=sigma^2*Omega  ; Omega= diag[(lambda_1)^2; (lambda_2)^2; (lambda_3)^2… (lambda_t)^2]


If I recall correctly, my regression can be corrected like this :  y/lambda = constant+ beta* x/lambda + residual/lambda. However, I seem to have made a mistake that I cannot find. Here is my do-file:


set obs 1000

gen x1 = 2 * invnorm(uniform())

gen x2 = 4 * invnorm(uniform())


*** Generate Residual

gen e =  2*invnorm(uniform())

sum e

replace e = e-r(mean)


*Generate Heteroscedasticity with factor “s”  influencing my residual “e”

gen s = exp(0.4*x1)

gen e_het= s*e


*Generate true y under heteroscedasticity

gen y_het=10 +3*x1 + 2*x2 +e_het


* Estimation under total disregard of heteroscedasticity

reg y_het x1 x2


*** Estimation under the “known heteroscedasticity factor” regime


gen known_y=y/s

gen known_x1=x1/s

gen known_x2=x2/s



reg known_y known_x1 known_x2



Why do I not get close to the true relationship of y and x1/x2?


Thank you very much in advance for your answers,




© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index