Hi,
I have simulated the following ARIMA(1,0,1) model in fable
y(t) = 3 + 0.7*y(t-1) + e(t) + 0.6*e(t-1)
which I think is correct? Is there a better way?
How do I simulate an ARIMA(1,1,1) model with the SAME parameters, and how do I write down the equation?
library(fpp3)
library(patchwork)
set.seed(1)
nburn <- 100
nobs <- 200
T <- nburn+nobs
# Define the parameters for the ARIMA(1,0,1) model
phi <- +0.7
theta <- +0.6
constant <- 3
mean <- constant / (1 - phi)
mean
y <- vector()
y[1] <- 0
eps <- rnorm(nburn+nobs)
for(i in 2:T)
y[i] <- constant + phi * (y[i-1]) + eps[i] + theta * eps[i-1]
sim <- tsibble(idx = seq_len(T), y = y, index = idx)
sim
p1 <- sim |>
slice(101:n()) |>
autoplot(y) +
ggplot2::ggtitle("Simulated Time Plot\ny(t) = c + phi*y(t-1) + e(t) + theta*e(t-1)")
p2 <- sim |>
slice(101:n()) |>
ACF(y) |>
autoplot() +
ggplot2::ggtitle("ACF\ny(t) = c + phi*y(t-1) + e(t) + theta*e(t-1)")
p1 + p2
# fit ARIMA
fit <- sim |> slice((nburn+1):n()) |>
model('sim'= ARIMA( y ~ 1 + pdq(1, 0, 1) + PDQ(0, 0, 0),
method = "CSS-ML", optim.control = list(maxit = 1000))
)
fit
report(fit)
fit$sim[[1]][[1]][[1]] # constant
fit$sim[[1]][[1]][[6]] # mean
Amarjit