Equivalence of AR(1) and MA(infinity)
To better understand the relationship between MA models and AR models, you will demonstrate that an AR(1) model is equivalent to an MA(\(\small \infty\)) model with the appropriate parameters.
You will simulate an MA model with parameters \(\small 0.8, 0.8^2, 0.8^3, \ldots \) for a large number (30) lags and show that it has the same Autocorrelation Function as an AR(1) model with \(\small \phi=0.8\).
Note, to raise a number x
to the power of an exponent n
, use the format x**n
.
This exercise is part of the course
Time Series Analysis in Python
Exercise instructions
- Import the modules for simulating data and plotting the ACF from statsmodels
- Use a list comprehension to build a list with exponentially decaying MA parameters: \(\small 1, 0.8, 0.8^2, 0.8^3, \ldots\)
- Simulate 5000 observations of the MA(30) model
- Plot the ACF of the simulated series
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# import the modules for simulating data and plotting the ACF
from statsmodels.tsa.arima_process import ArmaProcess
from statsmodels.graphics.tsaplots import plot_acf
# Build a list MA parameters
ma = [___ for i in range(30)]
# Simulate the MA(30) model
ar = np.array([1])
AR_object = ArmaProcess(ar, ___)
simulated_data = ___.generate_sample(nsample=5000)
# Plot the ACF
plot_acf(___, lags=30)
plt.show()