Learn R Programming

qra (version 0.2.7)

getRho: Extract estimates of the intra-class correlation from a glmmTMB model object with beta-binomial error.

Description

The intra-class correlation is calculated as \((1+exp(\theta))^{-1}\), where \(\theta\) is the estimate given by the formula specified in the argument dispformula.

Usage

getRho(obj, varMult = FALSE)

Arguments

obj

glmmTMB model object with betabinomial error, and with a `dispformula` argument supplied.

varMult

If TRUE return, in addition to rho, the factor mult by which the variance is inflated relative to the binomial.

Value

if varMult==FALSE return (as a vector) the estimates \(\rho\), else (varMult==TRUE) return list(rho, mult).

Details

The variance for the betabinomial model is then obtained by multiplying the binomial variance by \(1+(n-1)\rho\), where $n$ is the binomial `size`.

Examples

Run this code
# NOT RUN {
pcheck <- suppressWarnings(requireNamespace("glmmTMB", quietly = TRUE))
if(pcheck) pcheck & packageVersion("glmmTMB") >= "1.1.2"
if(pcheck){
form <- cbind(Dead,Live)~0+trtGp/TrtTime+(1|trtGpRep)
HawMed <- droplevels(subset(HawCon, CN=="MedFly"&LifestageTrt!="Egg"))
HawMed <- within(HawMed,
                 {trtGp <- factor(paste0(CN,LifestageTrt, sep=":"))
                 trtGpRep <- paste0(CN,LifestageTrt,":",RepNumber)
                 scTime <- scale(TrtTime) })
HawMedbb.TMB <- glmmTMB::glmmTMB(form, dispformula=~trtGp+splines::ns(scTime,2),
                                 family=glmmTMB::betabinomial(link="cloglog"),
                                 data=HawMed)
rho <- qra::getRho(HawMedbb.TMB)} else
message("Example requires `glmmTMB` version >= 1.1.2: not available")

# }

Run the code above in your browser using DataLab