getRho: Extract estimates of the intra-class correlation from a...

View source: R/getRho.R

getRhoR Documentation

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.

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'.

Value

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

Examples

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")


jhmaindonald/qra-R-package documentation built on Nov. 16, 2023, 2:39 p.m.