new_data | R Documentation |
Create a data frame for the "newdata"-argument that contains
all combinations of values from the terms in questions. Similar to
expand.grid()
. The terms
-argument accepts all shortcuts
for representative values as in predict_response()
.
new_data(model, terms, typical = "mean", condition = NULL, ...)
data_grid(model, terms, typical = "mean", condition = NULL, ...)
model |
A fitted model object. |
terms |
Character vector with the names of those terms from |
typical |
Character vector, naming the function to be applied to the
covariates (non-focal terms) over which the effect is "averaged". The
default is |
condition |
Named character vector, which indicates covariates that
should be held constant at specific values. Unlike |
... |
Currently not used. |
A data frame containing one row for each combination of values of the supplied variables.
data(efc, package = "ggeffects")
fit <- lm(barthtot ~ c12hour + neg_c_7 + c161sex + c172code, data = efc)
new_data(fit, c("c12hour [meansd]", "c161sex"))
nd <- new_data(fit, c("c12hour [meansd]", "c161sex"))
pr <- predict(fit, type = "response", newdata = nd)
nd$predicted <- pr
nd
# compare to
predict_response(fit, c("c12hour [meansd]", "c161sex"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.