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

st: re: calculating growth rates in a panel dataset

From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: calculating growth rates in a panel dataset
Date   Mon, 13 Oct 2008 08:46:53 -0400

< >
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
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).

Kit Baum, Boston College Economics and DIW Berlin
An Introduction to Modern Econometrics Using Stata:

*   For searches and help try:

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