| add_quantile.lm {ciTools} | R Documentation |
Quantiles for the Response of a Linear Model
Description
This function is one of the methods of add_quantile. It is
called automatically when add_quantile is called on objects
of class lm.
Usage
## S3 method for class 'lm'
add_quantile(
df,
fit,
p,
name = NULL,
yhatName = "pred",
log_response = FALSE,
...
)
Arguments
df |
A data frame of new data. |
fit |
An object of class |
p |
A real number between 0 and 1. Sets the level of the quantiles. |
name |
|
yhatName |
A string. Name of the vector of predictions. |
log_response |
A logical. If TRUE, quantiles will be generated
for the prediction made with a log-linear model: |
... |
Additional arguments. |
Details
Quantiles for linear models are determined parametrically, by
applying a pivotal quantity to the distribution of Y|x.
Value
A dataframe, df, with predicted values and level -
p quantiles attached.
See Also
add_ci.lm for confidence intervals for
lm objects, add_pi.lm for prediction
intervals of lm objects, and add_probs.lm
for response probabilities of lm objects.
Examples
# Fit a linear Model
fit <- lm(dist ~ speed, data = cars)
# Find the 0.7-quantile (70th percentile) of new distances, given
# the linear model fit.
add_quantile(cars, fit, p = 0.7)
# As above, but with a custom name for the vector of quantiles
add_quantile(cars, fit, p = 0.7, name = "my_quantile")