Statalist


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

Re: st: manual first differencing


From   Eva Poen <eva.poen@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: manual first differencing
Date   Mon, 16 Mar 2009 16:12:55 +0000

Nola,

if you tell us what your ultimate goal is, we might be able to provide
better advice. Your command only gives correct results if
a) your data is already sorted by year, and
b) there are no gaps in your variables.

A better version is

generate fdpop = d.pop

which will take care of those things automatically.

However, you can also use the d. operator in regressions, e.g.

regress yvar d.pop

without actually creating the variables. If you do want to create the
variables, use a loop (see -help forvalues-).

Eva


2009/3/16 Nola Agha <nolaa@sportmgt.umass.edu>:
> Hi -
>   I'd like to first difference all of the variables in my equation.  I have a
> panel dataset which is -xtset dmaid year-.  The following command seems to work
> quite well for one of my variables:
>
> by dmaid, sort: generate fdpop=pop[_n]-pop[_n-1]
>
> I'm wondering:
>
> a) if there is a built-in command to do this for an entire equation (as opposed
> to doing it variable by variable)?
>
> b) if not, if there is a way to automate this procedure for all of my (many)
> variables?
>
> Thanks,
> Nola

*
*   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/



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