get_covariates: get_covariates

View source: R/TSDT_helper_functions.R

get_covariatesR Documentation

get_covariates

Description

Returns the covariate variables in the in-bag or out-of-bag data.

Usage

get_covariates(data, scoring_function_parameters)

Arguments

data

A data.frame containing in-bag or out-of-bag data

scoring_function_parameters

A list of named elements containing control parameters and other data required by the scoring function

Details

If the user provides a covariate_vars parameter in the list of scoring_function_parameters this function will return the variables specified by that parameter. If the user specifies a covariate_cols parameter in the list of scoring_function_parameters the function returns the columns in data indexed by that parameter. Otherwise, NULL is returned.

Value

A data.frame of covariates.

See Also

get_y, get_trt

Examples

## Create an example data.frame
df <- data.frame( y <- 1:5 )
names( df ) <- "y"
df$time <- 10:14
df$time2 <- 20:24
df$event <- sample( c(0:1), size = 5, replace = TRUE )
df$trt <- sample( c("Control","Treatment"), size = 5, replace = TRUE )
df$x1 <- runif( n = 5 )
df$x2 <- LETTERS[1:5]

## Select the covariate variables by name
get_covariates( df, scoring_function_parameters = list( covariate_vars = c("x1","x2") ) )

## Select the covariate variables by column index
get_covariates( df, scoring_function_parameters = list( covariate_cols = c(6:7) ) )

TSDT documentation built on April 7, 2022, 1:07 a.m.

Related to get_covariates in TSDT...