find_at_risk | R Documentation |
This function calculates the number of individuals at risk and number of events at each distinct event time
(and censoring time if include_cens==TRUE
).
find_at_risk(formula, data, include_cens = TRUE, timefix = TRUE)
formula |
Formula object. The response (on the left of the |
data |
Data frame containing time-to-event data. |
include_cens |
Boolean indicating whether to include values corresponding to censoring times |
timefix |
Deal with floating point issues (as in the survival package). Default is TRUE. May need to set FALSE for simulated data. |
Data frame
Returns a data frame with the following columns:
time t_j
number of events in each of the treatments at t_j
combined number of events in both treatments at event time t_j
number of individuals at risk in each of the treatment groups just before time t_j
combined number of individuals at risk in both treatment groups just before time t_j
library(nphRCT)
set.seed(1)
sim_data <- sim_events_delay(
event_model=list(
duration_c = 36,
duration_e = c(6,30),
lambda_c = log(2)/9,
lambda_e = c(log(2)/9,log(2)/18)
),
recruitment_model=list(
rec_model="power",
rec_period = 12,
rec_power = 1
),
n_c=5,
n_e=5,
max_cal_t = 36
)
#with censoring times included
find_at_risk(formula=survival::Surv(event_time,event_status)~group,
data=sim_data,
include_cens=TRUE)
#with censoring times excluded
find_at_risk(formula=survival::Surv(event_time,event_status)~group,
data=sim_data,
include_cens=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.