Generate variance for random effects that produce desired intra-class coefficients (ICCs) for clustered data.

iccRE(ICC, dist, varTotal = NULL, varWithin = NULL, lambda = NULL, disp = NULL)

Arguments

ICC

Vector of values between 0 and 1 that represent the target ICC levels

dist

The distribution that describes the outcome data at the individual level. Possible distributions include "normal", "binary", "poisson", or "gamma"

varTotal

Numeric value that represents the total variation for a normally distributed model. If "normal" distribution is specified, either varTotal or varWithin must be specified, but not both.

varWithin

Numeric value that represents the variation within a cluster for a normally distributed model. If "normal" distribution is specified, either varTotal or varWithin must be specified, but not both.

lambda

Numeric value that represents the grand mean. Must be specified when distribution is "poisson" or "negative binomial".

disp

Numeric value that represents the dispersion parameter that is used to define a gamma or negative binomial distribution with a log link. Must be specified when distribution is "gamma".

Value

A vector of values that represents the variances of random effects at the cluster level that correspond to the ICC vector.

Examples

targetICC <- seq(0.05, 0.20, by = .01) iccRE(targetICC, "poisson", lambda = 30)
#> [1] 0.0017513 0.0021231 0.0025026 0.0028901 0.0032858 0.0036900 0.0041029 #> [8] 0.0045249 0.0049562 0.0053971 0.0058480 0.0063092 0.0067811 0.0072640 #> [15] 0.0077584 0.0082647
iccRE(targetICC, "binary")
#> [1] 0.1731510 0.2099916 0.2476245 0.2860755 0.3253716 0.3655409 0.4066129 #> [8] 0.4486184 0.4915895 0.5355599 0.5805650 0.6266415 0.6738284 0.7221662 #> [15] 0.7716975 0.8224670
iccRE(targetICC, "normal", varTotal = 100)
#> [1] 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
iccRE(targetICC, "normal", varWithin = 100)
#> [1] 5.263158 6.382979 7.526882 8.695652 9.890110 11.111111 12.359551 #> [8] 13.636364 14.942529 16.279070 17.647059 19.047619 20.481928 21.951220 #> [15] 23.456790 25.000000
iccRE(targetICC, "gamma", disp = .5)
#> [1] 0.03394390 0.04116600 0.04854342 0.05608122 0.06378469 0.07165934 #> [7] 0.07971095 0.08794555 0.09636946 0.10498927 0.11381189 0.12284458 #> [13] 0.13209493 0.14157089 0.15128083 0.16123352
iccRE(targetICC, "negBinomial", lambda = 40, disp = .5)
#> [1] 0.03609454 0.04377423 0.05161908 0.05963446 0.06782601 0.07619959 #> [7] 0.08476134 0.09351768 0.10247531 0.11164126 0.12102288 0.13062787 #> [13] 0.14046431 0.15054066 0.16086581 0.17144908