[R] piecewise linear approximation

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Thu Aug 30 03:05:52 CEST 2007

On Wed, 29 Aug 2007, Naxerova, Kamila wrote:

> Dear list,
> I have a series of data points which I want to approximate with exactly two
> linear functions. I would like to choose the intervals so that the total
> deviation from my fitted lines is minimal. How do I best do this?

>From the information you give it seems that you want to partition a model 
   lm(y ~ x)
along a certain ordering of the observations. Without any further 
restrictions you can do that with the function breakpoints() in package 
"strucchange". If there are continuity restrictions or something like 
that, you want to look at the "segmented" package.


> Thanks!
> Kamila
> The information transmitted in this electronic communication...{{dropped}}
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

More information about the R-help mailing list