compute_kmw_ncc: <Private function> Compute KM-type weight for NCC sample...

View source: R/km_type_weights.R

compute_kmw_nccR Documentation

<Private function> Compute KM-type weight for NCC sample given information on underlying cohort

Description

<Private function> Compute KM-type weight for NCC sample given information on underlying cohort

Usage

compute_kmw_ncc(
  ncc,
  id_name,
  risk_table_manual,
  t_start_name = NULL,
  t_name,
  t_match_name = t_name,
  y_name,
  match_var_names = NULL,
  n_per_case,
  return_risk_table = FALSE,
  km_names = c(".km_prob", ".km_weight")
)

Arguments

ncc

NCC data. A data.frame or a matrix with column names. This data should not include the ID of each matched set, but should include the actual event/censoring time of each subject.

id_name

Name of the column of the subject ID. A string.

risk_table_manual

A data.frame with columns t_event (unique event times, possibly coarsened), n_at_risk (number of subjects at risk at each t_event in the underlying cohort), and additional columns for matching variables, if any. Make sure the matching variables have the same column names as in ncc_cases and match_var_names.

t_start_name

Name of the column 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 column of the exact event/censoring time of each subject. Note that for controls, this should not be the time of the event in the same matched set. A string.

t_match_name

Name of the column of event time in each matched set in ncc, possibly coarsened to the same level as t_event in risk_table_manual. A string. Default is t_name, i.e., not coarsened.

y_name

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

match_var_names

Name(s) of the match variable(s) in ncc_cases used when drawing the NCC. A string vector.

n_per_case

Number of controls matched to each case.

return_risk_table

Whether the risk table should be returned. Default is FALSE.

km_names

Column names for the KM-type probability (the first element) and weight (the second element) computed, if these two columns are to be attached to each subject in the input data. Default is c(".km_prob", ".km_weight").

Value

If return_risk_table = FALSE (the default), returns a data.frame containing all the unique subjects selected in the NCC sample, with a column for the KM-type weight associated with each subject. If return_risk_table = TRUE, returns a list containing this subcohort (dat) and the risk table (risk_table), which is a data.frame containing the distinct (and exact) event time (t_event), matching variables (if any), and the number of subject at risk at each event time in each strata defined by matching variables (n_at_risk).


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