[R] GAM with constraints

Simon Wood s.wood at bath.ac.uk
Tue Nov 27 11:53:43 CET 2007


Are you interested in equality constraints or inequality constraints?

mgcv::gam will allow you to supply your own smooths (see e.g. ?p.spline), and 
the specification mechanism allows you to supply linear equality constraints 
that the smooth must satisfy, which are then handled automatically. Whether 
this mechanism is general enough  depends a bit on the nature of your 
constraints... 

Function `magic' can be used inside an IRLS loop for general GAM fitting (and 
is one of the options for fitting with mgcv::gam): it will accept completely 
general linear equality constraints.

`pcls' is really useful for the inequality constraint case (e.g. when you want 
shape preserving smooths). For fixed smoothing parameters you can embed this 
in an IRLS loop for gam fitting also, but convergence can be tricky, and 
smoothing parameter selection not so straightforward.

Simon

On Sunday 25 November 2007 08:48, lubaroz wrote:
> Hi,
> I am trying to build GAM with linear constraints, for a general link
> function, not only identity. If I understand it correctly, the function
> pcls() can solve the problem, if the smoothness penalties are given.
> What I need is to incorporate the constraints before calculating the
> penalties. Can this be done in R?
> Any help would be greately appreciated.



-- 
> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603  www.maths.bath.ac.uk/~sw283



More information about the R-help mailing list