Description Usage Arguments Details Value See Also Examples
This is a generic function to append response level probabilities
to a data frame. A response level probability (conditioned on the
model and covariates), such as Pr(Response|Covariates < 10),
is generated for the fitted value of each observation in
df
. These probabilities are then appended to df
and
returned to the user as a data frame.
1 |
df |
A data frame of new data. |
fit |
An object of class |
q |
A real number. A quantile of the conditional response distribution. |
name |
|
yhatName |
A character vector of length one. Names of the |
comparison |
A string. If |
... |
Additional arguments |
For more specific information about the arguments that are useful in each method, consult:
add_probs.lm
for linear regression response probabilities
add_probs.glm
for generalized linear regression response probabilities
add_probs.lmerMod
for linear mixed models response probabilities
add_probs.glmerMod
for generalized linear mixed model response probabilities
add_probs.survreg
for accelerated failure time model response probabilities
Note: Except in add_probs.survreg
, the probabilities
calculated by add_probs
are on the distribution of
Y|x, not E[Y|x]. That is, they use the same
distribution from which a prediction interval is determined, not
the distribution that determines a confidence
interval. add_probs.survreg
is an exception to this pattern
so that users of accelerated failure time models can obtain
estimates of the survivor function.
A dataframe, df
, with predicted values and
probabilities attached.
add_ci
for confidence intervals,
add_quantile
for response level quantiles, and
add_pi
for prediction intervals.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Define a model
fit <- lm(dist ~ speed, data = cars)
# Calculate the probability that the probability that a new
# dist is less than 20 (Given the model).
add_probs(cars, fit, q = 20)
# Calculate the probability that a new
# dist is greater than 20 (Given the model).
add_probs(cars, fit, q = 20, comparison = ">")
# Try a different model fit.
fit2 <- glm(dist ~ speed, family = "poisson", data = cars)
add_probs(cars, fit2, q = 20)
# Try a different model fit.
fit3 <- lme4::lmer(Reaction ~ Days + (1|Subject), data = lme4::sleepstudy)
add_probs(lme4::sleepstudy, fit3, q = 300, type = "parametric")
# As above, but do not condition on the random effects.
add_probs(lme4::sleepstudy, fit3, q = 300, type = "parametric", includeRanef = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.