ComeçarComece de graça

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.

Este exercício faz parte do curso

Time Series Analysis in R

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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)
Editar e executar o código