A wrapper for mgcv::gam() for use in nadir::super_learner().
Arguments
- data
A dataframe to train a learner / learners on.
- formula
A regression formula to use inside this learner.
- weights
Observation weights; see
?lm- ...
Any extra arguments that should be passed to the internal model for model fitting purposes.
Value
A prediction function that accepts newdata,
which returns predictions (a numeric vector of values, one for each row
of newdata).
Examples
lnr_gam(mtcars, mpg ~ s(hp) + disp + am + wt)(mtcars)
#> [1] 23.22581 22.45824 25.40058 20.36615 17.39324 19.90987 15.23172 24.76043
#> [9] 21.43602 18.52657 18.52657 15.12845 16.15188 16.00137 11.64956 10.83166
#> [17] 10.59240 28.47690 31.71946 29.65859 23.24865 17.57240 17.78308 14.38672
#> [25] 16.30327 29.27554 26.17361 26.13006 17.23486 20.10104 14.55182 22.69349
lnr_gam(mtcars, mpg ~ s(hp) + disp + am + wt, family = Gamma)(mtcars)
#> [1] 22.46849 21.40311 25.16986 19.52882 16.71790 19.08543 15.09481 21.99541
#> [9] 21.04550 19.00727 19.00727 15.56686 16.31717 16.20232 12.54476 12.22792
#> [17] 12.21143 27.66637 33.38767 30.51650 24.17497 17.26981 17.56591 14.61477
#> [25] 15.62167 29.54403 26.16189 29.39878 15.57818 19.81020 13.85100 22.14393
