Bookmark and Share

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, is already up and running.

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

Re: Re: st: Normalize Variables by s.d. (programmatically)

From   Christopher Baum <>
To   "" <>
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'
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'

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 Baum   |   Boston College Economics & DIW Berlin   |
                             An Introduction to Stata Programming  |
  An Introduction to Modern Econometrics Using Stata  |

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index