*! version 1.0.0 June 28, 2020

Title

grvar - Applies a non-constant growth rate to a variable

Syntax

grvar
growthvar
var,
generate(name)
[option]

Main
generate(name) Specifies the name of the new variable. This is required.

replace Specifies if you want to replace the variable; default is not replace.

Description

grvar Calculate the future values of a variable from the initial value and a non-constant growth/decrease rate (e.g. inflation).
It is useful when we want to fit a variable with a growth rate in a time serie or panel data.

Creating a new variable using a growth rate is very simple to code, we just have to follow a specification like: x_t = x_0*(1+r)^t.
But if the growth rate is not constant, we cannot use that specification, the solution is represented in the following table:

+
+
| time growthvar var output |
+
+
| 1 . x x |
| 2 r1 . x*(1+r1) |
| 3 r2 . x*(1+r1)*(1+r2) |
| 4 r3 . x*(1+r1)*(1+r2)*(1+r3) |
+
+

This is exactly what the command grvar does in a time serie or panel data.

Examples

We import panel data and define panel and time variable

.webuse invest2.dta, clear

.xtset company time

Now, we create a growth rate and a new investment variable; we only keep the first investment value.

.gen GrowthInvest = (invest-L.invest)/L.invest

.gen Invest = invest if time==1

Finally, just using the first value and the growth rate of the investment, we calculate the values for all periods.

.grvar GrowthInvest Invest, gen(invest2)

Author

Daniel Pailañir
Email daniel.pailanir@gmail.com