【发布时间】:2019-05-02 20:40:49
【问题描述】:
我有两个变量year 和price,我想计算前一个变量的增长。但是,每次计算中的基准年都是不变的。
考虑下表:
+------+-------+--------+
| year | price | growth |
+------+-------+--------+
| 2010 | 7 | -0.3 |
+------+-------+--------+
| 2011 | 9 | -0.1 |
+------+-------+--------+
| 2012 | 10 | 0 |
+------+-------+--------+
| 2013 | 12 | 0.2 |
+------+-------+--------+
| 2014 | 13 | 0.3 |
+------+-------+--------+
| 2015 | 17 | 0.7 |
+------+-------+--------+
增长公式为:
(price of second year - price of first year) / price of first year
在我的公式中,第一年总是2012:
growth = (price - price (for year=2012) ) / price (for year=2012)
如何在 Stata 中生成这个公式?
【问题讨论】:
标签: statistics formula stata