Get startedGet started for free

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.

This exercise is part of the course

Time Series Analysis in R

View Course

Exercise instructions

  • Use arima() to fit the MA model to the series x.
  • What are the slope (ma1), mean (intercept), and innovation variance (sigma^2) estimates produced by your arima() output? Paste these into your workspace.
  • Use a similar call to arima() to fit the MA model to the Nile data. Save the results as MA and use print() to display the output.
  • Finally, use the pre-written commands to plot the Nile data and your fitted MA values.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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)
Edit and Run Code