powered by
Add predicted values of different types to dataframe
add_pred(data, model, var = "pred", type = NULL, transformation = NULL)
dataframe / tibble
dataframe or tibble
model object
name of new variable in dataframe / tibble
type of predicted value
A possible transformation of predicted variable, e.g. reciprocal(), log() etc
Søren Højsgaard
data(cars) lm1 <- lm(dist ~ speed + I(speed^2), data=cars) lm1 |> response() |> head() cars <- cars |> add_pred(lm1) cars |> head() cars <- cars |> add_resid(lm1) cars
Run the code above in your browser using DataLab