I am programming a function in order to get an over the sample simulation. My function is the following:
oos <- function(alpha, rho,rv){
ar_oos <-(alpha + rho*rv)
return(ar_oos)
}
I define now arbitrary the values of alpha and rho:
rho <-0.4
alpha <- 45
Lets create a matrix to save our results:
results <- matrix(NA, nrow=(1239), ncol=1)
The first 240 values will be a stationary time series:
results[1:240] <- rnorm(240, 0, 2)
What I need now is a loop that takes the previous value and recalculate the funcion oos until I fill the 1,239 values of my matrix:
results[241] <- oos(alpha, rho, rv[240])
results[242] <- oos(alpha, rho, rv[241])
results[243] <- oos(alpha, rho, rv[242])
results[244] <- oos(alpha, rho, rv[243])
Does anyone have an idea?
Thank you very much !