kris91
kris91

Reputation:

Initializing in arima.sim in R

I want to simulate from an ARMA(1,2) series. I need to initialize $X0$ = 9. How do I do it in R? I cannot find any provision for initialization in arima.sim

Upvotes: 2

Views: 3456

Answers (1)

javlacalle
javlacalle

Reputation: 1049

You may get it using the right combination of the arguments start.innov, n.start and innov that are passed to stats:arima.sim.

For an AR process with parameter phi, it is easy to see that the following yields the first simulated value equal to $X_0=9$.

n <- 50
phi <- 0.5
x0 <- 9
set.seed(123)
arima.sim(n, model=list(ar=phi), start.innov=x0/phi, n.start=1, 
  innov=c(0,rnorm(n-1)))
#  [1]  9.00000000  3.93952435  1.73958469  2.42850066  1.28475872  0.77166710
#  [7]  2.10089853  1.51136547 -0.50937850 -0.94154210 -0.91643302  0.76586529
# [13]  0.74274647  0.77214469  0.49675506 -0.30746361  1.63318133  1.31444115
# ...

For the ARMA(1,2) you should do the maths, for example I found the following combination for the parameters used below:

set.seed(123)
arima.sim(n=50, model=list(ar=0.5, ma=c(0.4, 0.2)), start.innov=c(0,0,10), 
  n.start=3, innov=c(rep(0,3),rnorm(47)))
#  [1]  9.00000000  6.50000000  3.25000000  1.06452435  0.07789443  1.39348940
#  [7]  1.34470092  1.14158321  2.35167337  2.34863643  0.43663646 -0.88237587
# [13] -1.41460329  0.20114479  0.86088655  1.21995661  0.95293237  0.04505243
# ...

Upvotes: 4

Related Questions