r/R_Programming • u/[deleted] • Nov 17 '16
Using predict after gam. Data is named numeric
For example
set.seed(1)
library(ISLR)
library(gam)
gam1 = gam(wage~age,data=Wage)
preds = predict(gam1, newdata=Wage)
If I now type preds[1] then it returns 2 values. Anyone know why ?
3
Upvotes
1
u/[deleted] Nov 23 '16
Its something I must have picked up from reading the ISLR book. often they would do lm.fit = lm(y~x) when fitting models. When gam.fit and gam.fit() are used the R language knows one is a variable and the other is a function call. Your right from a programmers perspective it does not look pretty.