[R] gam() in Splus and R

Simon Wood snw at mcs.st-and.ac.uk
Mon Aug 20 14:27:08 CEST 2001


> Is there any difference in the gam() function in R and Splus?
- there are quite alot of differences: see latest issue of Rnews [Perhaps
I shouldn't have called it "gam()" - but this does describe what it does]. 

> 
> I just tried to do an Ace Plot (plotting the result of the gam() ) on a
> dataset.  R gave me four (the data set has one response and four
> explanatory variables) ace plot with perfectly straight lines.  I kind of
> felt that it is highly unlikely, so I tried it in Splus.  Using the exact
> commands Splus gave me four completely different ace plots (in fact so
> different that three of them suggested a quadratic polynomial
> transformation).

- As Brian Ripley pointed out, the difference here is that mgcv's gam() is
doing model selection for you. If you want something more like an Splus
GAM then you can fix the degrees of freedom for each the model terms -

e.g. 
> gam(y~s(x,5|f)) # fits 4 df regression spline

then you should find a closer correspondance between what you get from
R/mgcv and what you get from Splus. 

mgcv has a tendancy to select too many straight lines if your predictor
variables are highly correlated. I would check for this and try dropping
some terms (again, see current Rnews). 

Finally: how many data do you have? GCV will tend to suggest smoothing 
quite heavily if there are very few data.  

Simon

  ______________________________________________________________________
> Simon Wood  snw at st-and.ac.uk  http://www.ruwpa.st-and.ac.uk/simon.html
> The Mathematical Institute, North Haugh, St. Andrews, Fife KY16 9SS UK
> Direct telephone: (0)1334 463799          Indirect fax: (0)1334 463748 


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list