Function used to define a segmented (stepmented) term within the segreg (stepreg) formula. The function simply passes relevant information to proper fitter functions.
seg(x, npsi = 1, psi = NA, est = NA, R = NA, fixed.psi = NULL, by = NULL, f.x = I)
The function simply returns the covariate with added attributes relevant to segmented term
The segmented/stepmented (numeric) covariate
The number of breakpoints/jumpoints to estimate. Default to npsi=1
. If by
has been specified, the same npsi
applies to all categories of the factor by
; otherwise it can be vector, wherein the entries represent the number of breakpoints of the segmented relationships within the categories of by
. If npsi
is specified as a vector, the corresponding est
should be a list. The npsi
starting values are computed according the specification of quant
in seg.control
.
Numerical vector indicating possible starting value(s) for the breakpoint(s). When provided, psi
overwrites npsi
. If by
has been specified, psi
can be a list, wherein the components represent the starting values of the segmented/stepmented relationships within the categories of by
.
Possible vector (of length equal to npsi+1
) of 0's and 1's to indicate whether the slopes have to be estimated or fixed to zero. NA
, the default, means all ones, namely every slope is estimated. Consecutive zeroes are not allowed. If by
has been specified, the same est
applies to all categories of the factor by
; otherwise est
can be a list, wherein the components represent the slope constraints of the segmented relationships within the categories of by
. Note that, when a grouping variable has been specified in by
, npsi
can be specified as a vector, and est
should be a list.
Matrix to constrain the slopes. If provided, it overwrites the matrix (which is built internally) coming from the specification of est
.
Possible fixed breakpoint values to be accounted for in addition to the estimated ones; slope
and plot.segmented
will account for them correctly.
A possible factor meaning an interaction with the segmented term x
. Hence, if specified, a different segmented relationship is fitted within each category of by
.
an optional function meaning a function to apply to the covariate before fitting
Vito Muggeo
The function is used within segreg
and stepreg
to 'build' information about the segmented relationships to fit.
segreg