pingouin.pairwise_ttests

pingouin.pairwise_ttests(dv=None, between=None, within=None, subject=None, data=None, alpha=0.05, tail='two-sided', padjust='none', effsize='hedges', return_desc=False, export_filename=None)[source]

Pairwise T-tests.

Parameters:
dv : string

Name of column containing the dependant variable.

between : string or list with 2 elements

Name of column(s) containing the between factor(s).

within : string or list with 2 elements

Name of column(s) containing the within factor(s).

subject : string

Name of column containing the subject identifier. Compulsory for contrast including a within-subject factor.

data : pandas DataFrame

DataFrame

alpha : float

Significance level

tail : string

Indicates whether to return the ‘two-sided’ or ‘one-sided’ p-values

padjust : string

Method used for testing and adjustment of pvalues. Available methods are

'none' : no correction
'bonferroni' : one-step Bonferroni correction
'holm' : step-down method using Bonferroni adjustments
'fdr_bh' : Benjamini/Hochberg FDR correction
'fdr_by' : Benjamini/Yekutieli FDR correction
effsize : string or None

Effect size type. Available methods are

'none' : no effect size
'cohen' : Unbiased Cohen d
'hedges' : Hedges g
'glass': Glass delta
'eta-square' : Eta-square
'odds-ratio' : Odds ratio
'AUC' : Area Under the Curve
return_desc : boolean

If True, append group means and std to the output dataframe

export_filename : string

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.

Returns:
stats : DataFrame

Stats summary

'A' : Name of first measurement
'B' : Name of second measurement
'Paired' : indicates whether the two measurements are paired or not
'Tail' : indicate whether the p-values are one-sided or two-sided
'T' : T-values
'p-unc' : Uncorrected p-values
'p-corr' : Corrected p-values
'p-adjust' : p-values correction method
'BF10' : Bayes Factor
'efsize' : effect sizes
'eftype' : type of effect size

Notes

If between or within is a list (e.g. [‘col1’, ‘col2’]), the function returns 1) the pairwise T-tests between each values of the first column, 2) the pairwise T-tests between each values of the second column and 3) the interaction between col1 and col2. The interaction is dependent of the order of the list, so [‘col1’, ‘col2’] will not yield the same results as [‘col2’, ‘col1’].

In other words, if between is a list with two elements, the output model is between1 + between2 + between1 * between2.

Similarly, if within is a list with two elements, the output model is within1 + within2 + within1 * within2.

If both between and within are specified, the function return within + between + within * between.

Examples

  1. One between-factor

    >>> from pingouin import pairwise_ttests
    >>> from pingouin.datasets import read_dataset
    >>> df = read_dataset('mixed_anova.csv')
    >>> post_hocs = pairwise_ttests(dv='Scores', between='Group', data=df)
    >>> print(post_hocs)
    
  2. One within-factor

    >>> post_hocs = pairwise_ttests(dv='Scores', within='Time',
    >>>                             subject='Subject', data=df)
    >>> print(post_hocs)
    
  3. Within + Between + Within * Between with corrected p-values

    >>> post_hocs = pairwise_ttests(dv='Scores', within='Time',
    >>>                             subject='Subject', between='Group',
    >>>                             padjust='bonf', data=df)
    >>> print(post_hocs)
    
  1. Between1 + Between2 + Between1 * Between2

    >>> pairwise_ttests(dv='Scores', between=['Group', 'Time'], data=df)