I am looking into the mboost
package in R
for creating GAM models. Below is code for creating a very simple GAM model with tree stumps on the mtcars
data set.
library(mboost)
my_model = mboost(formula = mpg ~ cyl + disp + hp,
data = mtcars,
baselearner = "btree",
control = boost_control(mstop = 1000, nu = 0.1))
par(mfrow = c(1,3))
plot(my_model)
The resulting shape plots for the three functions $f_{cyl}, f_{disp}, f_{hp}$ look like this:
I can now use the model to predict new instances by calling predict(mymodel, newdata)
. However, is there a way to predict by using one of the shape functions at the time? In practice, this means that I would like to call something like predict(f_cyl, newdata)
, predict(f_disp, newdata)
or predict(f_hp, newdata)
where f_cyl
, f_disp
and f_hp
are the shape functions that together make up the GAM.