model_values {LSTbook} | R Documentation |
Construct a model and return the model values
Description
One-stop shopping to fit a model and return the model output on the training data.
Usage
model_values(data, tilde, family = c("linear", "prob", "counts"))
Arguments
data |
A data frame containing the training data. When used with |
tilde |
A model specification in the form of a tilde expression |
family |
The type of model architecture: |
Details
This is intended to be used ONLY WITHIN mutate()
Value
A vector (not a data frame) of the model evaluated on the training data.
This is intended mainly for use within mutate()
, so that a general model can be used in
the place of simple reduction verbs like mean()
, median()
Examples
mtcars |> mutate(mpg_mod = model_values(mpg ~ hp + wt)) |> select(hp, wt, mpg_mod) |> head()
[Package LSTbook version 0.5.0 Index]