I'm trying to calculate the prediction of a model on a dataset but I get an error with the model generated by the library caret model <- caret::train(method="gamSpline", ...)
> model$modelInfo$label
[1] "Generalized Additive Model using Splines"
> model$modelInfo$library
[1] "gam"
> pred <- predict(object = model, newdata = newData)
Error
Error in s(V1, df = 3) : could not find function "s"
12. eval(predvars, data, env)
11. eval(predvars, data, env)
10. model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels)
9. model.frame(Terms, newdata, na.action = na.action, xlev = object$xlevels)
8. predict.lm(object, newdata, se.fit, scale = 1, type = ifelse(type ==
"link", "response", type), terms = terms, na.action = na.action)
7. predict.glm(object, newdata, type = local.type, dispersion = dispersion,
se.fit = FALSE, terms = terms)
6. newdata.predict.Gam(object, newdata, type, dispersion, se.fit,
na.action, terms, ...)
5. gam:::predict.Gam(modelFit, newdata, type = "response") at gamSpline.R#42
4. method$predict(modelFit = modelFit, newdata = newdata, submodels = param)
3. predictionFunction(method = object$modelInfo, modelFit = object$finalModel,
newdata = newdata, preProc = object$preProcess)
2. predict.train(object = model, newdata = newData)
1. predict(object = model, newdata = newData)
My newData look like this dim(newData): 101 513