mid.conditional {midr}R Documentation

Calculate ICE of MID Models

Description

mid.conditional() creates an object to draw ICE curves of a MID model.

Usage

mid.conditional(
  object,
  variable,
  data = NULL,
  keep.effects = TRUE,
  n.samples = 100L,
  max.nrow = 100000L,
  type = c("response", "link")
)

## S3 method for class 'mid.conditional'
print(x, digits = max(3L, getOption("digits") - 2L), ...)

Arguments

object

a "mid" object.

variable

a character string or expression specifying the variable for the ICE calculation.

data

a data frame containing observations for which ICE values are calculated. If not passed, data is extracted from parent.env() based on the function call of the "mid" object.

keep.effects

logical. If TRUE, the effects of component functions are stored in the output object.

n.samples

integer. The number of sample points for the calculation.

max.nrow

an integer specifying the maximum number of rows of the output data frames.

type

the type of prediction required. The default is "response". "link" is possible if the MID model uses a link function.

x

a "mid.conditional" object to be printed.

digits

an integer specifying the minimum number of significant digits to be printed.

...

additional parameters to be passed to print.default() to print the sample point vector.

Details

mid.conditional() obtains predictions for hypothetical observations from a MID model and returns a "mid.conditional" object. The graphing functions ggmid() and plot() can be used to generate the ICE curve plots.

Value

mid.conditional() returns an object of class "mid.conditional" with the following components:

terms

the character vector of relevant terms.

observed

the data frame of the actual observations and the corresponding predictions.

conditional

the data frame of the hypothetical observations and the corresponding predictions.

values

the sample points of the variable.

Examples

data(airquality, package = "datasets")
mid <- interpret(Ozone ~ .^2, airquality, lambda = 1)
mc <- mid.conditional(mid, "Wind", airquality)
mc

[Package midr version 0.5.0 Index]