Selecting number of breakpoints in segmented regression
This function selects the number of breakpoints of the segmented relationship according to the BIC criterion or sequential hypothesis testing.
selgmented(olm, seg.Z, alpha = 0.05, type = c("score", "davies", "bic"), control = seg.control(), return.fit = TRUE, bonferroni = FALSE, Kmax = 2, msg=TRUE)
olm |
A starting |
seg.Z |
A one-side formula for the segmented variable. Only one term can be included, and it can be omitted if |
alpha |
The fixed type I error probability. |
type |
Which criterion should be used? Currently via sequential hypothesis testing |
control |
See |
return.fit |
If |
bonferroni |
If |
Kmax |
The maximum number of breakpoints being tested. If |
msg |
If |
The function uses properly the functions segmented
, pscore.test
or davies.test
to select the 'right' number
of breakpoints.
The returned object depends on argument return.fit
. If FALSE
, the returned object is a list with some information on the compared models (i.e. the BIC values), otherwise a classical segmented object with the component selection.psi
including the aforemntioned information. See segmented
for details.
This is a sperimental function. Please use that with caution.
Vito Muggeo
Muggeo V (2020) Selecting number of breakpoints in segmented regression: implementation in the R package segmented https://www.researchgate.net/publication/343737604
## from ?segmented ## Not run: set.seed(12) xx<-1:100 zz<-runif(100) yy<-2+1.5*pmax(xx-35,0)-1.5*pmax(xx-70,0)+15*pmax(zz-.5,0)+rnorm(100,0,2) dati<-data.frame(x=xx,y=yy,z=zz) out.lm<-lm(y~x,data=dati) os<-selgmented(out.lm) ## selects number of breakpoints via the Score test os <-selgmented(out.lm, Kmax=3, type="bic") #BIC-based selection ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.