I have been trying to calculate the PACF manually, but I encountered some issues with the following equation:
$PACF = \frac{Covariance ([Y_{t}|Y_{t-1}, Y_{t-2},...,Y_{t-k+1}],[Y_{t-k}|Y_{t-1}, Y_{t-2},...,Y_{t-k+1}])}{\sigma_{[Y_{t}|Y_{t-1}, Y_{t-2},...,Y_{t-k+1}]} \sigma_{[Y_{t-k}|Y_{t-1}, Y_{t-2},...,Y_{t-k+1}]} } $
Let's supposed we are trying to calculate the PACF for lag 3, so k=3.
Nominator: To be able to calculate the Covariance we need two variables. The equation for covariance requires cov(x, y).
Denominator: To be able to calculate the standard deviation we need one variable.
With lag = 3 on the nominator, there would be 6 variables in total, three on the left and 3 on the right side of the comma.
For lag 2 the way we turn 4 variables into two is by plotting the two variables on each side of the formula against each other, finding a line of best fit using OLS, and then finding the residuals. This then gives us one variable, so two in total for the nominator.
How would I do this for lag 3, I could maybe plot 3 variables and find that correlation, but that clearly isn't it because what about lag 4 or lag 5.
So how do I turn the list of variables into two for the nominator (or one for each standard deviation on the denominator)?