Simulating future values in a time series without using a model

时间:2018-08-22 13:48:54

标签: r time-series forecasting

I would like to have one year ahead simulations of a non-stationary time-series with annual time steps (fish landings). I would like to keep it as simple as possible because I would do this within a much larger simulation framework (I can't check model fit or so and different time series will be used). I do however hope to at least include lag-1 temporal auto-correlation.

What I came up with so far:

set.seed(123)
x <- 100+cumsum(rnorm(30,0,20))
par(mfrow=c(2,1))
plot(x,type='l')
acf(x)

mu <- tail(x,1)
sig <- sd(diff(x))
ac <- acf(x,plot = FALSE)$acf[2,1,1]

nsim <- 500
set.seed(120)
devs <- rnorm(0,sig,n=nsim)
xnew1 <- ac*mu+(mu+devs)*sqrt(1-ac^2) # this is an equation I found in a paper
xnew2 <- ac*mu+(mu+devs)*(1-ac) # this is purely intuitive

xmat <- matrix(x,nsim,length(x),byrow=T)
xmat1 <- cbind(xmat,xnew1)
xmat2 <- cbind(xmat,xnew2)
matplot(t(xmat1),type='l')
matplot(t(xmat2),type='l')

Both of these equations are probably wrong, but it should give an idea of what I actually want to do. I also looked at autoregressive processes but can't seem to figure out how to code them by hand.

Any help is welcome and I know I might be completely tackling it from the wrong angle.

0 个答案:

没有答案