4

如何使用genoregen命令在 Stata 中生成不同年份的观测值之间的百分比变化?例如,我有 1990 到 2010 年的观察结果,每个观察值都有不同的支出值,我试图生成一个新的观察值,其中包含 1990-1991、1991-1992 等期间的百分比变化。

4

1 回答 1

3

// 这是另一个衡量增长的示例:

clear
set obs 100
gen year = _n + 1959
gen expenditure = _n^(1/3) + runiform()
line expenditure year, yti("Synthetic data example")

//来自国家主义者

bys year: g expendituregrowth=100*(expenditure[_n]-expenditure[_n-1])/expenditure[_n-1]

// 还:

gen expenditure_gr = (expenditure/expenditure[_n-1] - 1)*100 // growth rate for expenditure
gen expenditure_bl = 100*expenditure/expenditure[1] // baseline growth rate for expenditure; base 100 = 1960

line expenditure_gr year, yti("Growth rate")
line expenditure_bl year, yti("Growth rate (base 100 = 1960)")

// 的计算expenditure_gr是我认为你正在寻找的。

// 如果您的数据格式正确,请使用带有时间序列的 Stata 并轻松获得增长率:

tsset year, delta(1)
cap drop expenditure_gr
gen expenditure_gr = D.expenditure / 100*L.expenditure
于 2012-04-21T14:33:42.233 回答