[R] GAMs under R?

Prof Brian D Ripley ripley at stats.ox.ac.uk
Mon May 1 08:19:56 CEST 2000


On Mon, 1 May 2000, Bill Venables wrote:

> At 06:09 AM 5/1/00 +0100, Prof Brian D Ripley wrote:
> >On Sun, 30 Apr 2000, Stephen R. Laniel wrote:
> >
> >> I was just now surprised to note that functions to go generalized additive
> >> models don't appear to exist under R 1.000.  In particular, the gam() and
> >> loess() functions aren't there.  Are they hidden somewhere and I just
> >> haven't noticed?
> >
> >loess: yes, and it's not really hidden. It is in standard package modreg.
> >It does not do `generalized additive models' though, even under S.
> >(The R implementation is a little less general than that in S.)
> >
> >gam(): no, it is not there.  Look at the original code to see one reason
> >why: it is highly convoluted and not at all well documented.  I think
> >additive models have been greatly over-sold in certain statistical circles,
> >but if you want to use them for least-squares fitting, try bruto (in
> >package mda on CRAN) instead as at least that makes a sensible attempt to
> >choose the smoothness of the variable transformations.
> 
> The restriction "for least-squares fitting" is crucial.  bruto is a form of
> additive model fitting, not *generalized* additive model fitting.  If you
> have to deal with binomial, poisson, .... models it doesn't help much.

Whoah!  It helps a great deal.  gam() fits by IWLS just like glm(), so you
can build an outer loop around bruto(), say.  The variable selection
aspects of bruto make that somewhat unstable, but with a good starting
set of weights (e.g. from a large linear fit) it can work well.  (I did
some experiments in ca 1994 when writing my PRNN book.)


> >I wonder why you were surprised?  See section 5.6 of the FAQ:
> >
> >  5.6 How can I contribute to R?
> >  ==============================
> >
> >[...]
> >
> >     One place where functionality is still missing is the modeling
> >  software as described in "Statistical Models in S" (see *Note What is
> >  S?::); Generalized Additive Models (*gam*) and some of the nonlinear
> >  modeling code are not there yet.
> >
> >which shows we are still waiting for a volunteer (hint, hint).
> 
> But the effort required should not be under-estimated and the need for a
> *good* implementation is pretty strict.  A mediocre or worse implementation
> is in many ways worse than useless and even dangerous.  This looks like a

(And where do you place the one in S-PLUS?  The main difficulty with
implementing modreg was bugs in the underlying code, bugs which also exist
in the S-PLUS implementation, but Linux compilers/glibc seemed to 
stumble over them where Solaris did not.)

Those who look at the future plans for R (on developer.r-project.org)
will see in my section:

Longer term

...

Something better than gam for additive models. Perhaps along the lines of
BRUTO (in package mda).

[That's not likely to materialize for some months, though.]

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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