[R] Piecewise Regression with a known slope

Jarrett Byrnes jebyrnes at ucdavis.edu
Sun Jul 29 23:22:05 CEST 2007


Hey, all.  I'm working on a data set with a broken stick linear  
regression where I know one of the two slopes.  It is a negative  
linear function until the line intersects with the x-axis, at which  
point it becomes 0.  It is not a nonlinear asymptotic function, and,  
indeed, using negative exponential or logistic types of fits as an  
approximation has tended to lead to an under or overestimation of  
values.  I am also very interested to know just what the breakpoint  
in the data is.

Essentially

if x<psi y = a + bx + error, where b is negative
else y=0+error

and I want to know the value of psi, as well as a and b.  The error  
is also most likely gamma distributed, as values<0 are not possible  
(nutrient concentrations).

I have attempted to use the segmented package, specifying something  
close to the visually estimated breakpoint as the value of psi, but  
it continues to return fits with a breakpoint that occurs somewhere  
in the middle of the linear portion of the line, and the slope and  
intercept of the second half of the regression is not 0.

Is there either a package that exists that will allow me to estimate  
such a model, or a function that I can use for optim or nlm (I admit,  
I am a rank novice at coding such functions).

Thanks so much!

-Jarrett



More information about the R-help mailing list