1
$\begingroup$

I am trying to use R to develop a corporate financial model.

The model includes various line items, X, of the following form with actual values for time period 1, 2.. n and projected values for periods n+1, n+2,.. n+k. g is the average growth rate for the forecast period.

I need to construct a vector of the following form:

  X=c(X1,X2,...,Xn,Xn+1=(1+g)Xn,Xn+2=(1+g)Xn+1,...,Xn+k=(1+g)Xn+k-1))

How would I do this in R?

I have tried looking up the R literature on lagged variables but could not find a simple example which does what is required. I look forward to any guidance that can be given.

$\endgroup$

1 Answer 1

2
$\begingroup$

Does this do what you want?

x1 <- 1:10
g <- .1
x2 <- cumprod(c(tail(x1, 1), rep(1+g, 5)))
c(x1, x2)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.