I wish I had a better answer.

There are two things that I know of that use a direct approach:

The segmentation package seems to work well if you are doing a few fits, but
I had problems when I tried running it on loads of data.  It's a bit tricky
to parametrize.  When I tried investigating the internals I found that the
variables are are in Italian, which makes it difficult (and comical) to
follow. However, the theory is very attractive.

There are also some examples in the archives where people have used the nls
solver.  But, as I remember, it didn't do a great job at estimating
breakpoints (maybe it didn't do it at all).  If you don't know about
markmail, that has a nice interface for searching the help archives, and you
can easily find the example I'm referencing:
http://r-project.markmail.org/

A second approach (in my mind) is to use a two step approach of smoothing,
then segmenting the smooth:

The other thing that I have found very useful is using approx in conjunction
with a smoother, like a spline or GAM.  You can get a smooth estimate, and
then do something like have a piecewise line at every 10th percentile of
your smoothed line.

I've experimented with is using a classification and regression tree (rpart
package) to classify the slope of a smooth line, and then use the regions of
slopes to reconstitute a line.  One of the challenges with this approach is
deciding when to stop segmenting, and picking an appropriate CP value.

I keep thinking that there must be some sort of annealing optimization
approach that would work the best, but I have not had the time to figure out
how to specify it.

Gene

On Fri, Jan 14, 2011 at 8:42 AM, Federico Bonofiglio <bonoricus@gmail.com>wrote:

> Hello everybody!!!!
>
> Quick question, if you'd like to throw a little tip:
>  does anyone knows a function that runs piecewise regression models with
> coefficients estimation and inferences ?
>
> Thank you
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

