stata面板数据求增长率两种方法
编号id 时间变量year
变量income 同比增长率growth
(1)设置面板:xtset id year
滞后一阶得到上一年的income:
gen l_income=l.income
计算增长率:
gen growth=(income-l_income)/l_income
(2)设置面板:xtset id year
生成一阶差分,即当期减上期:
gen d_income=d.income
计算增长率:
gen growth=
d_income/(income-d_income)