[R] Piece-wise continuous regression with one knot

Duncan Murdoch murdoch.duncan at gmail.com
Thu Dec 23 15:15:47 CET 2010


On 23/12/2010 9:03 AM, John Sorkin wrote:
> Windows Vista
> R 2.10 - I know it is old, I will update later today.
>
> How might I perform a piece-wise linear regression where two linear segments are separated by a single knot? In addition to estimating the slopes of the two segments (or the slope in one segment and the difference between the slope of the first and second segment), I would like the analysis to select the optimum knot. My first analysis will contain a single dependent and a single independent variables. Subsequent analyses will add additional independent variables to determine the effect on the results of adjusting for potential confounding.


Do you know the position of the knot?  If so, it's simply linear 
regression with two predictors.  One predictor could be the x variable, 
the other should be zero below the knot, x above it.  (This corresponds 
to the formulation you list in parentheses; it's best if you want to 
test whether the knot is necessary or not).

If you don't know the position of the knot it's a much harder problem.  
I don't know current recommended practice.

Duncan Murdoch



More information about the R-help mailing list