Description Usage Arguments Details Value Examples
View source: R/evaluate_model.R
Find the model outputs for specified inputs. This is equivalent to the
generic predict()
function, except it will choose sensible values
by default. This simplifies getting a quick look at model values.
1 2 |
model |
the model to display graphically |
data |
optional set of cases from which to extract levels for explanatory variables |
on_training |
flag whether to use the training data for evaluation. Only needed
when there are random terms, e.g. from |
nlevels |
how many levels to construct for input variables.
For quantitative variables, this is a suggestion. |
at |
named list giving specific values at which to hold the variables. Use this to
override the automatic generation of levels for any or all explanatory variables.
Unlike |
... |
arguments about or values at which to evaluate the model or the kind of output to be passed along to predict(). |
This function is set up to let you look easily at typical outputs. The function
will choose "typical" levels of the explanatory variables at which to evaluate the model.
(See the examples.) The nlevels
controls
how many levels of these levels to use. If you wish to choose your own levels for one or more
explanatory variables, give those variables as named arguments assigned to the levels you want. If you have
a data frame with the desired inputs for some or all of the explanatory variables,
use the data
argument to pass those values.
There are two ways to evaluate the model on the training data. The first is
to set the data
argument to the same data frame used to train the model. The second
is to use the on_training = TRUE
argument. These are equivalent unless there is
some random component among the explanatory terms, as with 'mosaic::rand()', 'mosaic::shuffle()' and so on.
When you want to restrict/force the evaluation at specified values of an explanatory variable,
include a vector of those variables in ... for instance sex = "F"
will restrict the evaluation
to females.
A dataframe containing both the explanatory variable inputs and
the resulting model output (in the 'model_value' field). This differs from the output
of predict()
, which for many model classes/architectures may be a vector or matrix.
A data frame containing both the inputs to the model and the corresponding outputs.
1 2 3 4 5 6 7 8 | ## Not run: mod1 <- lm(wage ~ age * sex + sector, data = mosaicData::CPS85)
evaluate_model(mod1)
mod3 <- glm(married == "Married" ~ age + sex * sector,
data = mosaicData::CPS85, family = "binomial")
evaluate_model(mod3, nlevels = 2, type = "response")
evaluate_model(mod3, nlevels = 2, type = "response", at = list(sex = "F"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.