[R] Difference between gam() and loess().

Kevin E. Thorpe kevin.thorpe at utoronto.ca
Fri Mar 20 01:20:22 CET 2009


Rolf Turner wrote:
> 
> It seems that in general
> 
>     gam(y~lo(x)) # gam() from the gam package.
> 
> and
>     loess(y~x)
> 
> give slightly different results (in respect of the predicted/fitted 
> values).
> Most noticeable at the endpoints of the range of x.
> 
> Can anyone enlighten me about the reason for this difference?
> 
> Is it possible to twiddle the control parameters, for either or both 
> functions,
> so as to obtain identical results?

There are two obvious differences in the defaults.  In lo() from the gam 
package, span=0.5 and degree=1 while for loess(), span=0.75 and degree=2.

Try gam(y~lo(x,span=0.75,degree=2)) and see if that helps.

Kevin

-- 
Kevin E. Thorpe
Biostatistician/Trialist, Knowledge Translation Program
Assistant Professor, Dalla Lana School of Public Health
University of Toronto
email: kevin.thorpe at utoronto.ca  Tel: 416.864.5776  Fax: 416.864.6057




More information about the R-help mailing list