seg: Specifying a segmented term in the segreg formula

View source: R/seg.r

segR Documentation

Specifying a segmented term in the segreg formula

Description

Function used to define the segmented term within the segreg formula. The function simply passes relevant information to proper fitter functions.

Usage

seg(x, psi = NA, npsi = 1, est = NA, R = NA, fixed.psi = NULL, by = NULL, f.x = I)

Arguments

x

The segmented (numeric) covariate

psi

Possible starting value(s) for the breakpoint(s). If omitted, npsi has to be specified.

npsi

The number of breakpoints to estimate. Default npsi=1.

est

Possible vector (of length equal to npsi+1) of 0/1 to indicate whether the slopes have to be estimated of fixed to zero. If NA, default, means all ones, namely every slope has to be estimated. Consecutive zeroes are not allowed.

R

Matrix to constrain the slopes. If provided, it overwrites the matrix coming from the specification of est

fixed.psi

Possible fixed breakpoint values. These will be accounted for in addition to the estimated ones; slope and plot.segmented will account for them correctly.

by

A possible factor meaning an interaction with the segmented term. It means that a different segmented relationship is fitted within each category.

f.x

an optional function meaning a function to apply to the covariate before fitting

Details

The function is used within segreg to 'build' information about the segmented relationships to fit.

Value

The function simply returns the covariate with added attributes relevant to segmented term

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.

Author(s)

Vito Muggeo

See Also

segreg

Examples

##see ?segreg

segmented documentation built on Nov. 28, 2023, 1:07 a.m.