ljungbox

In [ ]:
ljungbox(vdf,
         column: str,
         ts: str,
         by: list = [],
         p: int = 1,
         alpha: float = 0.05,
         box_pierce: bool = False)

Ljung–Box test (whether any of a group of autocorrelations of a time series are different from zero).

Parameters

Name Type Optional Description
vdf
vDataFrame
❌
Input vDataFrame.
column
str
❌
Input vcolumn to test.
ts
str
❌
vcolumn used as timeline. It will be to use to order the data. It can be a numerical or type date like (date, datetime, timestamp...) vcolumn.
by
list
✓
vcolumns used in the partition.
p
int
✓
Number of lags to consider in the test.
alpha
float
✓
Significance Level. Probability to accept H0.
box_pierce
bool
✓
If set to True, the Box-Pierce statistic will be used.

Returns

tablesample : An object containing the result. For more information, see utilities.tablesample.

Example

In [103]:
from verticapy import *
texas = vDataFrame("Texas")
texas["cases"].plot(ts = "date")
In [104]:
from verticapy.stats import ljungbox
ljungbox(texas,
         column = "cases",
         ts = "date",
         p = 10)
Out[104]:
Ljung–Box Test Statistic
p_value
Serial Correlation
191.034482758620681.411900511388355e-21
✅
2183.127506014434631.7154075871800807e-40
✅
3276.117716837964051.4650458360176346e-59
✅
4370.026665409392658.303756428668113e-79
✅
5464.87668083107943.033447199435367e-98
✅
6560.69090912376246.997958362723855e-118
✅
7657.29887356820681.103888634091634e-137
✅
8754.72120956820671.174754870318247e-157
✅
9852.7809351378279.188103577980987e-178
✅
10951.49622129167315.226090762139598e-198
✅
Rows: 1-10 | Columns: 4
In [105]:
# Box-Pierce
ljungbox(texas,
         column = "cases",
         ts = "date",
         p = 10,
         box_pierce = True)
Out[105]:
Box-Pierce Test Statistic
p_value
Serial Correlation
188.06.545446540951261e-21
✅
2176.06.054601895401188e-39
✅
3263.8240886.692083814228472e-57
✅
4351.472448.43441460658278e-75
✅
5438.945232000000031.1902907835209562e-92
✅
6526.242641.863999540246192e-110
✅
7613.18980800000013.5148375770453054e-128
✅
8699.78744000000017.951961882367499e-146
✅
9785.86208800000012.347224172641296e-163
✅
10871.4153369.018406318552994e-181
✅
Rows: 1-10 | Columns: 4