ranef.glmmTMB: Extract Random Effects

Description Usage Arguments Value Note See Also Examples

View source: R/methods.R

Description

Extract random effects from a fitted glmmTMB model, both for the conditional model and zero inflation.

Usage

1
2
3
4
5
6
7
8
## 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, ...)

Arguments

object

a glmmTMB model.

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 ranef.glmmTMB object (i.e., the result of running ranef on a fitted glmmTMB model)

Value

Note

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.

See Also

fixef.glmmTMB.

Examples

1
2
3
4
5
6
7
8
9
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)
}

Example output

Warning message:
In checkMatrixPackageVersion() : Package version inconsistency detected.
TMB was built with Matrix version 1.2.15
Current Matrix version is 1.2.17
Please re-install 'TMB' from source using install.packages('TMB', type = 'source') or ask CRAN for a binary version of 'TMB' matching CRAN's 'Matrix' package
$cond
$cond$Subject
    (Intercept)
308   40.635065
309  -77.565893
310  -62.878623
330    4.390358
331   10.178934
332    8.191252
333   16.440339
334   -2.986087
335  -45.117144
337   71.919622
349  -21.119036
350   14.059914
351   -7.833598
352   36.245834
369    7.010713
370   -6.339544
371   -3.282295
372   18.049705


$zi
list()

        component  grpvar        term grp    condval   condsd
cond.1       cond Subject (Intercept) 308  40.635065 12.53483
cond.2       cond Subject (Intercept) 309 -77.565893 12.65075
cond.3       cond Subject (Intercept) 310 -62.878623 12.59611
cond.4       cond Subject (Intercept) 330   4.390358 12.49122
cond.5       cond Subject (Intercept) 331  10.178934 12.49347
cond.6       cond Subject (Intercept) 332   8.191252 12.49250
cond.7       cond Subject (Intercept) 333  16.440339 12.49793
cond.8       cond Subject (Intercept) 334  -2.986087 12.49094
cond.9       cond Subject (Intercept) 335 -45.117144 12.54508
cond.10      cond Subject (Intercept) 337  71.919622 12.62842
cond.11      cond Subject (Intercept) 349 -21.119036 12.50263
cond.12      cond Subject (Intercept) 350  14.059914 12.49599
cond.13      cond Subject (Intercept) 351  -7.833598 12.49234
cond.14      cond Subject (Intercept) 352  36.245834 12.52582
cond.15      cond Subject (Intercept) 369   7.010713 12.49202
cond.16      cond Subject (Intercept) 370  -6.339544 12.49178
cond.17      cond Subject (Intercept) 371  -3.282295 12.49099
cond.18      cond Subject (Intercept) 372  18.049705 12.49942

glmmTMB documentation built on July 20, 2021, 9:06 a.m.