Skip to content
Prev 259073 / 398502 Next

Using $ accessor in GAM formula

On 06/05/11 07:05, P Ehlers wrote:
Admittedly one should use the preferred code, i.e. gam(y ~ s(x),data=dat)
and avoid all the hoo-hah, but it's strange that the dodgey code
throws an error with gam(dat1$y ~ s(dat1$x))  but not with
gam(dat2$cf ~ s(dat2$s)) --- where dat1 and dat2 are identical except
for their column names.  Why are the column names having an impact
upon finding the variables/objects in question?

And it isn't just "x" and "y" that cause the error; I tried naming the 
columns
"u" and "v" and the error was thrown in that case also.  It seems that 
having
that name "s" involved keeps the error from happening.  It's probably not
coincidental that that is the name of a *function* that gam() uses.

Something a bit subtle is going on; it would be nice to be able to 
understand it.

Just out of pure academic interest. :-)

     cheers,

         Rolf Turner