rankICC3levels {rankICC} | R Documentation |
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 |
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 i
th level-3 unit, and m_{ij}
is the number of level-1 units in the j
th level-2 unit and the i
th 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")