pingouin.ancova

pingouin.ancova(dv=None, covar=None, between=None, data=None, export_filename=None, return_bw=False)[source]

ANCOVA with one or more covariate(s).

Parameters
dvstring

Name of column containing the dependant variable.

covarstring or list

Name(s) of column(s) containing the covariate.

betweenstring

Name of column containing the between factor.

datapandas DataFrame

DataFrame

export_filenamestring

Filename (without extension) for the output file. If None, do not export the table. By default, the file will be created in the current python console directory. To change that, specify the filename with full path.

return_bwbool

If True, return beta within parameter (used for the rm_corr function)

Returns
aovDataFrame

ANCOVA summary

'Source' : Names of the factor considered
'SS' : Sums of squares
'DF' : Degrees of freedom
'F' : F-values
'p-unc' : Uncorrected p-values

See also

anova

One-way and two-way ANOVA

Notes

Analysis of covariance (ANCOVA) is a general linear model which blends ANOVA and regression. ANCOVA evaluates whether the means of a dependent variable (dv) are equal across levels of a categorical independent variable (between) often called a treatment, while statistically controlling for the effects of other continuous variables that are not of primary interest, known as covariates or nuisance variables (covar).

Note that in the case of one covariate, Pingouin will use a built-in function. However, if there are more than one covariate, Pingouin will use the statsmodels package to compute the ANCOVA.

Rows with missing values are automatically removed (listwise deletion).

Examples

1. Evaluate the reading scores of students with different teaching method and family income as a covariate.

>>> from pingouin import ancova, read_dataset
>>> df = read_dataset('ancova')
>>> ancova(data=df, dv='Scores', covar='Income', between='Method')
     Source           SS  DF          F     p-unc
0    Method   571.030045   3   3.336482  0.031940
1    Income  1678.352687   1  29.419438  0.000006
2  Residual  1768.522365  31        NaN       NaN

2. Evaluate the reading scores of students with different teaching method and family income + BMI as a covariate.

>>> ancova(data=df, dv='Scores', covar=['Income', 'BMI'], between='Method')
     Source        SS  DF       F     p-unc
0    Method   552.284   3   3.233  0.036113
1    Income  1573.952   1  27.637  0.000011
2       BMI    60.014   1   1.054  0.312842
3  Residual  1708.509  30     NaN       NaN