Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Veit Böckers <Veit.Boeckers@dice.uni-duesseldorf.de> |

To |
statalist@hsphsun2.harvard.edu |

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: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Tirthankar Chakravarty Gesendet: Mittwoch, 6. Juni 2012 20:46 An: statalist@hsphsun2.harvard.edu 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 <Veit.Boeckers@dice.uni-duesseldorf.de> 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 tchakravarty@ucsd.edu tirthankar.chakravarty@gmail.com * * 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/

**References**:**st: Simulating Heteroscedasticity and correcting it***From:*Veit Böckers <Veit.Boeckers@dice.uni-duesseldorf.de>

**Re: st: Simulating Heteroscedasticity and correcting it***From:*Tirthankar Chakravarty <tirthankar.chakravarty@gmail.com>

- Prev by Date:
**Re: st: Goodness-of-fit measure after -oprobit- with compex survey data** - Next by Date:
**st: imputation missing values** - Previous by thread:
**Re: st: Simulating Heteroscedasticity and correcting it** - Next by thread:
**[no subject]** - Index(es):