3

I want to answer the following question, I know that I can use the arima.sim function but I am not sure how to simulate model asked:

I want to simulate the following:

yt =α+βt+φyt−1 +εt, εt ∼IIDN(0,1)

when: alpha=1, beta=0 and theta=0.8

Before each simulation we should set the seed to 100,000. Assume a starting value of y0=0 and obtain 500 observations. I have tried the following but it doesn't seem to work:

set.seed(seed = 100000)
e <- rnorm(500)
m1 <- arima.sim(model = list(c(ma=0.8,alpha=1,beta=0)),n=500)

I have to simulate 4 different models for 4 different values of beta, theta and alpha. Any suggestions?

Thanks in advance.

Peter
  • 151
  • 1
  • 11
  • If `beta = 0` then there is no (deterministic) time-dependent trend. Are you sure this is correct? In that case you have a simple MA(1) process with a non-zero mean. PS. You seem to be mixing up phi and theta. Your equation contains phi (for the MA(1) component), but later you write `theta = 0.8`. Is that a typo? – Maurits Evers Mar 10 '20 at 22:43

2 Answers2

3

Since you were using arima.sim in your attempt, here is an arima.sim option:

set.seed(100000)
t <- 1:500
alpha <- 1
beta <- 0
theta <- 0.8
ts <- alpha + beta * t + arima.sim(list(ma = theta), n = length(t))

Since beta = 0, there is no deterministic time-dependent trend, and the process corresponds to an MA(1) process with non-zero mean alpha.

This decomposition into a deterministic and stochastic term corresponds to rewriting your equation as

enter image description here

with the MA(1) process

enter image description here

where the ϵ's are the i.i.d. N(0, 1) residuals.

We can visualise the data

library(forecast)
autoplot(ts)

enter image description here

Maurits Evers
  • 49,617
  • 4
  • 47
  • 68
2

1. (α,β,φ) = (1,0,0.8)

set.seed(seed = 1232020)
e <- rnorm(500,mean=0,sd=1)

alpha <- 1
beta <- 0
theta <- 0.8
m_1 <- 0
for(i in 2:length(e)){
  m_1[i] <- alpha+beta*i+theta*m_1[i-1]+e[i]
}

Think this should do the trick :)

Community
  • 1
  • 1
Peter
  • 151
  • 1
  • 11