Add predictions to the data set. A dplyr compatible way to add predictions to a data set.

add_model_predictions(model = NULL, old_data = NULL, new_data = NULL)

Arguments

model

A model object from `fit_model`

old_data

The data set to which predicted values will be added.

new_data

The data set to use for predicting.

Value

A data.frame object with a new column for predicted values

See also

Examples

data("yields", package="manymodelr")
yields1 <- yields[1:50,]
yields2<- yields[51:100,]
lm_model <- fit_model(yields1,"weight","height","lm") 
head(add_model_predictions(lm_model,yields1,yields2))
#>   normal    height     weight    yield predicted
#> 1    Yes 0.2849090 0.13442312 520.2837 0.2424740
#> 2     No 0.2427826 0.37484971 504.4754 0.3567557
#> 3    Yes 0.2579432 0.47134828 515.6463 0.3072897
#> 4     No 0.5175604 0.50143592 522.2247 0.2381176
#> 5    Yes 0.4026023 0.47171755 502.6406 0.2655422
#> 6     No 0.9789886 0.04191937 509.4663 0.2464302