Estimate the simple moving average model
Now that you've simulated some MA models and calculated the ACF from these models, your next step is to fit the simple moving average (MA) model to some data using the arima() command. For a given time series x we can fit the simple moving average (MA) model using arima(..., order = c(0, 0, 1)). Note for reference that an MA model is an ARIMA(0, 0, 1) model.
In this exercise, you'll practice using a preloaded time series (x, shown in the plot on the right) as well as the Nile dataset used in earlier chapters.
Questo esercizio fa parte del corso
Time Series Analysis in R
Istruzioni dell'esercizio
- Use
arima()to fit the MA model to the seriesx. - What are the slope (
ma1), mean (intercept), and innovation variance (sigma^2) estimates produced by yourarima()output? Paste these into your workspace. - Use a similar call to
arima()to fit the MA model to theNiledata. Save the results asMAand useprint()to display the output. - Finally, use the pre-written commands to plot the
Niledata and your fitted MA values.
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Fit the MA model to x
arima(___, order = ___)
# Paste the slope (ma1) estimate below
# Paste the slope mean (intercept) estimate below
# Paste the innovation variance (sigma^2) estimate below
# Fit the MA model to Nile
MA <- arima(___, order = ___)
print(MA)
# Plot Nile and MA_fit
ts.plot(Nile)
MA_fit <- Nile - resid(MA)
points(MA_fit, type = "l", col = 2, lty = 2)