ranef.glmmTMB | R Documentation |

Extract random effects from a fitted `glmmTMB`

model, both
for the conditional model and zero inflation.

## S3 method for class 'glmmTMB' ranef(object, condVar = TRUE, ...) ## S3 method for class 'ranef.glmmTMB' as.data.frame(x, ...) ## S3 method for class 'glmmTMB' coef(object, condVar = FALSE, ...)

`object` |
a |

`condVar` |
whether to include conditional variances in result. |

`...` |
some methods for this generic function require additional arguments (they are unused here and will trigger an error) |

`x` |
a |

For

`ranef`

, an object of class`ranef.glmmTMB`

with two components:- cond
a list of data frames, containing random effects for the conditional model.

- zi
a list of data frames, containing random effects for the zero inflation.

If

`condVar=TRUE`

, the individual list elements within the`cond`

and`zi`

components (corresponding to individual random effects terms) will have associated`condVar`

attributes giving the conditional variances of the random effects values. These are in the form of three-dimensional arrays: see`ranef.merMod`

for details. The only difference between the packages is that the attributes are called ‘postVar’ in lme4, vs. ‘condVar’ in glmmTMB.For

`coef.glmmTMB`

: a similar list, but containing the overall coefficient value for each level, i.e., the sum of the fixed effect estimate and the random effect value for that level.*Conditional variances are not yet available as an option for*`coef.glmmTMB`

.For

`as.data.frame`

: a data frame with components- component
part of the model to which the random effects apply (conditional or zero-inflation)

- grpvar
grouping variable

- term
random-effects term (e.g., intercept or slope)

- grp
group, or level of the grouping variable

- condval
value of the conditional mode

- condsd
conditional standard deviation

When a model has no zero inflation, the
`ranef`

and `coef`

print methods simplify the
structure shown, by default. To show the full list structure, use
`print(ranef(model),simplify=FALSE)`

or the analogous
code for `coef`

.
In all cases, the full list structure is used to access
the data frames, see example.

`fixef.glmmTMB`

.

if (requireNamespace("lme4")) { data(sleepstudy, package="lme4") model <- glmmTMB(Reaction ~ Days + (1|Subject), sleepstudy) rr <- ranef(model) print(rr, simplify=FALSE) ## extract Subject conditional modes for conditional model rr$cond$Subject as.data.frame(rr) }

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.