predict_linear_regression.Rd
Predicts the response variable using a linear regression model
predict_linear_regression(data, lm_fit, x_vars, intercept = TRUE)
dataframe containing the feature variables
a list containing the model object and fitted values
character vector of variable names to be used as predictors
logical value indicating whether to include an intercept term in the model
a numeric vector of predicted values
data(mtcars)
lm_fit <- fit_linear_regression(data = mtcars, x_vars = c("wt"), y_var = "mpg")
lm_pred <- predict_linear_regression(data = mtcars, lm_fit, x_vars = c("wt"))
lm_pred # display the predicted values
#> mpg
#> Mazda RX4 23.282611
#> Mazda RX4 Wag 21.919770
#> Datsun 710 24.885952
#> Hornet 4 Drive 20.102650
#> Hornet Sportabout 18.900144
#> Valiant 18.793255
#> Duster 360 18.205363
#> Merc 240D 20.236262
#> Merc 230 20.450041
#> Merc 280 18.900144
#> Merc 280C 18.900144
#> Merc 450SE 15.533127
#> Merc 450SL 17.350247
#> Merc 450SLC 17.083024
#> Cadillac Fleetwood 9.226650
#> Lincoln Continental 8.296712
#> Chrysler Imperial 8.718926
#> Fiat 128 25.527289
#> Honda Civic 28.653805
#> Toyota Corolla 27.478021
#> Toyota Corona 24.111004
#> Dodge Challenger 18.472586
#> AMC Javelin 18.926866
#> Camaro Z28 16.762355
#> Pontiac Firebird 16.735633
#> Fiat X1-9 26.943574
#> Porsche 914-2 25.847957
#> Lotus Europa 29.198941
#> Ford Pantera L 20.343151
#> Ferrari Dino 22.480940
#> Maserati Bora 18.205363
#> Volvo 142E 22.427495