getIndex: Get index by specifying cut points

Description Usage Arguments Value See Also Examples

View source: R/getIndex.R

Description

Get index by specifying cut points. Assigns index 1 to lower than the first cut point, 2 to larger than the first cut point but lower than the second cut point, and so on. This function is intended to be used for time dependent covariate in Cox regression models to select covariate according to time point. In this case, cut points is a vector of time points, and index is used to select time-specific covariate.

Usage

1
2
getIndex(variable, cutpoints = NULL, toLowerCategory = TRUE,
  checkOrder = FALSE)

Arguments

variable

a numeric value or vector to be converted into index.

cutpoints

a numeric vector specifying cut point values.

toLowerCategory

a logical value specifying which to assign a cut point to lower category or upper category index. The default is assigning to lower category.

checkOrder

a logical value specifying whether to check the order of cut points. Checking the order is skipped by default.

Value

an index vector.

See Also

selectByIndex, epifit

Examples

1
2
3
4
# cutpoint   cp(1)  cp(2)  ...   cp(n-1)  cp(n)
# index    1   *   2  *    ... (n-1) *  (n) * (n+1)
a <- rnorm(100) * 10
b <- getIndex(a, cutpoints=c(-2,-1,0,1,2))

epifit documentation built on May 29, 2017, 3:43 p.m.