悬赏 20 个论坛币 未解决
已解决!谢谢各位
有一组数据 (如下):
第五年的数据缺失,根据前四年的数据,stata如何求第五年的数据, stata程序该如何写呢?求大神指点
year nle nle_cm nle_wr
2012 48721 6309 10298
2013 38551 4232 7823
2014 43079 4321 8995
2015 42874 4488 8008
Ps.我的做法是:
首先,求出12至15年的年均增长率g,
然后,用2015年的数据乘以g,即为2016年的数据。
结果如下:
year nle nle_cm nle_wr
2016 37392.8 2959.52 5993.92
但是这一结果中 后面两个变量的数据从2013年开始 呈现出上升趋势, 但2016年的数据很小。我想去掉2012年的数据重新求g 再做一遍,不知道stata程序该怎么写,求赐教,感谢!
以求2016年nle 数据为例,我的stata命令如下:
bys province (year): gen nle16 = nle[1]
gen nleg = log(nle/nle16) // average growth rate
gen nle2016=nle*(nleg+1) if year==2015 //nle2016 变量 2015年数据
foreach v of varlist nle2016 {
bys province (year): replace `v' = `v'[_n-1] if year == 2016
} //让nle2016变量 2016年年数据与2015年相等
replace nle=nle2016 if year==2016