sgb_data: Create data for 'sgboost'

Description Usage Arguments Value Examples

View source: R/sgboost.R

Description

xgboost operates using a data structure called xgb.DMatrix. The xgboost functions can internally create these data structures if they are given a matrix with columns giving predictor variables and a vector representing the label. For survival analysis, the label vector is a combination of time/status values (see sgb_label). This function automates the creation of a label vector and creates a list of components that are easily plugged in to xgboost functions.

Usage

1
2
3
sgb_data(data, label)

as_sgb_data(data, status, time)

Arguments

data

the data containing predictor variables and a label column

label

a numeric vector based on time and status values. Time values should be less than zero for censored observations, and greater than zero for non-censored observations.

status

a numeric vector indicating status at a given time. Normally, 0 indicates no event and 1 indicates an event occurred.

time

a numeric vector of follow-up time values.

Value

an object of class sgb_data with components:

Examples

1
2
3
4
5
df = data.frame(time=c(1,2,3), status = c(0,0,1), x = c(2,2,1))

as_sgb_data(df, status = status, time = time)

sgb_data(df, label = sgb_label(df$time, df$status))

bcjaeger/xgboost.surv documentation built on Nov. 18, 2019, 6:43 a.m.