Re: [R] piece-wise linear regression nls function

2013-01-10 Thread Rolf Turner
Instead of reinventing the wheel, why not use the "segmented" package? Having stored your data in a data frame "X" I did: require(segmented) m1 <- lm(FM ~ BMIJS,data=X) m2 <- segmented(m1,seg.Z=~BMIJS,psi=list(BMIJS=35)) which worked instantaneously. The break point is estimated as 41.580, wi

Re: [R] piece-wise linear regression nls function

2013-01-09 Thread David Winsemius
On Jan 9, 2013, at 5:33 PM, John Sorkin wrote: > windows 7, R 2.12 > > I am trying to run a piecewise linear regression with a single knot, i.e. a > regression composed of two straight lines where the two lines intersect at an > x value given by the variable knot. I wish to estimate the slope

[R] piece-wise linear regression nls function

2013-01-09 Thread John Sorkin
windows 7, R 2.12 I am trying to run a piecewise linear regression with a single knot, i.e. a regression composed of two straight lines where the two lines intersect at an x value given by the variable knot. I wish to estimate the slope of both lines, the value of knot, the x value where the t