[R] scatterplot smoothing using gam

Liaw, Andy andy_liaw at merck.com
Thu Jul 24 22:06:35 CEST 2003


This is gam() in the mgcv package, I presume?  That does regression splines,
AFAIK.

You don't need gam() to do scatterplot smoothing either.  If you want se
bands, you can get that from locfit(), in the locfit package.  There are
several other packages that does kernel/local polynomial smoothing, but I
don't know if they provide se bands.

HTH,
Andy



> -----Original Message-----
> From: Tony Long [mailto:tdlong at uci.edu] 
> Sent: Thursday, July 24, 2003 3:06 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] scatterplot smoothing using gam
> 
> 
> All:
> 
> 	I am trying to use gam in a scatterplot smoothing problem. 
> The data being smoothed have greater 1000 observation and have 
> multiple "humps".  I can smooth the data fine using a function 
> something like:
> 
> out <- ksmooth(x,y,"normal",bandwidth=0.25)
> plot(x,out$y,type="l")
> 
> The problem is when I try to fit the same data using gam
> 
> out <- predict.gam(gam(y~s(x)),se=TRUE)
> plot(x,out$fit,type="l")
> 
> I only seem to get fits that would correspond to "big" bandwidths 
> using ksmooth, and straight lines are always fit to the data.  I do 
> not appear to appreciate how to "control bandwidth" using gam.  As 
> even if I apply something like the gam model above to the smoothed 
> "out$y" generated using ksmooth it tends to flatten out the smoothing 
> curve.
> -- 
> ###########################
> 
> Tony Long
> 
> Ecology and Evolutionary Biology
> Steinhaus Hall
> University of California at Irvine
> Irvine, CA
> 92697-2525
> 
> Tel:  (949) 824-2562   (office)
> Tel:  (949) 824-5994   (lab)
> Fax: (949) 824-2181
> 
> email:  tdlong at uci.edu
> http://hjmuller.bio.uci.edu/~labhome/
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
> 

------------------------------------------------------------------------------
Notice: This e-mail message, together with any attachments, ...{{dropped}}




More information about the R-help mailing list