Apologies - I should have looked at the gratis example more carefully, thus I have

added:

- nothing onto sim.ts.m2
- the mean onto the simulated series
- the mean onto the estimated ar1 coeff

Correct?

```
# Simulate ARIMA(1,1,0) with constant i.e. ARIMA-in-1st-diff
# ----------------------------------------------------------
constant <- +150.0
phi1 <- +0.7
mean <- (constant/(1.0 - phi1))
mean # theoretical mean (or isolating behaviour) as you look at the graph
sim.ts.m2 <- arima.sim(list(order = c(1,1,0), ar = 0.7), n = 200) # + 0
ts.plot(sim.ts.m2)
ts.plot(sim.ts.m2 + mean)
# Base R
sim.df <- as.data.frame(sim.ts.m2[2:201])
b.fit <- sim.df |>
stats::arima( order=c(1,1,0),
fixed = list(ar1 = NA),
transform.pars = FALSE,
method = "CSS-ML", optim.control = list(maxit = 1000)
)
b.fit
b.mean_est <- b.fit$coef[[1]] + mean
b.mean_est
# library(forecast)
f.fit <- sim.ts.m2[2:201] |>
forecast::Arima( order=c(1,1,0),
fixed = list(ar1 = NA),
transform.pars = FALSE,
method = "CSS-ML", optim.control = list(maxit = 1000)
)
f.fit
f.mean.est <- f.fit$coef[[1]] + mean
f.mean.est
# library(fable)
library(fable)
tb <- as_tsibble(sim.ts.m2)
fit <- tb |>
dplyr::slice(-1) |>
model('tb'= ARIMA( value ~ 0 + pdq(1, 1, 0),
fixed = list(ar1 = NA),
transform.pars = FALSE,
method = "CSS-ML", optim.control = list(maxit = 1000))
)
fit
report(fit)
mean_est <- fit[[1]][[1]]$fit$par$estimate[1] + mean
mean_est
```

Further, I can simulate an ARIMA(0,0,1) with constant as:

```
#===============================
# Simulate ARIMA(0,0,1) with constant ARIMA-IN-LEVELS
# ---------------------------------------------------
# y = 20 + e(t) + 0.8*e(t-1)
# --------------------------
# R BURN-IN: arima.sim, n.start = NA, the default, a reasonable value is computed
# ---------
library(fpp3)
constant <- +20
theta1 <- +0.8
mean <- constant
ma1 <- arima.sim(model=list(ma=theta1), sd=sqrt(1), n=100) + constant
index <- c(1:100)
tb <- bind_cols(index=index, ma1=ma1) |>
gather("Series", "value", -index) |>
as_tsibble(index=index, key=Series)
tb
p1_R <- tb |> autoplot(value) +
ggplot2::ggtitle("MA(1)\ny = 20 + e(t) + 0.8*e(t-1)")
# fit ARIMA
fit <- tb |>
model('tb'= ARIMA( value ~ 1 + pdq(0, 0, 1) + PDQ(0, 0, 0),
method = "CSS-ML", optim.control = list(maxit = 1000))
)
fit
report(fit)
```

and in library(gratis) as:

```
#===============================
# Simulate ARIMA(0,0,1) ARIMA-IN-LEVELS
# -------------------------------------
# y = 20 + e(t) + 0.8*e(t-1)
# --------------------------
library(fpp3)
constant <- +20
theta1 <- +0.8
mean <- constant
ma1 <- gratis::arima_model(p = 0, d = 0, q = 1,
theta = theta1,
constant = constant,
sigma = 1
)
ma1_d0 <- gratis::generate(ma1, length = 100, nseries = 1)
ma1_d0
ma1_d0 |>
autoplot(value) +
ggplot2::ggtitle("MA(1)\ny = 20 + e(t) + 0.8*e(t-1)")
# fit ARIMA (as the model is written down)
fit <- ma1_d0 |>
model('ma1_d0_sim'= ARIMA( value ~ 1 + pdq(0, 0, 1),
fixed = list(ma1 = NA, constant = NA),
transform.pars = FALSE,
method = "CSS-ML", optim.control = list(maxit = 1000))
)
fit
report(fit)
mean_est <- fit[[1]][[1]]$fit$par$estimate[2]
mean_est
```

Correct?

What about an

(i) ARIMA(0,1,1) with constant ?

(ii) ARIMA(1,0,1) with constant ?

(iii)ARIMA(1,1,1) with constant ?