Skip to contents

Generates predictions from a fitted heckmanGE model. Predictions can be made on the scale of the linear predictors or on the scale of the response variable. The function can also return confidence intervals for the predictions if requested.

Usage

# S3 method for class 'heckmanGE'
predict(
  object,
  part = c("selection", "outcome", "dispersion", "correlation"),
  newdata = NULL,
  type = c("link", "response"),
  cofint = F,
  confidence_level = 0.95
)

Arguments

object

An object of class heckmanGE. This object should be a fitted model from which predictions will be made.

part

A character vector specifying the model part for which to make predictions. Options include "selection", "outcome", "dispersion", and "correlation". The default is "outcome". If multiple parts are specified, only the "outcome" part will be used.

newdata

Optionally, a data frame containing new data for making predictions. If omitted, the function uses the fitted linear predictors from the model object.

type

The type of prediction required. The default is "link", which returns predictions on the scale of the linear predictors. If "response" is specified, predictions are returned on the scale of the response variable after applying the inverse link function.

cofint

A logical indicating whether to return confidence intervals for the predictions. Default is FALSE.

confidence_level

A numeric value specifying the confidence level for the confidence intervals if cofint is TRUE. Default is 0.95.

Value

A vector or matrix of predictions from the heckmanGE object, depending on the value of cofint. If cofint is TRUE, the function returns a matrix with the mean predicted value, and the lower and upper bounds of the confidence interval.

Details

  • The function first checks the validity of the part and type arguments.

  • If newdata is provided, the function ensures it matches the variables and structure of the original model frame.

  • Predictions can be on the link scale or the response scale, depending on the type argument.

  • Confidence intervals are calculated if cofint is TRUE, using the standard errors derived from the model.