deff()
function in the Hmisc
package.R/get_icc.R
get_icc.Rd
Function to calculate the intracluster correlation coefficient of an
indicator collected from random cluster survey (RCS). This is a wrapper of
the deff()
function in the Hmisc
package.
get_icc(x, cluster)
x | variable to calculate ICC from |
---|---|
cluster | variable identifying the clusters or groupings of the variable |
A vector with named elements n (total number of non-missing observations),
clusters
(number of clusters after deleting missing data),
rho
(intra-cluster correlation), and deff
(design effect).
x <- sample(1:2, size = 25, replace = TRUE) cluster <- c(rep(1, 5), rep(2, 5), rep(3, 5), rep(4, 5), rep(5, 5)) get_icc(x = x, cluster = cluster)#> n clusters rho deff #> 25.0000000 5.0000000 -0.1217949 0.5128205