Type: Package
Title: Rank Intraclass Correlation for Clustered Data
Version: 1.0.2
Date: 2023-11-03
Description: Estimates the rank intraclass correlation coefficient (ICC) for clustered continuous and ordinal data. See Tu et al. (2023) <doi:10.1002/sim.9864> for details.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
Encoding: UTF-8
Collate: 'rankICC.R' 'rankICC3levels.R'
RoxygenNote: 7.2.3
NeedsCompilation: no
Packaged: 2023-11-04 22:15:30 UTC; shengxintu
Author: Shengxin Tu [aut, cre], Chun Li [aut], Donglin Zeng [aut], Bryan Shepherd [aut]
Maintainer: Shengxin Tu <shengxin.tu@vanderbilt.edu>
Repository: CRAN
Date/Publication: 2023-11-14 09:43:19 UTC

Rank ICC with two hierarchies

Description

rankICC computes the rank intraclass correlation coefficient (ICC) of a two-level hierarchical distribution. It can be used with any orderable variable, including continuous and discrete variables. Different weighting methods are provided, including methods assigning equal weights to observations or to clusters.

Usage

rankICC(
  x,
  cluster,
  weights = c("obs", "clusters", "ess", "combination"),
  conf.int = 0.95,
  fisher = FALSE,
  na.rm = FALSE,
  ...
)

Arguments

x

a numeric or factor vector.

cluster

a vector of cluster index corresponding to x.

weights

a character string indicating which weighting method is used. Or an optional vector of user-defined weights to be used. Should be one of the strings "obs", "clusters", "ess", "combination", or a numeric vector. Default is "obs". See Details.

conf.int

numeric specifying confidence interval level.

fisher

logical, indicating whether to apply Fisher transformation to compute confidence intervals.

na.rm

logical. Should missing values be removed?

...

additional arguments to be passed to the iteration function if weights is "ess" or "combination". Specifying the tolerance via "tol" and the maximum iteration times via "maxIter".

Details

"obs" assigns equal weights to observations; p_{ij} = 1/N, where N is the total number of observations. "clusters" assigns equal weights to clusters; p_{ij} = 1/(nk_i), where n is the total number of clusters and k_i is the cluster size. "ess" and "combination" implement iterations until convergence; p_{ij}(\gamma_I)=1/(1+k_i\gamma_I)/\{\sum_{j=1}^n k_j/(1+k_j\gamma_I)\} for "ess", p_{ij}(\gamma_I)=(1-\gamma_I)/N+\gamma_I/(nk_i) for "combination".

Value

a vector with following components.

rankICC the rank ICC.
SE the standard error.
Lower, Upper the lower and upper bound of the confidence interval.

References

Tu, S., Li, C., Zeng, D., and Shepherd, B. E. (2023). Rank intraclass correlation for clustered data. Statistics in Medicine 42, 4333-4348.

Examples

k <- 50; m <- 5
sigma.u <- 1; sigma.e <- 2
u <- rnorm(k, 5, sigma.u)
x1 <- matrix(NA, k, m)
for (i in 1:k){
x1[i,] <- u[i] + rnorm(5, 0, sigma.e)
}
x <- as.vector(t(x1))
cluster <- rep(1:k, each=5)
rankICC(x, cluster, weights = "clusters")
rankICC(x, cluster, weights = "ess", tol = 1e-4, maxIter = 10)

Rank ICC with three hierarchies

Description

rankICC3levels computes the rank intraclass correlation coefficient (ICC) with three hierarchies. Starting from the innermost level, the three levels are named level 1, level 2, and level 3. The rank ICC at level 2 evaluates the rank correlation between a random pair from the same level-2 unit. The rank ICC at level 3 evaluates the rank correlation between a random pair from the same level-3 unit but different level-2 units.

Usage

rankICC3levels(
  x,
  level2,
  level3,
  weights = c("level1", "level2", "level3"),
  conf.int = 0.95,
  fisher = FALSE,
  na.rm = FALSE
)

Arguments

x

a numeric or factor vector.

level2

a vector indicating level-2 membership.

level3

a vector indicating level-3 membership.

weights

a character string indicating which weighting method is used. Or an optional vector of user-defined weights to be used. Should be one of the strings "level1", "level2", "level3", or a numeric vector. Default is "level1". See Details.

conf.int

numeric specifying confidence interval level.

fisher

logical, indicating whether to apply Fisher transformation to compute confidence intervals.

na.rm

logical. Should missing values be removed?

Details

"level1" assigns equal weights to level-1 units; p_{ijk}=1/(\sum_{i=1}^n\sum_{j=1}^{n_i}m_{ij}), where n is the total number of level-3 units, n_i is the number of level-2 units in the ith level-3 unit, and m_{ij} is the number of level-1 units in the jth level-2 unit and the ith level-3 unit. "level2" assigns equal weights to level-2 units; p_{ijk}=1/(m_{ij}\sum_{i=1}^n n_{i}). "level3" assigns equal weights to level-3 units; p_{ijk}=1/(nn_{i}m_{ij}).

Value

a matrix with two rows. The first row is for rank ICC at level 2 and the second row is for rank ICC at level 3. Each row has the following components.

rankICC the rank ICC.
SE the standard error.
Lower, Upper the lower and upper bound of the confidence interval.

References

Tu, S., Li, C., Zeng, D., and Shepherd, B. E. (2023). Rank intraclass correlation for clustered data. Statistics in Medicine 42, 4333-4348.

Examples

k <- 50; m <- 5
sigma.u <- 1; sigma.e <- 2
u <- rnorm(k, 5, sigma.u)
x1 <- matrix(NA, k, m)
for (i in 1:k){
x1[i,] <- u[i] + rnorm(5, 0, sigma.e)
}
x <- as.vector(t(x1))
level2 <- rep(1:k, each=5)
level3 <- round(level2 / 10)
rankICC3levels(x, level2, level3, weights = "level2")