Description Usage Arguments Details Value See Also Examples
This function is one of the methods in add_ci
and
automatically is called when an object of class lm
is passed
to add_ci
.
1 2 3 4 5 6 7 8 9 10 |
df |
A data frame. |
fit |
An object of class |
alpha |
A real number between 0 and 1. Controls the confidence level of the interval estimates. |
names |
|
yhatName |
A string. Name of the vector of the predictions made for each observation in df |
log_response |
Logical. Default is |
... |
Additional arguments. |
Confidence intervals for lm
objects are calculated
parametrically. This function is essentially a wrapper for
predict(fit, df, interval = "confidence")
if fit
is a
linear model. If log_response = TRUE
, confidence intervals
for the response are calculated using Wald's Method. See Meeker and
Escobar (1998) for details.
A dataframe, df
, with predicted values, upper and lower
confidence bounds attached.
add_pi.lm
for prediction intervals for
lm
objects, add_probs.lm
for conditional
probabilities of lm
objects, and
add_quantile.lm
for response quantiles of
lm
objects.
1 2 3 4 5 6 7 8 9 | # Fit a linear model
fit <- lm(dist ~ speed, data = cars)
# Get fitted values for each observation in cars, and append
# confidence intervals
add_ci(cars, fit)
# Try a different confidence level
add_ci(cars, fit, alpha = 0.5)
# Try custom names for the confidence bounds
add_ci(cars, fit, alpha = 0.5, names = c("lwr", "upr"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.