I have a train data table in R
, which always have different columns, for example now the data table has the following column names:
library(mgcv)
dt.train <- c("DE", "DEWind", "DESolar", "DEConsumption", "DETemperature",
"DENuclear", "DELignite")
Now I want to fit a Generalized Additive Model (= GAM) with integrated smoothness estimation that predicts the DE
price. At the moment I fit the model as the following:
fitModel <- mgcv::gam(DE ~ s(DEWind)+s(DESolar)+s(DEConsumption)+s(DETemperature)+
s(DENuclear)+s(DELignite),
data = dt.train)
The column names are currently hard-coded, but I don't want to change this all the time, I would like to let the program recognize how many columns there are and fit the model with the existing columns. So, I would like to have something like this (which works for stats::lm()
or stats::glm()
):
fitModel <- mgcv::gam(DE ~ .-1, data = dt.train)
Unfortunately, this doesn't work with gam()
.