Repeated-measures correlation estimates the common within-subject
linear association between two variables measured repeatedly on the same
subjects. It differs from agreement methods such as Lin's CCC or
Bland-Altman analysis because those target concordance or interchangeability,
whereas repeated-measures correlation targets the strength of the
subject-centred association.
For subject \(i = 1,\ldots,S\) and repeated observations
\(j = 1,\ldots,n_i\), let \(x_{ij}\) and \(y_{ij}\) denote the two
responses. Define subject-specific means
$$\bar x_i = \frac{1}{n_i}\sum_{j=1}^{n_i} x_{ij}, \qquad
\bar y_i = \frac{1}{n_i}\sum_{j=1}^{n_i} y_{ij}.$$
The repeated-measures correlation uses within-subject centred values
$$x^\ast_{ij} = x_{ij} - \bar x_i, \qquad
y^\ast_{ij} = y_{ij} - \bar y_i$$
and computes
$$r_{\mathrm{rm}} =
\frac{\sum_i \sum_j x^\ast_{ij} y^\ast_{ij}}
{\sqrt{\left(\sum_i \sum_j {x^\ast_{ij}}^2\right)
\left(\sum_i \sum_j {y^\ast_{ij}}^2\right)}}.$$
Equivalently, this is the correlation implied by an ANCOVA model with a
common slope and subject-specific intercepts:
$$y_{ij} = \alpha_i + \beta x_{ij} + \varepsilon_{ij}.$$
The returned slope is
$$\hat\beta =
\frac{\sum_i \sum_j x^\ast_{ij} y^\ast_{ij}}
{\sum_i \sum_j {x^\ast_{ij}}^2},$$
and the subject-specific fitted intercepts are
\(\hat\alpha_i = \bar y_i - \hat\beta \bar x_i\). Residual degrees of
freedom are \(N - S - 1\), where \(N = \sum_i n_i\) after filtering to
complete observations and retaining only subjects with at least two repeated
pairs.
Confidence intervals are computed with a Fisher \(z\)-transformation of
\(r_{\mathrm{rm}}\) and then back-transformed to the correlation scale. In
matrix mode, the same estimator is applied to every pair of selected
response columns.
With estimator = "weighted", the package implements the weighted
repeated-measures estimator from Kondo et al. (2025) using complete observed
\((x,y)\) pairs per contrast. This estimator does not impute missing data;
it uses per-subject complete-pair sets and weighted sums of explained and
residual quantities from the fixed-subject ANCOVA decomposition.
Bootstrap confidence intervals use non-parametric subject-level resampling
(subjects are resampled as blocks, not rows).