Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Christopher Baum <kit.baum@bc.edu> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: Re: st: Normalize Variables by s.d. (programmatically) |
Date | Fri, 23 Dec 2011 09:44:02 -0500 |
<> On Dec 23, 2011, at 2:33 AM, Daniel wrote: > If you already have created your dummies, you migth want to pass them > in an option. This way you do not need to identify the dummies in > <varlist>. Good point. We can go one better (now that I have been enlightened on the difference between fvunab and fvexpand) with: ----------------------------------------- prog drop _all prog stdize2 syntax varlist(ts) [if] [in] [, dummies(varlist fv ts) *] tsunab vl: `varlist' marksample touse tempvar rs qui g `rs' = 0 if `touse' foreach w of local vl { qui replace `rs' = `rs' + `w' if `touse' } preserve foreach w of local vl { qui summ `w' if `touse' & !mi(`rs') tempvar ww qui g `ww' = `w' / r(sd) if `touse' & !mi(`rs') loc neww: subinstr loc w "." "_" rename `ww' _`neww' loc vl2 "`vl2' _`neww'" } fvexpand `dummies' xtreg `vl2' `r(varlist)', `options' restore end -------------------------------------------- which will now, using the grunfeld dataset, allow the use of factor variables to represent a set of time fixed effects, a common issue in a panel: stdize2 invest D.mvalue L(1/2).kstock if company<7, fe dummies(i.year) Best wishes of the season Kit Kit Baum | Boston College Economics & DIW Berlin | http://ideas.repec.org/e/pba1.html An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html An Introduction to Modern Econometrics Using Stata | http://www.stata-press.com/books/imeus.html * * 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/