pingouin.rm_corr

pingouin.
rm_corr
(data=None, x=None, y=None, subject=None, tail='twosided')[source] Repeated measures correlation.
 Parameters
 datapd.DataFrame
Dataframe.
 x, ystring
Name of columns in
data
containing the two dependent variables. subjectstring
Name of column in
data
containing the subject indicator. tailstring
Specify whether to return ‘onesided’ or ‘twosided’ pvalue.
 Returns
 statspandas DataFrame
Test summary
'r' : Repeated measures correlation coefficient 'dof' : Degrees of freedom 'pval' : one or two tailed pvalue 'CI95' : 95% parametric confidence intervals 'power' : achieved power of the test (= 1  type II error).
See also
Notes
Repeated measures correlation (rmcorr) is a statistical technique for determining the common withinindividual association for paired measures assessed on two or more occasions for multiple individuals.
From Bakdash and Marusich (2017):
“Rmcorr accounts for nonindependence among observations using analysis of covariance (ANCOVA) to statistically adjust for interindividual variability. By removing measured variance betweenparticipants, rmcorr provides the best linear fit for each participant using parallel regression lines (the same slope) with varying intercepts. Like a Pearson correlation coefficient, the rmcorr coefficient is bounded by − 1 to 1 and represents the strength of the linear association between two variables.”
Results have been tested against the rmcorr R package.
Please note that NaN are automatically removed from the dataframe (listwise deletion).
References
 1
Bakdash, J.Z., Marusich, L.R., 2017. Repeated Measures Correlation. Front. Psychol. 8, 456. https://doi.org/10.3389/fpsyg.2017.00456
 2
Bland, J. M., & Altman, D. G. (1995). Statistics notes: Calculating correlation coefficients with repeated observations: Part 1—correlation within subjects. Bmj, 310(6977), 446.
 3
Examples
>>> import pingouin as pg >>> df = pg.read_dataset('rm_corr') >>> pg.rm_corr(data=df, x='pH', y='PacO2', subject='Subject') r dof pval CI95% power rm_corr 0.50677 38 0.000847 [0.71, 0.23] 0.929579
Now plot using the
pingouin.plot_rm_corr()
function:>>> import pingouin as pg >>> df = pg.read_dataset('rm_corr') >>> g = pg.plot_rm_corr(data=df, x='pH', y='PacO2', subject='Subject')