Learn R Programming

LSTbook (version 0.5.0)

model_eval: Evaluate a model on inputs

Description

Evaluate a model on inputs

Usage

model_eval(
  mod,
  data = NULL,
  ...,
  skeleton = FALSE,
  ncont = 3,
  interval = c("prediction", "confidence", "none"),
  level = 0.95,
  type = c("response", "link")
)

Value

A data frame. There is one row for each row of the input values (see data parameter). The columns include

  • the explanatory variables

  • .output --- the output of the model that corresponds to the explanatory value

  • the .lwr and .upr bounds of the prediction or confidence interval

  • if training data is used as the input, the .response variable and the .resid. Note that the generic name .response is used, not the actual name of the model's response variable.

Arguments

mod

A model as from model_train(), lm() or glm()

data

A data frame of inputs. If missing, the inputs will be assembled from ... or from the training data, or an skeleton will be constructed.

skeleton

Logical flag. If TRUE, a skeleton on inputs will be created. See model_skeleton().

ncont

Only relevant to skeleton. The number of levels at which to evaluate continuous variables. See model_skeleton().

interval

One of "prediction" (default), "confidence", or "none".

level

The level at which to construct the interval (default: 0.95)

type

Either "response" (default) or "link". Relevant only to glm models. The format of the .output

...

Optional vectors specifying the inputs. See examples.

Examples

Run this code
mod <- mtcars |> model_train(mpg ~ hp + wt)
model_eval(mod, hp=100, wt=c(2,3))
model_eval(mod) # training data
model_eval(mod, skeleton=TRUE)

Run the code above in your browser using DataLab