| broken.line {segmented} | R Documentation |
Given a segmented model (typically returned by a segmented method), broken.line
computes the fitted values (and relevant standard errors) for each ‘segmented’ relationship.
broken.line(ogg, term = NULL, link = TRUE, interc=TRUE, se.fit=TRUE)
ogg |
A fitted object of class segmented (returned by any |
term |
Three options. A list (whose name should be one of the segmented covariates)
including values for which segmented predictions should be computed. A character meaning
the name of any segmented covariate in the model. |
link |
Should the predictions be computed on the scale of the link function? Default to |
interc |
Should the model intercept be added? (provided it exists). |
se.fit |
If |
If term=NULL or term is a valid segmented covariate name,
predictions for each 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 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".
A 2-component (if se.fit=TRUE) list representing predictions and standard errors for the segmented covariate values.
Vito M. R. Muggeo
segmented, predict.segmented, plot.segmented
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=.5)
## Not run: plot(z,y)
## Not run: points(z,broken.line(o.seg,link=FALSE)$fit,col=2) #just to illustrate, use plot.segmented