Re: [R] Using $ accessor in GAM formula

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Thu, 05 May 2011 14:06:19 -0400

On May 5, 2011, at 1:08 PM, Gene Leynes wrote:

> This is not mission critical, but it's bothering me. I'm getting
> inconsistent results when I use the $ accessor in the gam formula
>
> *In window #1:*
>> library(mgcv)
>> dat=data.frame(x=1:100,y=sin(1:100/50)+rnorm(100,0,.05))
>> str(dat)
>> gam(dat$y~s(dat$x))
> Error in eval(expr, envir, enclos) : object 'x' not found

I get the same error, but using the standard R approach to passing data and formulae to regression functions I have not difficulty:

 > gam(y~s(x), data=dat)

Family: gaussian
Link function: identity

Formula:
y ~ s(x)

Estimated degrees of freedom:
4.1552 total = 5.155229

GCV score: 0.002242771

>>
>
> *In window #2:*
>> gm = gam(dat$cf~s(dat$s))
>> gm
>
> Family: gaussian
> Link function: identity
>
> Formula:
> dat$cf ~ s(dat$s)
>
> Estimated degrees of freedom:
> 8.7757 total = 9.77568980091
>
> GCV score: 302.551417213
>
>
>
>
> Has anyone else seen the same thing?
>
> In both cases I'm using Windows 7 and R 2.13.0
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 05 May 2011 - 18:08:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 05 May 2011 - 19:20:05 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive