dynamichazard (version 0.6.3)

get_risk_obj: Risk Set on an Equidistant Distant Grid

Description

Get the risk set at each bin over an equidistant distant grid.

Usage

get_risk_obj(Y, by, max_T, id, is_for_discrete_model = T,
  n_threads = 1, min_chunk = 5000)

Arguments

Y

vector of outcome variable returned from Surv.

by

length of each bin.

max_T

last observed time.

id

vector with ids where entries match with outcomes Y.

is_for_discrete_model

TRUE if the model outcome is discrete. For example, a logit model is discrete whereas what is is referred to as the exponential model in this package is a dynamic model.

n_threads

set to a value greater than one to use mclapply to find the risk object.

min_chunk

minimum chunk size of ids to use when parallel version is used.

Value

a list with the following elements

risk_sets

list of lists with one for each bin. Each of the sub lists have indices that corresponds to the entries of Y that are at risk in the bin.

min_start

start time of the first bin.

I_len

length of each bin.

d

number of bins.

is_event_in

indices for which bin an observation Y is an event. -1 if the individual does not die in any of the bins.

is_for_discrete_model

value of is_for_discrete_model argument.

Examples

Run this code
# NOT RUN {
# small toy example with time-varying covariates
dat <- data.frame(
 id     = c(1, 1, 2, 2),
 tstart = c(0, 4, 0, 2),
 tstop  = c(4, 6, 2, 4),
 event  = c(0, 1, 0, 0))

with(dat, get_risk_obj(Surv(tstart, tstop, event), by = 1, max_T = 6, id = id))

# }

Run the code above in your browser using DataCamp Workspace