Statsample - Partial Autocorrelation

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 unbiased and 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 k as:

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:

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:

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