Safe predictions from a linear model
# S3 method for lm safe_predict(object, new_data, type = c("response", "conf_int", "pred_int"), ..., std_error = FALSE, level = 0.95)
object | An |
---|---|
new_data | TODO |
type | What kind of predictions to return. Options are:
|
... | Unused. |
std_error | Logical indicating whether or not calculate standard
errors for the fit at each point. Not available for all models, and can
be computationally expensive to compute. The standard error is always
the standard error for the mean, and never the standard error for
predictions. Standard errors are returned in a column called |
level | A number strictly between |
Do not use on model objects that only subclass lm
. This will result
in an error.
#> # A tibble: 32 x 1 #> .pred #> <dbl> #> 1 149. #> 2 141. #> 3 80.0 #> 4 126. #> 5 183. #> 6 111. #> 7 228. #> 8 77.1 #> 9 72.7 #> 10 146. #> # ... with 22 more rows#> # A tibble: 32 x 2 #> .pred .pred_std_error #> <dbl> <dbl> #> 1 NA NA #> 2 NA NA #> 3 NA NA #> 4 126. 11.9 #> 5 NA NA #> 6 NA NA #> 7 NA NA #> 8 NA NA #> 9 NA NA #> 10 NA NA #> # ... with 22 more rows#> # A tibble: 32 x 3 #> .pred .pred_lower .pred_upper #> <dbl> <dbl> <dbl> #> 1 NA NA NA #> 2 NA NA NA #> 3 NA NA NA #> 4 126. 76.6 175. #> 5 NA NA NA #> 6 NA NA NA #> 7 NA NA NA #> 8 NA NA NA #> 9 NA NA NA #> 10 NA NA NA #> # ... with 22 more rows