Specifying a segmented/stepmented term in the segreg/stepreg formula
seg.RdFunction used to define a segmented (stepmented) term within the segreg (stepreg) formula. The function simply passes relevant information to proper fitter functions.
Arguments
- x
The segmented/stepmented (numeric) covariate
- npsi
The number of breakpoints/jumpoints to estimate. Default to
npsi=1. Ifbyhas been specified andnpsiis a scalar, the samenpsiapplies to all categories of the factorby; otherwise it can be vector, wherein the entries represent the number of breakpoints of the segmented relationships within the categories ofby. Thenpsistarting values are computed according the specification ofquantinseg.control.- psi
Numerical vector indicating possible starting value(s) for the breakpoint(s). When provided,
psioverwritesnpsi. Ifbyhas been specified andpsiis a vector, the samepsiapplies to all categories of the factorby. Otherwisepsican be a list, wherein the components represent the starting values of the segmented/stepmented relationships within the categories ofby.- est
Possible vector (of length equal to
npsi+1) of 1's and 0'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 it is a vector andbyhas been specified, the sameestapplies to all categories of the factorby; otherwiseestcan be a list, wherein the components represent the slope constraints of the segmented relationships within the categories ofby.- R
Matrix to constrain the slopes. If provided, it overwrites the matrix (which is built internally) coming from the specification of
est. If matrix andbyhas been specified, the sameRapplies to all categories of the factorby; otherwiseRcan be a list, wherein the components represent the slope constraints of the segmented relationships within the categories ofby.- fixed.psi
Possible fixed breakpoint values to be accounted for in addition to those being estimated. If
byhas been specified andfixed.psiis a vector, the samefixed.psiapplies to all categories of the factorby. Otherwisefixed.psican be a list, wherein the components refer to the segmented relationship within the levels ofby.slopeandplot.segmentedwill account for them correctly.- by
A possible factor meaning an interaction with the segmented term
x. Hence, if specified, a different segmented relationship is fitted within each category ofby.- f.x
an optional function meaning a function to apply to the covariate before fitting.
Details
The function is used within segreg and stepreg to 'build' information about the segmented relationships to fit.
Note that, when a grouping variable has been specified in by, npsi can be specified as a vector, and est, if specified, should be a list.
Note
If any value is provided in fix.psi, the corresponding slope difference coefficient will be labelled by *.fixed.*. The slope function will compute the 'right' slopes also accounting for the fixed breakpoints.