Calculate the Phillips-Perron (PP) test for a unit root, per asset.

Phillips-Perron tests the same null hypothesis as the Augmented Dickey-Fuller test (a unit root), but corrects for heteroskedasticity and serial correlation in the errors nonparametrically via a Newey-West long-run variance estimate, rather than by adding lagged-difference terms to the regression as ADF does. PP and ADF should broadly agree on the same series since they test the same null with different correction methods.

For more information about the method, see the following paper:

  • Phillips, P.C.B., & Perron, P. (1988). “Testing for a Unit Root in Time Series Regression.” Biometrika, 75(2), 335-346.

Also known as: PP test, Z_t test.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Phillips-Perron Test for you. Just ask in plain English.

Calculate the Phillips-Perron Test in Python

The Phillips-Perron Test is available in the Econometrics module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_phillips_perron_test as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(["AMZN", "TSLA"], api_key="FINANCIAL_MODELING_PREP_KEY")

toolkit.econometrics.get_phillips_perron_test(period="quarterly")

Which returns:

  AMZN TSLA
Phillips-Perron Statistic -0.6688 -1.2623
Lags Used 9 9
Observations 46 46
Critical Value 1% -3.43 -3.43
Critical Value 5% -2.86 -2.86
Critical Value 10% -2.57 -2.57
Reject Unit Root (5%) 0 0

Parameters

get_phillips_perron_test accepts the following parameters:

  • period (str, optional): The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”.
  • column (str, optional): The historical data column to test. Defaults to “Adj Close”.
  • regression (str, optional): Which deterministic term to include, one of “c” (constant) or “ct” (constant and trend). Defaults to “c”. Note “n” (no constant) is not supported, see econometrics.unitroot_model.get_phillips_perron_test for why.
  • lags (int, optional): The truncation lag for the Newey-West long-run variance estimate. Defaults to the Schwert (1989) rule of thumb.
  • include_benchmark (bool, optional): Whether to include “Benchmark” among the assets tested. Defaults to False.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.

The Econometrics module page introduces the module, and the sidebar lists all of its functions.

Share