On Sep 27, 2012, at 9:07 PM, Ben Harrison wrote:
> Hello,
>
> I have produced some segmented regressions with the segmented package by
> Viggo Mutteo. I have some example data and code below. I want to annotate
> the individual segments with the slope parameter (actually it would be
> nicer to annotate with 1000*slope and add some small amount of text as
> well). How can I do it? Reading the docs for segmented I can access all of
> the slope parameters via a named vector of the coefficients. How can I
> access the slope segments or locations? I have never tried to annotate an R
> plot before, so I don't even know how to 'pin' a bit of text to
an x,y
> location on a plot.
>
?text # should be fairly clear.
>> dput(bullard)
> structure(list(Rt = c(14.4477, 23.6752, 26.723, 33.8508, 37.9628,
> 47.0804, 49.7232, 54.6395, 59.9251, 64.7518, 81.1629, 85.7209,
> 88.0334, 98.366, 102.6563, 105.6953, 134.8691, 137.3795, 155.0056,
> 158.6707, 162.0671, 206.7413, 248.701, 255.9407, 265.5201, 283.1462,
> 288.8939, 299.8356, 311.0788, 323.2355, 366.9049, 379.3662, 384.3869,
> 392.3246, 436.0853, 439.1246, 454.6023, 458.6247, 464.1744, 479.9764,
> 486.5171, 489.5564, 507.5925, 524.7894, 544.0806, 558.7642, 562.4293,
> 577.9268, 650.8613, 658.6664, 669.6996, 692.7172, 694.6993),
> Tem = c(14.6189, 15.2877, 15.3106, 15.3536, 15.3665, 15.3764,
> 15.3928, 15.4182, 15.4671, 15.528, 15.5921, 15.7066, 15.7806,
> 15.8747, 16.0244, 16.146, 16.481, 16.6098, 16.8581, 17.0339,
> 17.2242, 17.8379, 19.2747, 19.7184, 19.9621, 20.0953, 20.4838,
> 20.578, 20.774, 21.0112, 23.01, 23.3897, 24.1697, 24.4176,
> 27.0874, 27.3597, 28.0178, 28.4026, 28.909, 29.7406, 30.532,
> 30.8734, 32.216, 32.8198, 34.0339, 34.7553, 35.2611, 35.8303,
> 41.1202, 41.5027, 42.0578, 42.6597, 42.656)), .Names = c("Rt",
> "Tem"), class = "data.frame", row.names = c(NA, -53L))
>
> library(segmented)
>
> out.lm <- lm(Tem ~ Rt, data=bullard)
>
> o<-segmented(out.lm, seg.Z=~Rt, psi=NA,
control=seg.control(display=FALSE,
> K=2))
>
> plot(o, lwd=1,col=2:6, main='Plot title')
> points(bullard)
> abline(out.lm, col="red", lwd=2)
>
> Ben.
>
> [[alternative HTML version deleted]]
Please learn to post in plain text.
--
David Winsemius, MD
Alameda, CA, USA