[R] Gam() function in R
Jari Oksanen
jari.oksanen at oulu.fi
Mon Dec 6 09:09:47 CET 2004
On 6 Dec 2004, at 7:36, Janice Tse wrote:
> Thanks for the email. I will check that out....
>
> However when I was doing this : gam(y~s(x1)+s(x2,3),
> family=gaussian,
> data=mydata )it gives me the error :
>
> "Error in terms.formula(formula, data = data) :
> invalid model formula in ExtractVars"
>
> What does it mean ?
>
When Any Liaw answered you (below), he asked you to specify which kind
of 'gam' did you use: the one in standard package 'mgcv' or the one in
package 'gam'. We should know this to know "what does it mean" to get
your error message. If you used mgcv:::gam, it means that you didn't
read it help pages which say that you should specify your model as:
gam(y ~ s(x1) + s(x2, k=3))
Further, it may be useful to read the help pages to understand what it
means to specify k=3 and how it may influence your model. Simon Wood --
the mgcv author -- also has a very useful article in the R Newsletter:
see the CRAN archive. It may be really difficult to understand what you
do when you do mgcv:::gam unless you read this paper (it is possible,
but hard). Simon's article specifically answers to your first question
of deciding the smoothness, and explains how elegantly this is done in
mgcv:::gam (gam:::gam has another set of tools and philosophy).
If you happened to use gam:::gam, then you have to look at another
explanation.
cheers, jari oksanen
> From: Liaw, Andy [mailto:andy_liaw at merck.com]
> Sent: Sunday, December 05, 2004 11:34 PM
> To: 'Janice Tse'; r-help at stat.math.ethz.ch
> Subject: RE: [R] Gam() function in R
>
> Unfortunately that's not really an R question. I recommend that you
> read up
> on the statistical methods underneath. One that I'd wholeheartedly
> recommend is Prof. Harrell's `Regression Modeling Strategies'.
>
> [BTW, there are now two implementations of gam() in R: one in `mgcv',
> which
> is fairly different from that in `gam'. I'm guessing you're
> referring to
> the one in `gam', but please remember to state which contributed
> package
> you're using, along with version of R and OS.]
>
> Cheers,
> Andy
>
>> From: Janice Tse
>>
>> Hi all,
>>
>> I'm a new user of R gam() function. I am wondering how do
>> we decide on the
>> smooth function to use?
>> The general form is gam(y~s(x1,df=i)+s(x2,df=j).......) , how do we
>> decide on the degree freedom to use for each smoother, and if we shold
>> apply smoother to each attribute?
>>
>> Thanks!!
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide!
>> http://www.R-project.org/posting-guide.html
>>
>>
>
>
> -----------------------------------------------------------------------
> -----
> --
> Notice: This e-mail message, together with any
> attachments,...{{dropped}}
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
--
Jari Oksanen, Oulu, Finland
More information about the R-help
mailing list