Learn R Programming

segmented (version 2.2-1)

broken.line: Fitted values for segmented relationships

Description

Given a segmented model (typically returned by a segmented method), broken.line computes the fitted values (and relevant standard errors) for the specified `segmented' relationship.

Usage

broken.line(ogg, term = NULL, link = TRUE, interc=TRUE, se.fit=TRUE, isV=FALSE, 
  .vcov=NULL, .coef=NULL, ...)

Arguments

Value

A list having one component if (if se.fit=FALSE), and two components (if se.fit=TRUE) list representing predictions and standard errors for the segmented covariate values.

Details

If term=NULL or term is a valid segmented covariate name, predictions for that segmented variable are the relevant fitted values from the model. If term is a (correctly named) list with numerical values, predictions corresponding to such specified values are computed. If link=FALSE and ogg inherits from the class "glm", predictions and possible standard errors are returned on the response scale. The standard errors come from the Delta method. Argument link is ignored whether ogg does not inherit from the class "glm".

See Also

segmented, predict.segmented, plot.segmented, vcov.segmented

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)
if (FALSE) plot(z,y)
if (FALSE) points(z,broken.line(o.seg,link=FALSE)$fit,col=2) #ok, but use plot.segmented()!
    

Run the code above in your browser using DataLab