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.
This is a part of the course
“Time Series Analysis in R”
Exercise instructions
- Use
arima.sim()
to simulate a MA model with the slope parameter set to 0.5, and series length 100. Save this model tox
. - Use another call to
arima.sim()
to simulate a MA model with the slope parameter set to 0.9. Save this model toy
. - Use a third call to
arima.sim()
to simulate a final MA model with the slope parameter set to -0.5. Save this model toz
. - Use
plot.ts()
to display all three models.
Hands-on interactive exercise
Have a go at this exercise by completing this sample 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(___, ___, ___))