Learn R Programming

segmented (version 0.2-5)

broken.line: Fitted values for segmented relationships

Description

Given a segmented model (typically returned by a segmented method), broken.line computes the fitted values for each `segmented' relationship.

Usage

broken.line(ogg, term = NULL, gap = FALSE, linkinv = FALSE)

Arguments

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.
linkinv
Should the predictions be computed on the scale of the link function? Default to FALSE.

Value

  • A matrix whose columns represent predictions for the segmented variables.

Details

If term=NULL predictions for each segmented variable in the fitted model are computed. Argument linkinv is ignored whether ogg does not inherit from the class "glm".

See Also

segmented, predict.glm

Examples

Run this code
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))
plot(z,y)
points(z,broken.line(o.seg,linkinv=TRUE),col=2,pch=20)

Run the code above in your browser using DataLab