compute_risk_table: Compute number at risk at each event time from a "skeleton...

View source: R/km_type_weights.R

compute_risk_tableR Documentation

Compute number at risk at each event time from a "skeleton cohort"

Description

Compute number at risk at each event time from a "skeleton cohort"

Usage

compute_risk_table(
  cohort,
  t_start_name = NULL,
  t_name,
  y_name,
  match_var_names = NULL
)

Arguments

cohort

Cohort data with at least the following information on each subject: start time (if not 0 for all subjects) and end time of follow-up, censoring status and matching variables (if any). A data.frame or a matrix with column names.

t_start_name

Name of the variable in cohort for the start time of follow-up. A string. Default is NULL, i.e., every subject started the follow-up at time 0.

t_name

Name of the variable in cohort for the event or censoring time. A string.

y_name

Name of the column of censoring status in each matched set in cohort, with 1 for event and 0 for censoring. A string.

match_var_names

Name(s) of the match variable(s) in cohort used when drawing the NCC. A string vector. Default is NULL, i.e., the NCC was only time-matched.

Value

Returns a data.frame with the following columns:

t_event

Unique event times in cohort_skeleton.

n_event

Number of events at each event time.

n_at_risk

Number of subjects at risk at each event time.

<each matching variable>

If the NCC is matched on additional confounders, each matching variable will be included as a column to the right of strata.

See Also

compute_km_weights

Examples

library(SamplingDesignTools)
# With common entry time:
data("mini_cohort")
mini_cohort
compute_risk_table(cohort = mini_cohort, t_name = "t", y_name = "status")
# With staggered entry time:
data("mini_cohort2")
mini_cohort2
compute_risk_table(cohort = mini_cohort2, t_start_name = "t_start", 
                   t_name = "t_end", y_name = "status")

nyilin/SamplingDesignTools documentation built on Nov. 20, 2022, 8:07 a.m.