I'm trying to create a program that uses the Hannan-Rissanen algorithm to compute the sample parameters for an ARMA(p, q) auto-regressive moving average stochastic process.
The main step I'm having difficulty with is calculating the autocovariance function of the time series.
The program should take in an n×1-dimensional column vector Y and compute a k×1-dimensional column vector γ^hat given by:
where Ybar is the average of the elements of Y.
How can I compute the above sum efficiently? (obviously for loops would work, but I'm trying to get better at vectorized numpy operations) Since I'm using this as a learning experience, I would prefer not to use any numpy functions other than very basic ones like np.sum
or np.mean
.
The following previous similar question has been asked, but doesn't quite answer my question:
Computing autocorrelation of vectors with numpy (uses np.correlate
)
(a few others suffer the same problem of using more advanced numpy
functions, or aren't spitting out vectors as I wish to do here.)