predict.refmodel: Predictions or log predictive densities from a reference...

View source: R/refmodel.R

predict.refmodelR Documentation

Predictions or log predictive densities from a reference model

Description

This is the predict() method for refmodel objects (returned by get_refmodel() or init_refmodel()). It offers three types of output which are all based on the reference model and new (or old) observations: Either the linear predictor on link scale, the linear predictor transformed to response scale, or the log predictive density.

Usage

## S3 method for class 'refmodel'
predict(
  object,
  newdata = NULL,
  ynew = NULL,
  offsetnew = NULL,
  weightsnew = NULL,
  type = "response",
  ...
)

Arguments

object

An object of class refmodel (returned by get_refmodel() or init_refmodel()).

newdata

Passed to argument newdata of the reference model's extract_model_data function (see init_refmodel()). Provides the predictor (and possibly also the response) data for the new (or old) observations. May also be NULL (see argument extract_model_data of init_refmodel()). If not NULL, any NAs will trigger an error.

ynew

If not NULL, then this needs to be a vector of new (or old) response values. See section "Value" below.

offsetnew

Passed to argument orhs of the reference model's extract_model_data function (see init_refmodel()). Used to get the offsets for the new (or old) observations.

weightsnew

Passed to argument wrhs of the reference model's extract_model_data function (see init_refmodel()). Used to get the weights for the new (or old) observations.

type

Only relevant if is.null(ynew). The scale on which the predictions are returned, either "link" or "response" (see predict.glm() but note that predict.refmodel() does not adhere to the typical R convention of a default prediction on link scale). For both scales, the predictions are averaged across the posterior draws.

...

Currently ignored.

Details

Argument weightsnew is only relevant if !is.null(ynew).

Value

Either a vector of predictions (with the scale depending on argument type) or, if !is.null(ynew), a vector of log predictive densities evaluated at ynew.


projpred documentation built on Nov. 10, 2022, 5:15 p.m.