Re: [R] Gam() function in R

From: Simon Wood <>
Date: Mon 06 Dec 2004 - 22:41:07 EST

> this subject is very intersting for me. I'm using mgcv 0.8-9 with R
> version 1.7.1. i didn't know that there was an another gam version with
> package library(gam). Someone can tell me the basics differences between
> them? I look for an help page on google but i only find "mgcv" help
> pages.

Here's an attempt at a summary of the differences:

Estimation: gam::gam based on backfitting, mgcv::gam based on direct penalized likelihood maximization (with smoothness estimation integrated)

Model selection: package(gam) based on stepwise regression methods. mgcv::gam based on integrated GCV estimation of degree of smoothness.

Smooth terms: gam::gam can represent smooth terms using a very wide range of scatterplot smoothers incuding loess, which is built in. mgcv::gam is restricted to smoothers that can be represented using basis functions and an associated ``wiggliness'' penalty, but these include low rank thin plate spline smoothers and tensor product smoothers for smooths of more than one variable. Both packages provide interfaces for adding new classes of smoother.

Uncertainty estimation: since mgcv GAMs explicitly estimate coefficients for each smooth term, it is fairly straightforward to obtain a covariance matrix for the model coefficients, which makes further variance calcualtions easy. For example predictions with standard errors are easily obtained for predictions made with new prediction data. The backfitting approach makes variance calculation more difficult (e.g. at present s.e.s are not available from gam::predict.gam with new data)

Interface: both packages are based on Trevor Hastie's Chapter 7 of Chambers and Hastie. Since Trevor H. wrote package(gam) it's a closer implementation than package(mgcv).

Basically, if you want integrated smoothness selection, an underlying parametric representation, or want smooth interactions in your models then mgcv is probably worth a try (but I would say that). If you want to use local regression smoothers and/or prefer the stepwise selection approach then package gam is for you.


> Simon Wood
>> Department of Statistics, University of Glasgow, Glasgow, G12 8QQ >>> Direct telephone: (0)141 330 4530 Fax: (0)141 330 4814 mailing list PLEASE do read the posting guide! Received on Mon Dec 06 22:49:14 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 01:22:34 EST