statsmodels.stats.anova.anova_lm
-
statsmodels.stats.anova.anova_lm(*args, **kwargs)
[source] -
ANOVA table for one or more fitted linear models.
Parameters: args : fitted linear model results instance
One or more fitted linear models
scale : float
Estimate of variance, If None, will be estimated from the largest model. Default is None.
test : str {?F?, ?Chisq?, ?Cp?} or None
Test statistics to provide. Default is ?F?.
typ : str or int {?I?,?II?,?III?} or {1,2,3}
The type of ANOVA test to perform. See notes.
robust : {None, ?hc0?, ?hc1?, ?hc2?, ?hc3?}
Use heteroscedasticity-corrected coefficient covariance matrix. If robust covariance is desired, it is recommended to use
hc3
.Returns: anova : DataFrame
A DataFrame containing. :
See also
model_results.compare_f_test
,model_results.compare_lm_test
Notes
Model statistics are given in the order of args. Models must have been fit using the formula api.
Examples
12>>>
import
statsmodels.api as sm
>>>
from
statsmodels.formula.api
import
ols
1234567>>> moore
=
sm.datasets.get_rdataset(
"Moore"
,
"car"
,
... cache
=
True
)
# load data
>>> data
=
moore.data
>>> data
=
data.rename(columns
=
{
"partner.status"
:
...
"partner_status"
})
# make name pythonic
>>> moore_lm
=
ols(
'conformity ~ C(fcategory, Sum)*C(partner_status, Sum)'
,
... data
=
data).fit()
12>>> table
=
sm.stats.anova_lm(moore_lm, typ
=
2
)
# Type 2 ANOVA DataFrame
>>>
print
table
Please login to continue.