slope | R Documentation |
Computes the slopes of each ‘segmented’ (or even ‘stepmented’) relationship in the fitted model.
slope(ogg, parm, conf.level = 0.95, rev.sgn=FALSE,
APC=FALSE, .vcov=NULL, .coef=NULL, use.t=NULL, by=NULL,
interc=TRUE, level=0, ..., digits = max(4, getOption("digits") - 2))
ogg |
an object of class "segmented" or "segmented.lme", returned by any |
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 |
APC |
logical. If |
.vcov |
The full covariance matrix of estimates. If unspecified (i.e. |
.coef |
The regression parameter estimates. If unspecified (i.e. |
use.t |
Which quantiles should be used to compute the confidence intervals? If |
by |
Only for |
interc |
logical, only for |
level |
Numeric, only for |
... |
Further arguments to be passed on to |
digits |
controls number of digits in the returned output. |
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.
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.
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.
Vito M. R. Muggeo, vito.muggeo@unipa.it
Muggeo, V.M.R. (2003) Estimating regression models with unknown break-points. Statistics in Medicine 22, 3055–3071.
See also davies.test
and pscore.test
to test for a nonzero difference-in-slope parameter.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.