Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AW: st: Simulating Heteroscedasticity and correcting it
From
Veit Böckers <[email protected]>
To
[email protected]
Subject
AW: st: Simulating Heteroscedasticity and correcting it
Date
Fri, 08 Jun 2012 09:44:04 +0200
Thank you very much! I knew I was making an unneccessary and easy mistake.
Best Regards,
Veit
-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]] Im Auftrag von Tirthankar Chakravarty
Gesendet: Mittwoch, 6. Juni 2012 20:46
An: [email protected]
Betreff: Re: st: Simulating Heteroscedasticity and correcting it
The following code should be self-explanatory. You need to weight the constant as well.
*----------------------------------------------------------------------------------
clear*
program wls_sim, eclass
drop _all
set obs 10000
gen x1 = rnormal()
gen x2 = rnormal()
gen e = rnormal()
* conditional heteroskedasticity
gen s = exp(0.4*x1)
gen e_het= s*e
* outcome variable
gen y_het=10 +3*x1 + 2*x2 +e_het
* OLS
reg y_het x1 x2
* WLS
g ones = 1
g known_ones = ones/s
gen known_y=y/s
gen known_x1=x1/s
gen known_x2=x2/s
reg known_y known_ones known_x1 known_x2, nocons
matrix vCoeff = e(b)
ereturn repost b = vCoeff
end
simulate _b, reps(100): wls_sim
su
*----------------------------------------------------------------------------------
T
On Wed, Jun 6, 2012 at 3:33 AM, Veit Böckers <[email protected]> wrote:
> Hello,
>
>
>
>
>
> 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,
>
>
>
> Veit
>
>
--
Tirthankar Chakravarty
[email protected]
[email protected]
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/