vDataFrame.acf¶
In [ ]:
vDataFrame.acf(column: str,
ts: str,
by: list = [],
p=12,
unit: str = "rows",
method: str = "pearson",
acf_type: str = "bar",
confidence: bool = True,
alpha: float = 0.95,
round_nb: int = 3,
show: bool = True,
ax = None,
**style_kwds,)
Computes the correlations of the input vcolumn and its lags.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
ts | str | ❌ | TS (Time Series) vcolumn to use to order the data. It can be of type date or a numerical vcolumn. |
column | str | ❌ | Input vcolumn to use to compute the Auto Correlation Plot. |
by | list | ✓ | vcolumns used in the partition. |
p | int / list | ✓ | If int: the maximum number of lag to consider during the computation. If List: a list of the different lags to include in the computation. p must be positive or a list of positive integers. |
unit | str | ✓ | Unit to use to compute the lags.
|
method | str | ✓ | Method to use to compute the correlation.
|
acf_type | str | ✓ | ACF Type.
|
confidence | bool | ✓ | If set to True, the confidence band width is drawn. |
alpha | float | ✓ | Significance Level. Probability to accept H0. Only used to compute the confidence band width. |
round_nb | int | ✓ | Round the coefficient using the input number of digits. It is used only if acf_type is 'heatmap'. |
show | bool | ✓ | If set to True, the Auto Correlation Plot will be drawn using Matplotlib. |
ax | Matplotlib axes object | ✓ | The axes to plot on. |
**style_kwds | any | ✓ | Any optional parameter to pass to the Matplotlib functions. |
Returns¶
tablesample : An object containing the result. For more information, see utilities.tablesample.
Example¶
In [61]:
from verticapy.datasets import load_amazon
amazon = load_amazon()
display(amazon)
In [62]:
# Autocorrelation Plot for each 'month' lag using Spearman coefficients
# p = 48: it will compute 48 'months' lags
amazon.acf(ts = "date",
column = "number",
p = 48,
by = ["state"],
unit = "month",
method = "spearman")
Out[62]:
In [63]:
# Autocorrelation Plot using only the selected lags
amazon.acf(ts = "date",
column = "number",
by = ["state"],
p = [1, 3, 6, 7],
unit = "year",
method = "pearson")
Out[63]:
In [64]:
# Autocorrelation Heatmap for each 'month' lag
amazon.acf(ts = "date",
column = "number",
by = ["state"],
p = 12,
unit = "month",
method = "pearson",
round_nb = 3,
acf_type = "heatmap")
Out[64]:
In [65]:
# Autocorrelation Line for each 'month' lag
amazon.acf(ts = "date",
column = "number",
by = ["state"],
p = 12,
unit = "month",
method = "pearson",
acf_type = "line")
Out[65]:
See Also¶
vDataFrame.corr | Computes the Correlation Matrix of a vDataFrame. |
vDataFrame.cov | Computes the Covariance Matrix of the vDataFrame. |
vDataFrame.interpolate | Interpolates and computes a regular time interval vDataFrame. |
vDataFrame.pacf | Computes the Partial Autocorrelations of the input vcolumn. |