Last chance! 50% off unlimited learning
Sale ends in
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 ggpredict()
.
new_data(model, terms, typical = "mean", condition = NULL)
A fitted model object.
Character vector with the names of those terms from
model
for which all combinations of values should be created.
Character vector, naming the function to be applied to the
covariates over which the effect is "averaged". The default is "mean".
See ?sjmisc::typical_value
for options.
Named character vector, which indicates covariates that
should be held constant at specific values. Unlike typical
, which
applies a function to the covariates to determine the value that is used
to hold these covariates constant, condition
can be used to define
exact values, for instance condition = c(covariate1 = 20, covariate2 = 5)
.
See 'Examples'.
A data frame containing one row for each combination of values of the supplied variables.
# NOT RUN {
data(efc)
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
ggpredict(fit, c("c12hour [meansd]", "c161sex"))
# }
Run the code above in your browser using DataLab