Skip to content

Odach cc support left truncated surv input#13

Open
afarnudi wants to merge 11 commits into
Penncil:masterfrom
afarnudi:ODACH_CC_support_left_truncated_Surv_input
Open

Odach cc support left truncated surv input#13
afarnudi wants to merge 11 commits into
Penncil:masterfrom
afarnudi:ODACH_CC_support_left_truncated_Surv_input

Conversation

@afarnudi
Copy link
Copy Markdown

Adds Support for Three-Column Survival Input in ODACH-CC

This merge request introduces support for three-column survival inputs of the form:

survival::Surv(t_start, t_stop, status)

Key Changes

1. R/pda.R

The construction of ipdata is now determined by the number of columns in the response object.
If three columns are detected, the function extracts (t_start, t_stop, status); otherwise it falls back to the existing two-column (time, status) structure.

if (!is.null(ipdata)) {
    if (ncol(model.response(mf)) == 3) {
        ipdata <- data.table::data.table(
            time_in  = as.numeric(model.response(mf)[, 1]),
            time     = as.numeric(model.response(mf)[, 2]),
            status   = as.numeric(model.response(mf)[, 3]),
            subcohort = ipdata$subcohort,
            model.matrix(formula, mf)[, -1]
        )
    } else if (ncol(model.response(mf)) == 2) {
        ipdata <- data.table::data.table(
            time     = as.numeric(model.response(mf))[1:n],
            status   = as.numeric(model.response(mf))[-c(1:n)],
            subcohort = ipdata$subcohort,
            model.matrix(formula, mf)[, -1]
        )
    }
}

2. R/ODACH-CC.R

In both ODACH_CC.initialize() and ODACH_CC.derive():

  • The col_deg variable is updated to reflect whether the response contains two or three columns.
  • Adjustments to ipdata related to Prentice weighting are revised accordingly.

3. R/case_cohort.R

prepare_case_cohort() now uses the model control to retrieve the response, ensuring that the correct covariate_list is extracted for both two- and three-column survival inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant