The partial autocorrelation(pacf) of an ARMA process is the function defined by the equation:
f(0) = 1,
f(x) = g(x)(x) correlation of series with itself. for
x >= 1
The first component of every pacf series is 1.
I implemented pacf with yule-walker equations of unbiased and mle outcomes. Yule-walker equations are the set of equations represented by:
Yule-walker uses the Toeplitz matrix(gives same output when stored in either row-major or column-major form) inverse with the outcomes to generate the intermediate vector results.
Here, we can generate pacf by making use of either
mle method with yule-walker function. For
unbiased, the denominator is
(n-k) whereas for
mle, it is
n (n is the size of time-series). To achieve that, I made use of fantastic Ruby
lambdas to make a closure over the variable
1 2 3 4 5 6 7 8
Below might have been a viable shortcut, but I used former for maintaining descriptive comments and simplicity in code:
Here is the useful description and theoretical implementation of yule-walker by University of Pennsylvania.
Henceforth, the overall yule-walker method looks like following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
toeplitz method generates the Toeplitz matrix, and
solve_matrix solves the equation by using the inverse and matrix muliplication.
pacf is available in
Statsample::TimeSeries and can be called as:
1 2 3 4
The entire implementation can be seen at : https://github.com/AnkurGel/statsample/blob/master/lib/statsample/timeseries.rb#L151 with it’s tests at : https://github.com/AnkurGel/statsample/blob/master/test/test_pacf.rb
Cheers, /-Ankur Goel