## Prediction Intervals for Linear Model Predictions

### Description

This function is one of the methods for add_pi and is automatically called when an object of class lm is passed to to add_pi.

### Usage

## S3 method for class 'lm'
df,
fit,
alpha = 0.05,
names = NULL,
yhatName = "pred",
log_response = FALSE,
...
)


### Arguments

 df A data frame of new data. fit An object of class lm. Predictions are made with this object. alpha A real number between 0 and 1. Controls the confidence level of the interval estimates. names NULL or character vector of length two. If NULL, prediction bounds automatically will be named by add_pi, otherwise, the lower prediction bound will be named names[1] and the upper prediction bound will be named names[2]. yhatName A string. Name of the predictions vector. log_response A logical. If TRUE, prediction intervals will be generated at the response level of a log-linear model: \log(Y) = X\beta + \epsilon. Again, these intervals will be on the scale of the original response, Y. ... Additional arguments.

### Details

Prediction intervals for lm objects are calculated parametrically. This function is essentially just a wrapper for predict(fit, df, interval = "prediction") if fit is a linear model. If log_response = TRUE, prediction intervals for the response are calculated parametrically, then the exponential function is applied to transform them to the original scale.

### Value

A dataframe, df, with predicted values, upper and lower prediction bounds attached.

add_ci.lm for confidence intervals for lm objects. add_probs.lm for conditional probabilities of lm objects, and add_quantile.lm for response quantiles of lm objects.

### Examples

# Fit a linear model
fit <- lm(dist ~ speed, data = cars)
# Add prediction intervals and fitted values to the original data