CommencerCommencer gratuitement

Simulate the simple moving average model

The simple moving average (MA) model is a parsimonious time series model used to account for very short-run autocorrelation. It does have a regression like form, but here each observation is regressed on the previous innovation, which is not actually observed. Like the autoregressive (AR) model, the MA model includes the white noise (WN) model as special case.

As with previous models, the MA model can be simulated using the arima.sim() command by setting the model argument to list(ma = theta), where theta is a slope parameter from the interval (-1, 1). Once again, you also need to specify the series length using the n argument.

In this exercise, you'll simulate and plot three MA models with slope parameters 0.5, 0.9, and -0.5, respectively.

Cet exercice fait partie du cours

Time Series Analysis in R

Afficher le cours

Instructions

  • Use arima.sim() to simulate a MA model with the slope parameter set to 0.5, and series length 100. Save this model to x.
  • Use another call to arima.sim() to simulate a MA model with the slope parameter set to 0.9. Save this model to y.
  • Use a third call to arima.sim() to simulate a final MA model with the slope parameter set to -0.5. Save this model to z.
  • Use plot.ts() to display all three models.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Generate MA model with slope 0.5
x <- arima.sim(model = ___, n = ___)

# Generate MA model with slope 0.9
y <- 

# Generate MA model with slope -0.5
z <- 

# Plot all three models together
plot.ts(cbind(___, ___, ___))
Modifier et exécuter le code