Skip to content
Prev 259146 / 398502 Next

Using $ accessor in GAM formula

On Fri, 2011-05-06 at 11:20 -0500, Gene Leynes wrote:
Dear Gene,
No, No, No, No, No!!!!!

If there is one thing you **should** take from this thread is that there
is no need to perform subsetting like that in a model formula.

Why would you want (or prefer) to do:

gam(dat$y ~ s(dat$x))

or

gam(dat[, "y"] ~ s(dat[, "x"]))

when

gam(y ~ s(x), dat)

will suffice?
If you use R's formula notation properly, you'll get cleaner code than
either of your suggestions.
I would consider this a bug - but in the sense that Simon didn't foresee
the strange formulas that users of his software might concoct.

By the way, I think you perhaps meant Berwin (re the detailed analysis)?

HTH

G