Learn R Programming

segmented (version 0.5-2.1)

slope: Slope estimates from segmented relationships

Description

Computes the slopes of each `segmented' relationship in the fitted model.

Usage

slope(ogg, parm, conf.level = 0.95, rev.sgn=FALSE, 
    var.diff=FALSE, APC=FALSE, digits = max(3, getOption("digits") - 3))

Arguments

ogg

an object of class "segmented", returned by any segmented method.

parm

the segmented variable whose slopes have to be computed. If missing all the segmented variables are considered.

conf.level

the confidence level required.

rev.sgn

vector of logicals. The length should be equal to the length of parm, but it is recycled otherwise. When TRUE it is assumed that the current parm is `minus' the actual segmented variable, therefore the sign is reversed before printing. This is useful when a null-constraint has been set on the last slope.

var.diff

logical. If var.diff=TRUE and there is a single segmented variable, the computed standard errors are based on a sandwich-type formula of the covariance matrix. See Details in summary.segmented.

APC

logical. If APC=TRUE the `annual percent changes', i.e. \(100\times(\exp(\beta)-1)\), are computed for each interval (\(\beta\) is the slope). Only point estimates and confidence intervals are returned.

digits

controls number of digits printed in output.

Value

slope returns a list of matrices. Each matrix represents a segmented relationship and its number of rows equal to the number of segments, while five columns summarize the results.

Details

To fit broken-line relationships, segmented uses a parameterization whose coefficients are not the slopes. Therefore given an object "segmented", slope computes point estimates, standard errors, t-values and confidence intervals of the slopes of each segmented relationship in the fitted model.

References

Muggeo, V.M.R. (2003) Estimating regression models with unknown break-points. Statistics in Medicine 22, 3055--3071.

See Also

See also davies.test and pscore.test to test for a nonzero difference-in-slope parameter.

Examples

Run this code
set.seed(16)
x<-1:100
y<-2+1.5*pmax(x-35,0)-1.5*pmax(x-70,0)+rnorm(100,0,3)
out<-glm(y~1)
out.seg<-segmented(out,seg.Z=~x,psi=list(x=c(20,80)))
## the slopes of the three segments....
slope(out.seg)
rm(x,y,out,out.seg)
#
## an heteroscedastic example..
set.seed(123)
n<-100
x<-1:n/n
y<- -x+1.5*pmax(x-.5,0)+rnorm(n,0,1)*ifelse(x<=.5,.4,.1)
o<-lm(y~x)
oseg<-segmented(o,seg.Z=~x,psi=.6)
slope(oseg)
slope(oseg,var.diff=TRUE) #better CI

Run the code above in your browser using DataLab