[R] Questions about piecewise spline fitting

MUGGEO VITO vito.muggeo at giustizia.it
Thu Dec 6 15:08:09 CET 2001


> Thanks a lot for your advices.
>
> My real problem is that the knot positions are not predetermined,  so I
have
> to deal with this part by myself, :(.

This isn't a simple question:
Likelihood model with linear predictor
b1*X+ b2*pmax(X-th,0)
i.e. depending on (b1, b2, th) is just *piecewise differenziable* and so the
classical regularity condition (large sample first order approx) are not
met.
Several approach have been discussed in literature:
see, for instance,
-Kuchenoff (1997), Computational Statistics, vol12, 249
-Gossl (2001) , Stat in Med, vol20, pg 3109 for a bayesian approach and the
references inside.

However fixed th, the model is a classical [G]LM. So a "grid-search-type"
algorithm can be carried out on the profile [log]Lik for th

#profile [log]Lik for th:
fn(th,yourdata){
....write the obj function ....
}

#maximize it
th<-optimize(fn,th,range(x)...,maximum=T)$max

#Fit classical [G]LM *assuming known the estimate*
[g]lm(y~x+pmax(x-th,0)....)
#or
[g]lm(y~bs(x, knots=th, degree=1)....)

Alternatively you can get a smoothing estimate of the non-linear relation
(by smoothspline() for instance), and looking at the plot to "estimate" the
break-point.

Best,
vito



----- Original Message -----
From: "Gang Liang" <gumpleon at hotmail.com>
To: "MUGGEO VITO" <vito.muggeo at giustizia.it>; <r-help at hypatia.math.ethz.ch>
Sent: Thursday, December 06, 2001 6:22 AM
Subject: Re: [R] Questions about piecewise spline fitting


> Thanks a lot for your advices.
>
> My real problem is that the knot positions are not predetermined,  so I
have
> to deal with this part by myself, :(.
>
> ----- Original Message -----
> From: "MUGGEO VITO" <vito.muggeo at giustizia.it>
> To: "Gang Liang" <gumpleon at hotmail.com>; <r-help at hypatia.math.ethz.ch>
> Sent: Wednesday, December 05, 2001 1:39 AM
> Subject: Re: [R] Questions about piecewise spline fitting
>
>
> > Hi,
> > What you need is just the bs() or ns() functions in the library splines
in
> > the R-software. You have to specify the knots and can specify the
degree.
> > For instance:
> >
> > library(splines)
> > bs(1:20, knots=c(5,11), degree=1) #performs three #straight lines with
> > break-point at x=5 and 11 for the variable 1:20
> > lm(y~bs(1:20, knots=c(5,11), degree=1)) #piecewise linear regression
> >
> > Common "problem" is that the beta parameters for the pseudo-variables
> > inducted by bs() are not interpretable (i.e. in linear case they don't
> > represents the slopes in each piece).
> > best,
> > vito
> >
> >
> > ----- Original Message -----
> > From: "Gang Liang" <gumpleon at hotmail.com>
> > To: <r-help at hypatia.math.ethz.ch>
> > Sent: Wednesday, December 05, 2001 7:05 AM
> > Subject: [R] Questions about piecewise spline fitting
> >
> >
> > > Hi All,
> > >
> > > I want to fit a piecewise spline of degree 1, i.e. a spline consisting
> of
> > a
> > > straight line over each piece. I downloaded the R package pspline,
then
> I
> > > have following questions:
> > >
> > > 1. in the program, the degree of the spline is specified by
2*norder-1.
> > Why
> > > do they adopt such scheme that we can only fit a spline with odd
degree?
> > >
> > > 2. norder cannot be set to 1. Is there any specific reason for doing
so?
> > >
> > > Maybe I need to code this by myself. So I'd like to hear your advices.
> > >
> > > Thanks in advance,
> > > Gang
> > >
> > >
> > > _________________________________________________________________
> > >
> > >
> >
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
> > -.-.-
> > > 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
> > >
> >
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
> > _._
> >
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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