predict.jglmm: Predictions from a model

View source: R/predict.R

predict.jglmmR Documentation

Predictions from a model

Description

Predictions from a model

Usage

## S3 method for class 'jglmm'
predict(object, newdata = NULL, type = "link", allow.new.levels = FALSE, ...)

Arguments

object

An object of class 'jglmm', as returned by 'jglmm'.

newdata

(optional) A dataframe of new data.

type

(optional) A character string - either "link" (default), where predictions are returned on the scale of the linear predictors, or "response", where predictions are returned on the scale of the response variable.

allow.new.levels

(optional) A logical indicating whether new random effects levels in newdata are allowed. If FALSE (default), such new values in newdata will trigger an error; if TRUE, then the prediction will use population-level values for data with previously unobserved values.

...

Optional additional arguments, currently none are used.

Value

A numeric vector of predicted values

Examples

## Not run: 
jglmm_setup()
cbpp <- dplyr::mutate(lme4::cbpp, prop = incidence / size)
gm1 <- jglmm(prop ~ period + (1 | herd), data = cbpp, family = "binomial",
             weights = cbpp$size)
predict(gm1)
predict(gm1, type = "response")
newdata <- with(cbpp, expand.grid(period=unique(period), herd=unique(herd)))
predict(gm1, newdata)

## End(Not run)

mikabr/jglmm documentation built on Nov. 18, 2022, 1:32 a.m.