scipystatsmodels

Performing analysis of covariance with python/scipy/statsmodel


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!


Solution

  • 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