[R] constrained splines in GLM

Mayeul KAUFFMANN mayeul.kauffmann at tiscali.fr
Fri Oct 15 15:57:46 CEST 2004

I would like to use constrained splines in a GLM model (Poisson link)
to take into account the nonlinear effect of some covariate. The
constraints I need are described below.
I have several variables that I need concurrently in the same model.

I looked at package mgcv but I do not know if/how I can use it in GLM (not
GAM) : I could
not manage to adapt the mono.con(mgcv) example to GLM.
The help for package fda is not complete.
Not sure that backSpline(splines) does what I need.
isoreg (modreg) seems to do univariate regressions.

Some of my covariates are linear.

Three covariates (x1,x2 and x3) must be transformed in a decreasing and
convex way like


| o
|  o
|    o
|        o
|               ooooo

Currently, I use exp(-x1/alpha1)+exp(-x2/alpha2)+exp(-x3/alpha3), I try
several alpha's

and choose the best according to log-likelihood.

One variable should have only one local maximum (that is, the derivative
should be zero

only once, which is at the top), like this:
|          TOP
|          oo
|      o      o
|    o          o
|o o             o
|                 o o

with bs() or ns() and no constraint, I get:
|          TOP
|          oo
|o      o     o
|  o o          o
|                o
|                 o o
which is nonsense (note there are very few observations on the left part)

I also tried some parametric forms, choosing via log-likelihood. But with
four covariates,

it is a lot of parameters to try (several hours with little flexible

I am looking for something similar to ns or bs (package splines), which
are very

convenient to place in the formula of a GLM model. I tried them, adjusting
knots, but

could not manage what I want. Constraints on some derivatives may do the
trick, but I do

not know how to implement them in R.

Any help or comment would be greatly appreciated !

Université Pierre Mendès France - Grenoble

More information about the R-help mailing list