pingouin.pairwise_ttests

pingouin.
pairwise_ttests
(dv=None, between=None, within=None, subject=None, data=None, parametric=True, alpha=0.05, tail='twosided', padjust='none', effsize='hedges', return_desc=False, export_filename=None)[source] Pairwise Ttests.
 Parameters
 dvstring
Name of column containing the dependant variable.
 betweenstring or list with 2 elements
Name of column(s) containing the between factor(s).
 withinstring or list with 2 elements
Name of column(s) containing the within factor(s).
 subjectstring
Name of column containing the subject identifier. Compulsory for contrast including a withinsubject factor.
 datapandas DataFrame
DataFrame. Note that this function can also directly be used as a Pandas method, in which case this argument is no longer needed.
 parametricboolean
If True (default), use the parametric
ttest()
function. If False, usepingouin.wilcoxon()
orpingouin.mwu()
for paired or unpaired samples, respectively. alphafloat
Significance level
 tailstring
Indicates whether to return the ‘twosided’ or ‘onesided’ pvalues
 padjuststring
Method used for testing and adjustment of pvalues. Available methods are
'none' : no correction 'bonferroni' : onestep Bonferroni correction 'holm' : stepdown method using Bonferroni adjustments 'fdr_bh' : Benjamini/Hochberg FDR correction 'fdr_by' : Benjamini/Yekutieli FDR correction
 effsizestring or None
Effect size type. Available methods are
'none' : no effect size 'cohen' : Unbiased Cohen d 'hedges' : Hedges g 'glass': Glass delta 'etasquare' : Etasquare 'oddsratio' : Odds ratio 'AUC' : Area Under the Curve
 return_descboolean
If True, append group means and std to the output 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.
 Returns
 statsDataFrame
Stats summary
'A' : Name of first measurement 'B' : Name of second measurement 'Paired' : indicates whether the two measurements are paired or not 'Parametric' : indicates if (non)parametric tests were used 'Tail' : indicate whether the pvalues are onesided or twosided 'T' : Tvalues (only if parametric=True) 'U' : MannWhitney U value (only if parametric=False and unpaired data) 'W' : Wilcoxon W value (only if parametric=False and paired data) 'dof' : degrees of freedom (only if parametric=True) 'punc' : Uncorrected pvalues 'pcorr' : Corrected pvalues 'padjust' : pvalues correction method 'BF10' : Bayes Factor 'hedges' : Hedges effect size 'CLES' : Common language effect size
See also
Notes
Data are expected to be in longformat. If your data is in wideformat, you can use the
pandas.melt()
function to convert from wide to long format.If
between
orwithin
is a list (e.g. [‘col1’, ‘col2’]), the function returns 1) the pairwise Ttests between each values of the first column, 2) the pairwise Ttests 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
andwithin
are specified, the function return within + between + within * between.Missing values in repeated measurements are automatically removed using the
pingouin.remove_rm_na()
function. However, you should be very careful since it can result in undesired values removal (especially for the interaction effect). We strongly recommend that you preprocess your data and remove the missing values before using this function.This function has been tested against the pairwise.t.test R function.
Examples
One betweenfactor
>>> from pingouin import pairwise_ttests, read_dataset >>> df = read_dataset('mixed_anova.csv') >>> post_hocs = pairwise_ttests(dv='Scores', between='Group', data=df)
One withinfactor
>>> post_hocs = pairwise_ttests(dv='Scores', within='Time', ... subject='Subject', data=df) >>> print(post_hocs) # doctest: +SKIP
Nonparametric pairwise paired test (wilcoxon)
>>> pairwise_ttests(dv='Scores', within='Time', subject='Subject', ... data=df, parametric=False) # doctest: +SKIP
Within + Between + Within * Between with corrected pvalues
>>> posthocs = pairwise_ttests(dv='Scores', within='Time', ... subject='Subject', between='Group', ... padjust='bonf', data=df)
Between1 + Between2 + Between1 * Between2
>>> posthocs = pairwise_ttests(dv='Scores', between=['Group', 'Time'], ... data=df)