## Add Regression Quantiles to Data Frames

### Description

This is a generic function to append regression quantiles to a data frame. A regression quantile q is a point such that Pr(Response | Covariates < q) = p. These quantiles are generated for the fitted value of each observation in df. Quantiles are then appended to df and returned to the user as a data frame.

### Usage

add_quantile(df, fit, p = 0.5, name = NULL, yhatName = "pred", ...)


### Arguments

 df A data frame of new data. fit An object of class lm, glm, or lmerMod. Predictions are made with this object. p A double. A probability that determines the quantile. Must be between 0 and 1. name NULL or a string. If NULL, quantiles automatically will be named by add_quantile(), otherwise, the quantiles will be named name in the returned data frame. yhatName A string. Name of the vector of predictions. ... Additional arguments

### Details

For more specific information about the arguments that are applicable for each type of model, consult:

• add_quantile.lm for linear regression response quantiles

• add_quantile.glm for generalized linear regression response quantiles

• add_quantile.lmerMod for linear mixed models response quantiles

• add_quantile.glmerMod for generalized linear mixed models response quantiles

• add_quantile.survreg for accelerated failure time response quantiles

Note: Except in add_ci.survreg, the quantiles that add_quantile calculates are on the distribution of Y|x, not E[Y|x]. That is, they use the same distribution that determines a prediction interval, not the distribution that determines a confidence interval.

### Value

A dataframe, df, with predicted values and level-p quantiles attached.

add_ci for confidence intervals, add_probs for response level probabilities, and add_pi for prediction intervals

### Examples


# Fit a linear model
fit <- lm(dist ~ speed, data = cars)

# Find the 0.4 quantile (or 40th percentile) of new distances for
# each observations in cars, conditioned on the linear model.

# Fit a Poisson model
fit2 <- glm(dist ~ speed, family = "poisson", data = cars)
# Find the 0.4 quantile (or 40th percentile) of new distances for
# each observation in cars, conditioned on the Poisson model.