Slope estimates from segmented/stepmented relationships
slope.RdComputes the slopes of each `segmented' (or even `stepmented') relationship in the fitted model.
Arguments
- ogg
an object of class "segmented" or "segmented.lme", returned by any
segmentedmethod or a list of two segmented fits to compare the estimates of corresponding slopes.- 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. WhenTRUEit is assumed that the currentparmis `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.- APC
logical. If
APC=TRUEthe `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.- .vcov
The full covariance matrix of estimates. If unspecified (i.e.
NULL), the covariance matrix is computed internally byvcov(ogg).- .coef
The regression parameter estimates. If unspecified (i.e.
NULL), it is computed internally bycoef(ogg).- use.t
Which quantiles should be used to compute the confidence intervals? If
NULL(default) the \(t\) distribution is used only for objects obtained bysegmented.lm.- by
Only for
segmented.lmeobjects. It is a named list indicating covariate names and corresponding values affecting the fitted segmented relationship. For instance,by=list(group="2",z2=.2), provided that the model has been fitted by specifyinggroupandz2inx.diff(or as interaction with the segmented variable). Note that if the provided variables or values are irrelevant for changing the slopes, a warning message is printed.- interc
logical, only for
'stepmented'fits. IfTRUE, the mean levels also account for the intercept; otherwise the first level is assumed to be zero.- level
Numeric, only for
'segmented.lme'fits. If0, fixed effects left/right slopes are returned, otherwise the subject-specific values (with no confidence intervals).- ...
Further arguments to be passed on to
vcov.segmented, such asvar.diffandis. See Details invcov.segmentedandsummary.segmented.- digits
controls number of digits in the returned output.
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.
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.
References
Muggeo, V.M.R. (2003) Estimating regression models with unknown break-points. Statistics in Medicine 22, 3055–3071.
Author
Vito M. R. Muggeo, vito.muggeo@unipa.it
Note
The returned summary is based on limiting Gaussian distribution for the model parameters involved
in the computations. Sometimes, even with large sample sizes such approximations are questionable
(e.g., with small difference-in-slope parameters) and the results returned by slope
might be unreliable. Therefore is responsability of the user to gauge the applicability of such asymptotic
approximations. Anyway, the t values may be not assumed for testing purposes
and they should be used just as guidelines to assess the estimate uncertainty.
See also
See also davies.test and pscore.test to test for a nonzero difference-in-slope parameter.
Examples
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)
#> $x
#> Est. St.Err. t value CI(95%).l CI(95%).u
#> slope1 0.000000 NA NA NA NA
#> slope2 1.446900 0.048985 29.53900 1.35090 1.54290
#> slope3 0.014695 0.064403 0.22817 -0.11153 0.14092
#>
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)
#> $x
#> Est. St.Err. t value CI(95%).l CI(95%).u
#> slope1 -1.05430 0.26675 -3.9524 -1.583800 -0.5248
#> slope2 0.58006 0.26675 2.1746 0.050567 1.1096
#>
slope(oseg,var.diff=TRUE) #better CI
#> $x
#> Est. St.Err. t value CI(95%).l CI(95%).u
#> slope1 -1.05430 0.374500 -2.8152 -1.79770 -0.31092
#> slope2 0.58006 0.090817 6.3872 0.39979 0.76033
#>