This method for estfun extracts the
clusterwise score vectors (empirical estimating functions)
from a fitted glmmTMB model.
Usage
# S3 method for class 'glmmTMB'
estfun(x, full = FALSE, cluster = getGroups(x), rawnames = FALSE, ...)Arguments
- x
a
glmmTMBobject fitted with ML (REML is not supported).- full
logical; if
TRUE, return the full score vectors including random effects, otherwise only the fixed effects part.- cluster
a factor indicating the cluster structure of the data.
- rawnames
logical; if
TRUE, return the raw names of the parameters as in theTMBobject. By default,FALSEsuch that the names are sanitized to user friendly names.- ...
additional arguments (ignored).
Value
A matrix where each row corresponds to a cluster and each column corresponds to a parameter in the model. The values are the empirical estimating functions (score vectors) for each parameter in each cluster.
Note
If crossed random effects are used in the model, this function will not correctly calculate the score vectors in general, and warnings will be issued. In general, this function should be used with models with a single level of random effects or nested random effects only.
Examples
m <- glmmTMB(count ~ mined + (1 | spp), data = Salamanders, family = nbinom1)
estfun(m)
#> (Intercept) minedno
#> GP 0.2706978 6.48860214
#> PR -3.0211081 -3.75532769
#> DM 0.8819707 0.03221597
#> EC-A -1.7796539 -1.25566270
#> EC-L 1.3133490 2.56472446
#> DES-L 1.8236451 1.58152422
#> DF 0.5110888 -5.65607409
estfun(m, full = TRUE)
#> (Intercept) minedno disp~(Intercept) theta_1|spp.1
#> GP 0.2706978 6.48860214 -2.85282038 -0.9164167
#> PR -3.0211081 -3.75532769 0.05300856 2.3621127
#> DM 0.8819707 0.03221597 -3.42399503 -0.6776685
#> EC-A -1.7796539 -1.25566270 -0.30579461 0.2215967
#> EC-L 1.3133490 2.56472446 8.34515563 -0.3458957
#> DES-L 1.8236451 1.58152422 1.63267299 0.2125095
#> DF 0.5110888 -5.65607409 -3.44822281 -0.8562380