| icc_rm_reml | R Documentation |
Computes pairwise repeated-measures intraclass correlation coefficients from long-format data using the same REML and Woodbury-identity backend used by the repeated-measures agreement models.
icc_rm_reml(
data,
response,
subject,
method = NULL,
time = NULL,
type = c("consistency", "agreement"),
ci = FALSE,
conf_level = 0.95,
n_threads = getOption("matrixCorr.threads", 1L),
ci_mode = c("auto", "raw", "logit"),
verbose = FALSE,
digits = 4,
use_message = TRUE,
interaction = FALSE,
max_iter = 100,
tol = 1e-06,
Dmat = NULL,
Dmat_type = c("time-avg", "typical-visit", "weighted-avg", "weighted-sq"),
Dmat_weights = NULL,
Dmat_rescale = TRUE,
ar = c("none", "ar1"),
ar_rho = NA_real_,
slope = c("none", "subject", "method", "custom"),
slope_var = NULL,
slope_Z = NULL,
drop_zero_cols = TRUE,
vc_select = c("auto", "none"),
vc_alpha = 0.05,
vc_test_order = c("subj_time", "subj_method"),
include_subj_method = NULL,
include_subj_time = NULL,
sb_zero_tol = 1e-10
)
## S3 method for class 'icc_rm_reml'
print(
x,
digits = 4,
ci_digits = 4,
n = NULL,
topn = NULL,
max_vars = NULL,
width = NULL,
show_ci = NULL,
...
)
## S3 method for class 'icc_rm_reml'
summary(
object,
digits = 4,
ci_digits = 2,
n = NULL,
topn = NULL,
max_vars = NULL,
width = NULL,
show_ci = NULL,
...
)
## S3 method for class 'summary.icc_rm_reml'
print(
x,
digits = NULL,
n = NULL,
topn = NULL,
max_vars = NULL,
width = NULL,
show_ci = NULL,
...
)
data |
A data frame. |
response |
Character. Response variable name. |
subject |
Character. Subject ID variable name. |
method |
Character or |
time |
Character or |
type |
Character scalar; one of |
ci |
Logical. If |
conf_level |
Numeric in |
n_threads |
Integer |
ci_mode |
Character scalar; one of |
verbose |
Logical. If |
digits |
Integer |
use_message |
Logical. When |
interaction |
Logical. Include |
max_iter |
Integer. Maximum iterations for variance-component updates
(default |
tol |
Numeric. Convergence tolerance on parameter change
(default |
Dmat |
Optional |
Dmat_type |
Character, one of
Pick |
Dmat_weights |
Optional numeric weights |
Dmat_rescale |
Logical. When |
ar |
Character. Residual correlation structure: |
ar_rho |
Numeric in |
slope |
Character. Optional extra random-effect design |
slope_var |
For |
slope_Z |
For |
drop_zero_cols |
Logical. When |
vc_select |
Character scalar; one of |
vc_alpha |
Numeric scalar in |
vc_test_order |
Character vector (length 2) with a permutation of
|
include_subj_method, include_subj_time |
Logical scalars or |
sb_zero_tol |
Non-negative numeric scalar; default |
x |
For |
ci_digits |
Integer; number of digits for confidence interval bounds in printed method summaries. |
n |
Optional row threshold for compact preview output. |
topn |
Optional number of leading/trailing rows to show when truncated. |
max_vars |
Optional maximum number of visible columns; |
width |
Optional display width; defaults to |
show_ci |
One of |
... |
Passed to the underlying display helpers. |
object |
For |
The repeated-measures model is fit separately for each method pair using the same REML and Woodbury-identity backend used by the repeated-measures concordance estimator.
Kernel D_m and the fixed-bias term S_B.
Let d = L^\top \hat\beta stack the within-time, pairwise method
differences, grouped by time. The symmetric positive semidefinite kernel
D_m \succeq 0 selects which functional of the bias profile is targeted
by S_B. Internally, the code rescales any supplied or constructed
D_m to satisfy 1^\top D_m 1 = n_t for stability and comparability.
Dmat_type = "time-avg" targets the square of the
time-averaged bias.
Dmat_type = "typical-visit" targets the average of squared
per-time biases.
Dmat_type = "weighted-avg" targets the square of a weighted
time average.
Dmat_type = "weighted-sq" targets the weighted average of
squared per-time biases.
As in the repeated-measures concordance implementation, S_B is the
fitted fixed-effect dispersion term induced by D_m. It enters the
denominator only for type = "agreement".
Time-averaging and shrinkage factors.
The fitted variance components reported in the summary are
\sigma_S^2, \sigma_{S\times M}^2, \sigma_{S\times T}^2,
and \sigma_E^2, stored respectively as sigma2_subject,
sigma2_subject_method, sigma2_subject_time, and sigma2_error.
The repeated-measures ICC always uses \sigma_S^2 in the numerator only.
The denominator uses the same time-averaging logic already used by the
repeated-measures concordance backend, through two pair-specific factors
\bar{\kappa}_g and \bar{\kappa}_e.
If time is absent, the implementation sets
\bar{\kappa}_g = 0, \qquad \bar{\kappa}_e = 1.
If time is present and the target is a single visit
(Dmat_type %in% c("typical-visit", "weighted-sq")), the implementation
leaves the time-varying terms unshrunk:
\bar{\kappa}_g = 1, \qquad \bar{\kappa}_e = 1.
If time is present and the target is time-averaged
(Dmat_type %in% c("time-avg", "weighted-avg")), then for each observed
subject-method unit with T distinct observed visits:
with equal weights,
\kappa_g = \frac{1}{T}, \qquad
\kappa_e = \frac{T + 2\sum_{h=1}^{T-1}(T-h)\rho^h}{T^2},
with \kappa_e=\kappa_g when residuals are iid;
with normalized visit weights w_1,\ldots,w_T,
\kappa_g = \sum_{t=1}^{T} w_t^2, \qquad
\kappa_e = \sum_{t=1}^{T}\sum_{s=1}^{T} w_t w_s \rho^{|t-s|},
with \kappa_e=\kappa_g when residuals are iid.
With unbalanced T, the implementation averages the per-unit
\kappa values across the observations contributing to the pair and then
clamps both \bar{\kappa}_g and \bar{\kappa}_e to
[10^{-12},\,1] for numerical stability.
Repeated-measures ICC.
Let \sigma_{S\times M,\mathrm{eff}}^2 denote the effective
subject-by-method variance term, equal to \sigma_{S\times M}^2 when
the subject-by-method random effect is included and 0 otherwise. Let
\sigma_{S\times T,\mathrm{eff}}^2 denote the effective subject-by-time
variance term, equal to \sigma_{S\times T}^2 when the subject-by-time
random effect is included and 0 otherwise.
For type = "consistency", the reported ICC is
\mathrm{ICC}_{\mathrm{consistency}} \;=\;
\frac{\sigma_S^2}{
\sigma_S^2 + \sigma_{S\times M,\mathrm{eff}}^2 +
\bar{\kappa}_g\,\sigma_{S\times T,\mathrm{eff}}^2 +
\bar{\kappa}_e\,\sigma_E^2}.
For type = "agreement", the denominator additionally includes S_B:
\mathrm{ICC}_{\mathrm{agreement}} \;=\;
\frac{\sigma_S^2}{
\sigma_S^2 + \sigma_{S\times M,\mathrm{eff}}^2 +
\bar{\kappa}_g\,\sigma_{S\times T,\mathrm{eff}}^2 +
\bar{\kappa}_e\,\sigma_E^2 + S_B}.
This differs from repeated-measures concordance because ICC uses only
\sigma_S^2 in the numerator, whereas the concordance numerator also
includes the time-averaged subject-time term. Extra random-effect variances
\{\sigma_{Z,j}^2\} from slope / slope_Z are estimated by the shared
backend but are not included in the ICC denominator.
CIs / SEs (delta method for ICC).
Confidence intervals are built from the same REML fit by a large-sample delta
method. If ci_mode = "raw", a Wald interval is formed on the ICC scale,
\widehat{\mathrm{ICC}} \;\pm\; z_{1-\alpha/2}\,
\widehat{\mathrm{se}}\{\widehat{\mathrm{ICC}}\},
and truncated to [0,1]. If ci_mode = "logit", the same Wald
construction is applied on the logit scale and then back-transformed. If
ci_mode = "auto", the backend selects between the raw-scale and logit-scale
interval per estimate.
Choosing \rho for AR(1).
When ar="ar1" and ar_rho = NA, \rho is estimated by
profiling the REML log-likelihood at (\hat\beta,\hat G,\hat\sigma_E^2).
With very few visits per subject, \rho can be weakly identified; consider
sensitivity checks over a plausible range.
A repeated-measures pairwise ICC object. Without confidence intervals the
result is a symmetric matrix of class c("icc_rm_reml", "icc", "matrix").
With confidence intervals it is a list with est, lwr.ci, and upr.ci
and class c("icc_rm_reml", "icc_ci", "icc"). Both carry the fitted
variance-component matrices as attributes.
All per-subject solves are r\times r with
r = 1 + n_m + n_t + q_Z, so cost scales with the number of subjects and
the fixed-effects dimension rather than the total number of observations.
Solvers use symmetric positive-definite paths with a small diagonal ridge and
pseudo-inverse fallback, which helps for very small or unbalanced subsets and
near-boundary estimates. For AR(1), observations are ordered by time
within subject; NA time codes break the run, and gaps between factor
levels are treated as regular steps.
Heteroscedastic slopes across Z columns are supported. Each Z
column has its own variance component \sigma_{Z,j}^2, but
cross-covariances among Z columns are set to zero.
The C++ backend uses OpenMP loops while also forcing vendor BLAS libraries to
run single-threaded so that overall CPU usage stays predictable. On OpenBLAS
and Apple's Accelerate this is handled automatically. On Intel MKL builds the
guard is disabled by default, but you can also opt out manually by setting
MATRIXCORR_DISABLE_BLAS_GUARD=1 in the environment before loading the
package.
Shrout PE, Fleiss JL (1979). Intraclass correlations: uses in assessing rater reliability. Psychological Bulletin, 86(2), 420-428.
McGraw KO, Wong SP (1996). Forming inferences about some intraclass correlation coefficients. Psychological Methods, 1(1), 30-46.
icc(), ccc(), ccc_rm_reml(), ba(), ba_rm(), rmcorr()
set.seed(321)
n_id <- 20
n_time <- 3
id <- factor(rep(seq_len(n_id), each = 2 * n_time))
method <- factor(rep(rep(c("A", "B"), each = n_time), times = n_id))
time <- factor(rep(seq_len(n_time), times = 2 * n_id))
subj <- rnorm(n_id, sd = 1)[as.integer(id)]
subj_method <- rnorm(n_id * 2, sd = 0.25)
sm <- subj_method[(as.integer(id) - 1L) * 2L + as.integer(method)]
y <- subj + sm + 0.3 * (method == "B") + rnorm(length(id), sd = 0.35)
dat_rm <- data.frame(y = y, id = id, method = method, time = time)
fit_icc_rm <- icc_rm_reml(
dat_rm,
response = "y",
subject = "id",
method = "method",
time = "time",
type = "consistency"
)
print(fit_icc_rm)
summary(fit_icc_rm)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.