predict.glmmTMB {glmmTMB}R Documentation

prediction

Description

prediction

Usage

## S3 method for class 'glmmTMB'
predict(
  object,
  newdata = NULL,
  newparams = NULL,
  se.fit = FALSE,
  cov.fit = FALSE,
  re.form = NULL,
  allow.new.levels = FALSE,
  type = c("link", "response", "conditional", "zprob", "zlink", "disp", "latent"),
  zitype = NULL,
  na.action = na.pass,
  fast = NULL,
  debug = FALSE,
  aggregate = NULL,
  do.bias.correct = FALSE,
  bias.correct.control = list(sd = TRUE),
  ...
)

Arguments

object

a glmmTMB object

newdata

new data for prediction

newparams

new parameters for prediction

se.fit

return the standard errors of the predicted values?

cov.fit

return the covariance matrix of the predicted values?

re.form

NULL to specify individual-level predictions; ~0 or NA to specify population-level predictions (i.e., setting all random effects to zero)

allow.new.levels

allow previously unobserved levels in random-effects variables? see details.

type

Denoting mu as the mean of the conditional distribution and p as the zero-inflation probability, the possible choices are:

"link"

the linear predictor of the conditional model, or equivalently the conditional mean on the scale of the link function (this equivalence does not hold for truncated distributions, where the link-scaled value is not adjusted for the effect of truncation on the mean; to get the corrected value of the conditional mean on the linear predictor scale, use family(m)$linkfun(predict(m, type = "conditional")))

"response"

expected value; this is mu*(1-p) for zero-inflated models and mu otherwise

"conditional"

mean of the conditional response; mu for all models (i.e., synonymous with "response" in the absence of zero-inflation

"zprob"

the probability of a structural zero (returns 0 for non-zero-inflated models)

"zlink"

predicted zero-inflation probability on the scale of the logit link function (returns -Inf for non-zero-inflated models)

"disp"

dispersion parameter, however it is defined for that particular family (as described in sigma.glmmTMB)

"latent"

return latent variables

zitype

deprecated: formerly used to specify type of zero-inflation probability. Now synonymous with type

na.action

how to handle missing values in newdata (see na.action); the default (na.pass) is to predict NA

fast

predict without expanding memory (default is TRUE if newdata and newparams are NULL and population-level prediction is not being done)

debug

(logical) return the TMBStruc object that will be used internally for debugging?

aggregate

(optional factor vector) sum the elements with matching factor levels

do.bias.correct

(logical) should aggregated predictions use Taylor expanded estimate of nonlinear contribution of random effects (see details)

bias.correct.control

a list sent to TMB's function sdreport(). See documentation there.

...

unused - for method compatibility

Details

References

Thorson J.T. & Kristensen K. (2016) Implementing a generic method for bias correction in statistical models using random effects, with spatial and population dynamics examples. Fish. Res. 175, 66-74.

Examples

data(sleepstudy,package="lme4")
g0 <- glmmTMB(Reaction~Days+(Days|Subject),sleepstudy)
predict(g0, sleepstudy)
## Predict new Subject
nd <- sleepstudy[1,]
nd$Subject <- "new"
predict(g0, newdata=nd, allow.new.levels=TRUE)
## population-level prediction
nd_pop <- data.frame(Days=unique(sleepstudy$Days),
                     Subject=NA)
predict(g0, newdata=nd_pop)
## return latent variables (BLUPs/conditional modes/etc. ) with standard errors
##  (actually conditional standard deviations)
predict(g0, type = "latent", se.fit = TRUE)

[Package glmmTMB version 1.1.11 Index]