PACF
Install and import#
npm install fintech-algorithmsimport { pacf } from "fintech-algorithms/statistical-time-series/diagnostics/pacf";Signature#
pacf(values, maxLag)Partial autocorrelation: correlation at each lag with the intervening lags removed. Read together with the ACF it identifies model order — a PACF cutting off after lag p suggests AR(p).
Parameters#
| Name | Type | Notes |
|---|---|---|
values | number[] | Observation series in chronological order, oldest first. |
maxLag | number | Highest lag to compute. min: 1 · integer: true |
Returns#
{ method, variant, coefficients, acf_coefficients, recursion, confidence_95 }
Partial coefficients with the Durbin–Levinson recursion steps that produced them.
Errors#
- When maxLag is not less than the sample size — throws
Complexity: time O(maxLag²),
space O(maxLag).
Worked example#
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input#
[0.49366418, 1.54242291, -0.82556495, 0.47513288, 0.50704417, -0.3816439]Showing 6 of 96 elements.
12Call#
pacf(values, maxLag)Returns#
object with 10 fields: method, variant, nobs, max_lag, coefficients, acf_coefficients, recursion, confidence_95, …
{
"method": "pacf",
"variant": "biased-yule-walker-levinson-durbin",
"nobs": 96,
"max_lag": 12,
"coefficients": [
1,
0.6643847368068891,
-0.0011391366900339354,
-0.013487015741398519,
-0.1763888054329689,
-0.1217089519082119
],
"acf_coefficients": [
1,
0.6643847368068891,
0.4407707648102877,
0.28488438813871975,
0.08546397187939134,
-0.07801591085987973
],
"recursion": [
{
"lag": 1,
"reflection": 0.6643847368068891,
"prediction_variance": 0.5585929214980406
},
{
"lag": 2,
"reflection": -0.0011391366900339354,
"prediction_variance": 0.5585921966497681
},
{
"lag": 3,
"reflection": -0.013487015741398519,
"prediction_variance": 0.5584905889562045
}
],
"confidence_95": 0.2000416623272929,
"state": "estimated",
"reason": "positive prediction variance through requested lag"
}Other exports#
This module also exports
acf, adf, kpss, ljungBox, zivotAndrews, runDiagnostic. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams#
Calculation flow#
PACF decision flow
flowchart TD
A["Ordered finite series"] --> B{"Contract valid?"}
B -- "No" --> X["Stop: explicit invalid state"]
B -- "Yes" --> C["Compute biased ACF"]
C --> D["Seed reflection and variance"]
D --> E["Run Levinson-Durbin recursion"]
E --> F["Inspect incremental lag coefficient"]
F --> G{"Declared strict decision rule"}
G --> H["Report machine state, null, and limitation"]
H --> I["Compare with Augmented Dickey-Fuller"]
How it works#
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References#
- statsmodels.tsa.stattools.acf
- statsmodels.tsa.stattools.pacf
- Evidence decisions