cochrane_orcutt

In [ ]:
cochrane_orcutt(model, 
                vdf: (vDataFrame, str), 
                ts: str, 
                prais_winsten: bool = False, 
                drop_tmp_model: bool = True,)

Performs a Cochrane-Orcutt estimation.

Parameters

Name Type Optional Description
model
vModel
Linear regression object.
vdf
vDataFrame / str
Input relation.
ts
str
vcolumn of numeric or date-like type (date, datetime, timestamp, etc.) used as the timeline and to order the data.
prais_winsten
bool
If true, retains the first observation of the time series, increasing precision and efficiency. This configuration is called the Prais–Winsten estimation.
drop_tmp_model
bool
If true, it drops the temporary model.

Returns

model

A linear model with the following information stored as attributes:

  • coef_: Model's coefficients.
  • pho_: Cochrane-Orcutt pho.
  • anova_table_: ANOVA table.
  • r2_: R2.

Example

In [15]:
from verticapy.datasets import load_amazon
amazon = load_amazon().search("state = 'ACRE'")
amazon["number_bias"] = "POWER(number, 2) - 500 + RANDOM() * 1000"

from verticapy.learn.linear_model import LinearRegression
model = LinearRegression("model_lr")
model.drop()
model.fit(amazon, ["number_bias"], "number")
model.coef_
Out[15]:
Abc
predictor
Varchar(65000)
123
coefficient
Float
123
std_err
Float
123
t_value
Float
123
p_value
Float
1Intercept119.64676912341218.02140147960316.639148972893692.13193113743317e-10
2number_bias0.0002871173954122037.15827828366076e-0640.10983982944161.28381262117036e-107
Rows: 1-2 | Columns: 5
In [17]:
from verticapy.stats import cochrane_orcutt
co = cochrane_orcutt(model, amazon, "date")
co.coef_
Out[17]:
Abc
predictor
Varchar(65000)
123
coefficient
Float
123
std_err
Float
123
t_value
Float
123
p_value
Float
1Intercept82.997426196999716.08738002508635.159163646757615.25690500077592e-07
2number_bias0.0002660825746392926.91739924957652e-0638.46569571007211.22772718982409e-103
Rows: 1-2 | Columns: 5
In [18]:
co.pho_
Out[18]:
0.381523480423635