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