Statalist


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

Re: st: re: calculating growth rates in a panel dataset


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: re: calculating growth rates in a panel dataset
Date   Mon, 13 Oct 2008 08:56:42 -0400

I think you mean D.log(sales) instead of log(D.sales) but that cannot
be done in one command as shown--one must generate logsales and then
calculate the difference.  In any case, the difference in logs is only
sometimes a good approximation for percent change, so I would stick
with the first syntax:

webuse grunfeld, clear
g not=log(d.kstock)
g lnk=log(kstock)
g dlnk=d.lnk
g pc=d.kstock/l.kstock
li com t kstock not-pc in 1/10


On Mon, Oct 13, 2008 at 8:46 AM, Kit Baum <[email protected]> wrote:
> < >
> Martin suggested
>
> - bys id: g salesgrowth=(sales[_n]-sales[_n-1])/sales[_n-1]-
>
> This works, but I spend some time every year when I lecture about panel data
> explaining to students why it is a Very Bad Idea to do so.
>
> bys id: g salesgrowth = D.sales/L.sales
> or
> bys id: g salesgrowth = log(D.sales)
>
> is a much safer way to do this, as the time-series operators will catch any
> issues with the time index (what if period 4 was not recorded for a given
> firm?). It requires that the data be -xtset- or -tsset-, and doing so will
> also catch some miscoding if the time index. Best to have Stata look for
> such mistakes in the process of data transformation. Very misleading results
> can be produced if you use explicit subscripts and the observation is
> completely missing (not Stata missing, but not recorded at all).
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index