I was talking to Jeremy Freeman at CSHL and he asked about an easy way to fit a spline nonlinearity in a Poisson regression model. Recall that with the canonical exponential nonlinearity, we have the following setup:
And the negative log-likelihood is given by:
Start by fitting w by maximum likelihood. Compute . Then you can do one of two simple things to fit the output nonlinearity with a spline. Choice 1 is to set , where D is the basis matrix for the spline, and u is a set of weights. You want to use fmincon with A equal to the negative of the basis matrix for the spline evaluated at equispaced points in the range of the spline and B set to a vector of small equal negative values (say -.0001).
A second option is to set . In that case, the model reduces to Poisson regression and can be fit through unconstrained optimization.