Predicts the response variable using a Ridge regression model

predict_ridge_regression(data, ridge_fit, x_vars)

Arguments

data

dataframe containing the feature variables

ridge_fit

a list containing the model object and fitted values

x_vars

character vector of variable names to be used as predictors

Value

a numeric vector of predicted values

Examples

data(mtcars)
ridge_fit <- fit_ridge_regression(data = mtcars, x_vars = c("wt"), y_var = "mpg", lambda = 0.1)
ridge_pred <- predict_ridge_regression(data = mtcars, ridge_fit, x_vars = c("wt"))
ridge_pred # display the predicted values
#>                           mpg
#> Mazda RX4           22.928357
#> Mazda RX4 Wag       21.668911
#> Datsun 710          24.410059
#> Hornet 4 Drive      19.989649
#> Hornet Sportabout   18.878372
#> Valiant             18.779592
#> Duster 360          18.236301
#> Merc 240D           20.113124
#> Merc 230            20.310684
#> Merc 280            18.878372
#> Merc 280C           18.878372
#> Merc 450SE          15.766798
#> Merc 450SL          17.446060
#> Merc 450SLC         17.199110
#> Cadillac Fleetwood   9.938771
#> Lincoln Continental  9.079384
#> Chrysler Imperial    9.469566
#> Fiat 128            25.002740
#> Honda Civic         27.892058
#> Toyota Corolla      26.805477
#> Toyota Corona       23.693903
#> Dodge Challenger    18.483252
#> AMC Javelin         18.903067
#> Camaro Z28          16.902770
#> Pontiac Firebird    16.878075
#> Fiat X1-9           26.311576
#> Porsche 914-2       25.299080
#> Lotus Europa        28.395837
#> Ford Pantera L      20.211904
#> Ferrari Dino        22.187506
#> Maserati Bora       18.236301
#> Volvo 142E          22.138116