Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

Greetings,

I'm performing research that will help determine the size of observed space and the time elapsed since the big bang. Hopefully you can help!

I have data conforming to a piecewise linear function on which I want to perform two linear regressions. There is a point at which the slope and intercept change, and I need to (write a program to) find this point.

Thoughts?

share|improve this question
3  
What is the policy on cross-posting? The exact same question was asked on math.stackexchange.com: math.stackexchange.com/questions/15214/… – mpiktas Dec 22 '10 at 17:58

5 Answers

R package strucchange might help you. Look at the vignette, it has a nice overview how to solve similar problems.

share|improve this answer

This is an (offline) changepoint detection problem. Our previous discussion provides references to journal articles and R code. Look first at the Barry and Hartigan "product partition model," because it handles changes in slope and has efficient implementations.

share|improve this answer

If the number of points is not too big, you may try all possibilities. Let's assume that the points are $X_i=(x_i,y_i)$ where $i=1,..,N$. Than, you may loop with $j$ from $2$ to $N-2$ and fit two lines to both $\{X_1,...,X_j\}$ and $\{X_{(j+1)},...,X_N\}$. Finally, you pick $j$ for which the sum of sum of squared residuals for both lines is minimal.

share|improve this answer

Also the segmented package has helped me with similar problems in the past.

share|improve this answer

What is wrong with doing simple non-linear least squares in this case? Am I missing something obvious?

share|improve this answer
1  
I'd say that the derivative of the goal function with respect to the change point parameter is rather un-smooth – Andre Holzner Jul 27 '12 at 13:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.