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
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
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
3 matches
Mail list logo