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

From |
Eva Poen <eva.poen@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: AW: can I get standardized coefficients by standardize variables first? |

Date |
Tue, 3 Mar 2009 20:33:11 +0000 |

Mandy, as Martin demonstrated, missing values can lead to differing results. In order to get identical results, you have to apply the standardisation with respect to the estimation sample only (observations with missing values will not be in the estimation sample). There are two ways to do this. Firstly, you could estimate your model with regular (i.e. not standardised) coefficients and then make use of e(sample): xtreg y var1 var2 var3 var4, fe foreach x of varlist y var1 var2 var3 var4 { egen std`x' = std(`x') if e(sample) } xtreg stdy stdvar1 stdvar2 stdvar3 stdvar4, fe Alternatively, you could skip the first estimation and use the missing() function: foreach x of varlist y var1 var2 var3 var4 { egen std`x' = std(`x') if !missing(y,var1,var2,var3,var4) } However, be aware that missing values may also lurk in cluster or weight variables; if so, make sure you include these variables in the !missing() statement. Hope this helps, Eva 2009/3/3 Martin Weiss <martin.weiss1@gmx.de>: > <> > > Mandy, > > try the code below to see how the solutions drift apart depending on the > percentage of missings that you introduce into the dataset. ( I know my > method is crude but illustrates the issue quite well). Set the thing to zero > to see that w/o missings the solutions coincide. > > > ********** > clear* > set mem 400m > * enter the percentage of missings here > loc mis 0.01 > u http://www.stata-press.com/data/imeus/traffic, clear > foreach var of varlist fatal beertax spircons unrate perincK { > replace `var'=. if runiform()<`mis' > } > qui ds, not(type string) > foreach var of varlist `r(varlist)'{ > egen std`var'=std(`var') > } > xi: reg fatal beertax spircons unrate perincK i.state, beta > xtreg stdfatal stdbeertax stdspircons stdunrate stdperincK, fe > ********** > > > HTH > Martin > _______________________ > ----- Original Message ----- From: "Mandy fu" <mandy.fu1@gmail.com> > To: <statalist@hsphsun2.harvard.edu> > Sent: Tuesday, March 03, 2009 8:22 PM > Subject: Re: st: AW: can I get standardized coefficients by standardize > variables first? > > >> Dear Mr. Weiss, >> >> Thanks for your reply! You are right---it should be -foreach-- rather >> than --local--. >> What I meant and actually used is using --foreach--to standardize all >> the variables. I don't know why I wrote into -local--. Thanks! >> >> I think I kind of find why the results given by the two methods are >> different. It maybe is due to missing values. That is, for some groups >> , there are missing values for some years and for some indepent >> variables. >> ------------------------------ >> group year y var1 var2 var 3 var4 >> 1 1981 1 1 missing 0 1 >> 1 1982 >> 1 1983 >> 2 1981 >> 2 1982 >> 3 1981 >> 3 1982 >> 3 1983 >> ------------------------------------ >> For the first observation, it's included in the way "standardizing >> varaibles first" because y , var1,var3-4 included this observation. >> But it's excluded from the way "using beta option directly". >> >> So, can I underdtand that it is an alternative way to get beta >> coefficents by standardized variables first and then use the regular >> commands? This is the question I'm interested in. >> >> Thanks a lot! >> Mandy * * 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: can I get standardized coefficients by standardize variables first?***From:*Mandy fu <mandy.fu1@gmail.com>

**Re: st: AW: can I get standardized coefficients by standardize variables first?***From:*Mandy fu <mandy.fu1@gmail.com>

**Re: st: AW: can I get standardized coefficients by standardize variables first?***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**RE: st: double hurdle model with Tobit second stage estimation** - Next by Date:
**Re: st: AW: can I get standardized coefficients by standardize variables first?** - Previous by thread:
**Re: st: AW: can I get standardized coefficients by standardize variables first?** - Next by thread:
**Re: st: AW: can I get standardized coefficients by standardize variables first?** - Index(es):

© Copyright 1996–2017 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |