Skip to contents

Predictions are given at the population level, i.e., with random effects set to zero. For fitted models including random effects, see fitted.galamm. For mixed response models, only predictions on the scale of the linear predictors is supported.

Usage

# S3 method for galamm
predict(object, newdata = NULL, type = c("link", "response"), ...)

Arguments

object

An object of class galamm returned from galamm.

newdata

Data from for which to evaluate predictions, in a data.frame. Defaults to "NULL", which means that the predictions are evaluate at the data used to fit the model.

type

Character argument specifying the type of prediction object to be returned. Case sensitive.

...

Optional arguments passed on to other methods. Currently used for models with smooth terms, for which these arguments are forwarded to mgcv::predict.gam.

Value

A numeric vector of predicted values.

Examples

# Poisson GLMM
count_mod <- galamm(
  formula = y ~ lbas * treat + lage + v4 + (1 | subj),
  data = epilep, family = poisson
)

# Plot response versus link:
plot(
  predict(count_mod, type = "link"),
  predict(count_mod, type = "response")
)


# Predict on a new dataset
nd <- data.frame(lbas = c(.3, .2), treat = c(0, 1), lage = 0.2, v4 = -.2)
predict(count_mod, newdata = nd)
#>       [,1]
#> 1 2.188055
#> 2 1.832320
predict(count_mod, newdata = nd, type = "response")
#>       [,1]
#> 1 8.917850
#> 2 6.248365