pa_nested_case_control_weights: Nested case-control (NCC) sampling weights

View source: R/pa_nested_case_control_weights.R

pa_nested_case_control_weightsR Documentation

Nested case-control (NCC) sampling weights

Description

Computes inverse-selection weights for NCC designs. If 'strata' is provided, matched NCC weights are computed.

Usage

pa_nested_case_control_weights(time, status, strata = NULL, m = NULL)

Arguments

time

Numeric vector of follow-up times.

status

Numeric {0,1}, 1 = event, 0 = censored.

strata

Optional factor/character defining matching strata in the full phase-one cohort, not IDs of sampled case-control sets.

m

Positive integer, number of controls per case (required).

Details

Supply full-cohort follow-up and event information, not only sampled rows. Controls are sampled without replacement within each case's risk set and independently across cases. At tied failure times, all simultaneous cases are excluded from the eligible controls. Events precede censoring at ties. Matching restricts both cases and controls to the same stratum. If fewer than m controls are eligible, all eligible controls are sampled. A non-case with no sampling opportunity has infinite inverse probability; such a subject cannot belong to the sampled analysis dataset. Subset the returned weights to the subjects actually sampled and align their order with the prediction objects before evaluation.

Value

Numeric vector of weights, in full-cohort input order.

Examples

# Unmatched nested case-control design with m = 2 controls per case.
d <- pa_sim_cox_weibull(n = 150, pi_c = 0.3, v = 2,
                        beta = c(0.5, -0.5), seed = 2025)
set.seed(2025)
w <- pa_nested_case_control_weights(time = d$time, status = d$status, m = 2)
summary(w)

PAmeasures documentation built on Oct. 29, 2026, 1:08 a.m.