predict.glmmTMB: prediction

Description Usage Arguments Details Examples

View source: R/predict.R

Description

prediction

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## S3 method for class 'glmmTMB'
predict(
  object,
  newdata = NULL,
  newparams = NULL,
  se.fit = FALSE,
  re.form = NULL,
  allow.new.levels = FALSE,
  type = c("link", "response", "conditional", "zprob", "zlink", "disp"),
  zitype = NULL,
  na.action = na.pass,
  fast = NULL,
  debug = FALSE,
  ...
)

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?

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"

conditional mean on the scale of the link function, or equivalently the linear predictor of the conditional model

"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 (gives an error for non-zero-inflated models)

"zlink"

predicted zero-inflation probability on the scale of the logit link function

"disp"

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

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?

...

unused - for method compatibility

Details

Examples

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

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
  [1] 254.2208 273.7636 293.3064 312.8492 332.3921 351.9349 371.4777 391.0205
  [9] 410.5634 430.1062 211.3566 213.1798 215.0030 216.8263 218.6495 220.4727
 [17] 222.2959 224.1191 225.9424 227.7656 212.9719 217.9258 222.8798 227.8337
 [25] 232.7876 237.7415 242.6954 247.6493 252.6032 257.5571 274.2374 280.0459
 [33] 285.8545 291.6630 297.4715 303.2801 309.0886 314.8971 320.7057 326.5142
 [41] 272.9551 280.4779 288.0006 295.5234 303.0462 310.5689 318.0917 325.6145
 [49] 333.1372 340.6600 260.2207 270.4528 280.6848 290.9169 301.1490 311.3811
 [57] 321.6132 331.8452 342.0773 352.3094 267.8471 278.1556 288.4640 298.7725
 [65] 309.0809 319.3894 329.6979 340.0063 350.3148 360.6232 244.4084 255.9084
 [73] 267.4084 278.9084 290.4085 301.9085 313.4085 324.9085 336.4086 347.9086
 [81] 250.3677 250.2355 250.1034 249.9712 249.8391 249.7069 249.5747 249.4426
 [89] 249.3104 249.1783 286.0714 305.1711 324.2707 343.3704 362.4701 381.5697
 [97] 400.6694 419.7691 438.8687 457.9684 226.8469 238.3786 249.9103 261.4420
[105] 272.9737 284.5054 296.0371 307.5688 319.1004 330.6321 239.0705 256.0094
[113] 272.9484 289.8874 306.8264 323.7654 340.7044 357.6434 374.5824 391.5214
[121] 255.6792 263.1911 270.7031 278.2150 285.7269 293.2389 300.7508 308.2628
[129] 315.7747 323.2866 272.0273 286.0563 300.0853 314.1143 328.1433 342.1723
[137] 356.2013 370.2303 384.2592 398.2882 254.6636 266.0026 277.3416 288.6806
[145] 300.0196 311.3586 322.6976 334.0366 345.3756 356.7146 226.6948 241.8218
[153] 256.9488 272.0758 287.2029 302.3299 317.4569 332.5839 347.7110 362.8380
[161] 252.1284 261.6246 271.1208 280.6171 290.1133 299.6095 309.1058 318.6020
[169] 328.0982 337.5945 263.5240 275.3020 287.0800 298.8580 310.6360 322.4139
[177] 334.1919 345.9699 357.7479 369.5258
[1] 251.4051
 [1] 251.4051 261.8724 272.3397 282.8070 293.2742 303.7415 314.2088 324.6761
 [9] 335.1434 345.6107

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