Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Competing Risk models #16

Open
andrewsris opened this issue Mar 19, 2021 · 0 comments
Open

Support for Competing Risk models #16

andrewsris opened this issue Mar 19, 2021 · 0 comments

Comments

@andrewsris
Copy link

Hello,

I am very excited to see the tidymodels implementation of survival analysis. I am currently utilizing competing risk models in my research, and wanted to advocate for their implementation in the tidymodels framework in the future (But given their complexity, I imagine it would be low priority at this time).

The models of interest would be the Fine-Gray model (similar to the Cox Proportional hazards model) as well as the Cumulative Incidence function (similar to the Kaplan-Meier)

Competing risk dataset

As an example, we can use the MGUS2 dataset from the survival package, where patients with the disease MGUS have the potential to transform into a Plasma Cell Malignancy (PCM), but are also at risk for death. We will do imputation to get rid of all NA values.

library(tidyverse)
library(survival)
library(mice)

data(cancer, package="survival")

imputed_mgus2 <- mgus2 %>% 
  mutate(etime = ifelse(pstat==0, futime, ptime),
         event = ifelse(pstat==0, 2*death, 1)) %>% #0 = censor, 1 = Plasma cell malignancy, 2 = death as a competing risk
mice(maxit = 2, m = 2, seed = 1, method = "cart") %>% 
  complete()

mgus2_split <- imputed_mgus2 %>% initial_split(prop = 0.99) 
train_dat <- mgus2_split %>% training()
test_pred <- mgus2_split %>% testing()

Fine-Gray Models

cmprsk:::crr

The model fitting function:

library(cmprsk)
fit_mgus_crr <- cmprsk::crr(ftime = train_dat$etime, fstatus = train_dat$event, 
            cov1 = data.matrix(train_dat[,c("sex", "hgb")]), 
            cencode = 0, failcode = 1, variance = TRUE)

Per the documentation, The predict function "returns a matrix with the unique type 1 failure times in the first column, and the other columnsgiving the estimated subdistribution function corresponding to the covariate combinations in the
rows of cov1 and cov2, at each failure time (the value that the estimate jumps to at that failure
time)."

fit_mgus_crr %>% predict(cov1 = data.matrix(test_pred[,c("sex", "hgb")]))

In addition, there is a tidier in the broom package for crr objects.

References: Subdistribution Analysis of Competing Risks (pdf)

crrp:::crrp

This package is useful for penalized Fine-Gray models, using LASSO, SCAD, MCP, and their group versions.

The model fitting function:

library(crrp)
fit_mgus_crrp <- crrp(time = train_dat$etime,
     fstatus = train_dat$event,
     X = as.matrix(cbind(train_dat$hgb, train_dat$creat)), 
     failcode = 1, cencode = 0, penalty = "LASSO", 
     lambda = 0.01, eps = 1E-6)

Unfortunately, there is no predict function, and the output from the crrp() function does not include convenient parameters such as a P value. There are standard errors, so a P value can be manually calculated. Creating a tidy wrapper may be difficult. In addition, this package has not been maintained since its first commit in 2015.

References: Penalized Variable Selection in Competing Risks Regression (pdf)

fastcmprsk:::fastCrr

The fastcmprsk uses a wrapper in C to do the same unregularized and regularized Fine-Gray models, similar to above. However the implementation uses a novel algorithm that is much faster than the above.

The model fitting function:

library(fastcmprsk)
fit_mgus_fastcrrp <- fastCrrp(Crisk(ftime = etime,
                                    fstatus = event,
                                    cencode = 0, failcode = 1) ~ hgb + creat, 
                              lambda = 0.01, penalty = "LASSO",
                              data = train_dat)

Per documentation, the predict function calculates the cumulative incidence function.

fit_mgus_fastcrr %>% predict(train_dat %>% select(sex, hgb))

Though there is no tidy wrapper for the fcrr objects, the output is almost equivalent to the above crr objects, and making a wrapper would be simple.

References: Fine-Gray Regression via Forward-Backward Scan (pdf)

fastcmprsk:::fastCrrp

This is the faster implementation of penalized Fine-Gray models, similar to the crrp package.

The model fitting function:

fit_mgus_crrp <- crrp(time = train_dat$etime,
     fstatus = train_dat$event,
     X = as.matrix(cbind(train_dat$hgb, train_dat$creat)), 
     failcode = 1, cencode = 0, penalty = "LASSO", 
     lambda = 0.01, eps = 1E-6)

Unfortunately, there also is no predict function assocated with the fcrrp objects. In addition, there is no summary() function, so making a tidy wrapper would also be difficult.

References: Fine-Gray Regression via Forward-Backward Scan (pdf)

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

No branches or pull requests

2 participants