*! version 1.1.0 24Sep2021

*! version 1.0.0 12Jul2021

Title

rmcorr -- Correlation for data with repeated measures

Syntax

rmcorr
yvar
xvar
[if] [in]
,
id(varname)
[ level(#)
figure[(twoway_options) ]

yvar is the dependent variable and xvar is the independent variable

id(varname) subject identifier; required

level(#) set confidence level; default is level(95)

figure[(twoway_options)] produce a scatterplot of the dvar vs xvar combined with a linear fit for each subject with at least two observations

by is allowed with rmcorr; see [D] by.

Description

rmcorr computes a correlation coefficient for data in which subjects have repeated measures (i.e. multiple observations), as proposed by Bland and Altman (1995).
Additionally, confidence intervals are calculated by using Fisher's z transform (Gleason 1996).
When the figure option is specified, a graph is generated that includes a scatterplot of each subject's observations and a linear fit through those points (only
for subjects with at least two observations).
This graph assists the user in visualizing the variation amongst subjects.

Options

id(varname) specifies the subjects' identifier; id() is required

level(#) specifies the confidence level, as a percentage, for
confidence intervals. The default is level(95) or whatever is set by
set level.

figure[(twoway_options)] produces a scatterplot of the dvar vs xvar
combined with a linear fit for each subject's data (only for those subjects with at least two observations).
Specifying figure without options uses the default graph settings.

Examples

Setup

. use bland1995.dta

Basic specification

. rmcorr ph paco2, i(subject)

Add figure

. rmcorr ph paco2, i(subject) fig

Adjust the Y-axis scale on the figure

. rmcorr ph paco2, i(subject) fig(ylabel(6(.5)7.5))

Specify 99% confidence limits

. rmcorr ph paco2, i(subject) level(99)

Stored results

rmcorr stores the following in r():

Scalars

r(obs) number of observations in estimation sample

r(rho) correlation coefficient

r(lb) lower confidence limit

r(ub) upper confidence limit

r(pval) P-value

In addition to the above, the following is stored in r():

Matrices

r(table) matrix containing the coefficient, confidence intervals, p-value, and number of observations

References

Bland, J. M. and D. G. Altman. 1995. Calculating correlation coefficients with repeated observations: part 1—correlation within subjects. BMJ 310: 446.

Gleason, J. R. 1996. Inference about correlations using the Fisher z-transform. Stata Technical Bulletin 32: 13-18.

Citation of rmcorr

rmcorr is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden A. (2021). RMCORR: Stata module to compute a correlation for data with repeated measures. https://ideas.repec.org/c/boc/bocode/s458971.html

Authors

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

Also see

Online: anova, corr