| broken.line {segmented} | R Documentation |
Given a segmented model (typically returned by a segmented method), broken.line
computes the fitted values for each `segmented' relationship.
broken.line(ogg, term = NULL, gap = FALSE, link = FALSE)
ogg |
A fitted object of class segmented (returned by any segmented method). |
term |
A character meaning for which segmented variable prediction should be computed. |
gap |
Should the `gaps' of the segmented relationships be plotted? Default to FALSE. Currently unimplemented. |
link |
Should the predictions be computed on the scale of the link function? Default to FALSE. |
If term=NULL predictions for each segmented variable in the fitted model are computed. Argument link
is ignored whether ogg does not inherit from the class "glm".
A matrix whose columns represent predictions for the segmented variables.
set.seed(1234)
z<-runif(100)
y<-rpois(100,exp(2+1.8*pmax(z-.6,0)))
o<-glm(y~z,family=poisson)
o.seg<-segmented(o,seg.Z=~z,psi=list(z=.5))
par(mfrow=c(1,2))
plot(z,y)
points(z,broken.line(o.seg,link=FALSE),col=2,pch=20)
plot(z,broken.line(o.seg,link=TRUE),ylab="log(Fitted)")
point.psi(o.seg,"z",col=2,pch="x",bottom=FALSE)