Performing analysis of covariance with python/scip

2019-05-16 16:59发布

问题:

Could anyone please help in providing an example showing how ANCOVA (analysis of covariance) can be done in scipy/statsmodel, with python?

I am not sure if I am asking too much, but a quick search showed me this which is not informative enough for me.

Thanks!

回答1:

Statsmodels uses the linear model, OLS, to estimate ANOVA. So, having additional continuous regressors as in ANCOVA does not change the analysis.

Here are a few links to the relevant documentation

Anova helper functions and examples for ANCOVA interactions http://statsmodels.sourceforge.net/devel/examples/generated/example_interactions.html

using formulas to create the design matrix http://statsmodels.sourceforge.net/devel/example_formulas.html

the core OLS model http://statsmodels.sourceforge.net/devel/generated/statsmodels.regression.linear_model.OLS.html