plot.segmented {segmented}R Documentation

Plot method for segmented objects

Description

Takes a fitted segmented object returned by segmented() and plots (or add) the fitted broken-line for the selected segmented term.

Usage

## S3 method for class 'segmented':
plot(x, term = NULL, se = FALSE, const = coef(x)["(Intercept)"],
  add = FALSE, linkinv = FALSE, show.gap=TRUE, rev.sgn=FALSE, n.points = 10, ...)

Arguments

x a fitted segmented object
term the segmented variable whose piece-wise relationship has to be plotted. If there is a single segmented variable, term can be omitted
se when TRUE pointwise confidence intervals are drawn. Currently unimplemented.
const constant to add to each fitted segmented relationship (on the scale of the linear predictor) before plotting
add when TRUE the fitted lines are added to the current device
linkinv when TRUE, the fitted lines are (possibly) tranformed on the inverse link scale before plotting; in this case it could be useful to increase n.points to get smooth curves
show.gap should the gap between the fitted lines at the estimated breakpoints to be shown?
rev.sgn when TRUE it is assumed that current term is `minus' the actual segmented variable, therefore the sign is reversed before plotting. This is useful when a null-constraint has been set on the last slope
n.points number of points where the fitted lines have to be computed
... other graphics parameters to pass on to plotting commands

Details

Produces (or adds to the current device) the fitted segmented relationship between the response and the selected term. If the fitted model includes just a single `segmented' variable, term may be omitted. Due to the parameterization of the segmented terms, sometimes the fitted lines may not appear to join at the estimated breakpoints. If this is the case, the apparent `gap' would indicate some lack-of-fit. However such `gap' may be hidden by setting show.gap=FALSE: in this case the new fitted values are re-computed by means of a linear model fit. Note that, as hidding could lead to a wrong impression of the fit, show.gap=TRUE is suggested only when the gap coefficients are nonsignificant.

Value

None.

Author(s)

Vito M.R. Muggeo

See Also

lines.segmented

Examples

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(o.seg)
plot(z,y)
plot(o.seg,add=TRUE,linkinv=TRUE,lwd=2,col=2)
lines(o.seg,col=2,pch=19,bottom=FALSE,lwd=2)

[Package segmented version 0.2-4 Index]