产生在Stata年度观测值之间变化百分比?(Generate percent change betw

2019-09-16 15:29发布

如何使用genegen命令来生成不同年份在Stata观测值之间的百分比变化? 例如,我对1990年观测到2010年,每对支出不同的值,我想生成一个与1990 - 1991年,1991 - 1992年等变化率的新观察

Answer 1:

//这是与增长的另一项措施的例子:

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

// 从Statalist :

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


文章来源: Generate percent change between annual observations in Stata?
标签: stata