segmented.lm
or segmented.glm
).seg.control(toll = 1e-04, it.max = 10, display = FALSE, stop.if.error = TRUE,
K = 10, quant = FALSE, last = TRUE, maxit.glm = 25, h = 1,
n.boot=20, size.boot=NULL, gap=FALSE, jt=FALSE, nonParam=TRUE,
random=TRUE, powers=c(1,1), seed=NULL, fn.obj=NULL)
FALSE
if you want to perform a sort of
`automatic' breakpoint selection, provided that several starting values are provipsi
argument of segmented
is set to NA
.
K
is ignored when psi
is diffFALSE
equally-spaced
values are used, otherwise the quantiles. Ignored when psi
is different from NA
.NULL
, it is taken equal to the actual sample size.FALSE
the gap coefficients are always constrained to zero at the convergence.TRUE
the values of the segmented variable(s) are jittered before fitting the model to the
bootstrap resamples.TRUE
nonparametric bootstrap (i.e. case-resampling) is used, otherwise residual-based.
Currently working only for LM fits. It is not clear what residuals should be used for GLMs.TRUE
, when the algorithm fails to obtain a solution, random values are employed to obtain candidate values.set.seed()
when n.boot>0
. Setting the seed can be useful to replicate
the results when the bootstrap restart algorithm is employed. In fact a segmented fit includes seed
representing
segmented.default
is used. It represents the function
(with argument 'x'
) to be applied to the fit object to extract the objective function to be minimizedit.max
, while the (maximum) number of (inner) iterations to fit the GLM at
each fixed value of psi is fixed via maxit.glm
. Usually three-four inner iterations may be sufficient.
When the starting value for the breakpoints is set to NA
for any segmented variable specified
in seg.Z
, K
values (quantiles or equally-spaced) are selected as starting values for the breakpoints.
In this case, it may be useful to set also stop.if.error=FALSE
to automate the procedure, see Muggeo and Adelfio (2011).
The maximum number of iterations (it.max
) should be also increased when the `automatic' procedure is used.
If last=TRUE
, the object resulting from segmented.lm
(or segmented.glm
) is a
list of fitted GLM; the i-th model is the segmented model with the values of the breakpoints at the i-th iteration.
Sometimes to stabilize the procedure, it can be useful to set h<1< code=""> to reduce the increments in the breakpoint
updates. At each
iteration the updated estimate is usually given by psi.new=psi.old+increm
. By setting h<1< code="">
(actually min(abs(h),1)
is considered) causes the following updates of the breakpoint estimate:
psi.new=psi.old+h*increm
.
Since version 0.2-9.0 segmented
implements the bootstrap restarting algorithm described in Wood (2001).
The bootstrap restarting is expected to escape the local optima of the objective function when the
segmented relationship is flat. Notice bootstrap restart runs n.boot
iterations regardless of
toll
that only affects convergence within the inner loop.1<>
1<>
#decrease the maximum number inner iterations and display the
#evolution of the (outer) iterations
seg.control(display = TRUE, maxit.glm=4)
Run the code above in your browser using DataLab