sahirbhatnagar/casebase

Confidence bands for absolute risks in competing-risk setting

turgeonmaxime opened this issue · 6 comments

In the most recent version of casebase (v.0.10.1), we introduced confidence bands for absolute risks in the single-event setting. Our approach is based on approximate Bayesian inference, and its validity relies on the asymptotic normality of the case-base estimator.

The same approach is valid for competing risks, as will be shown in an upcoming paper. We should implement it in the package. I expect the implementation to be similar to the single-event setting.

Minor point: at the same time, we can make sure that the user can pass the arguments from absRisk to confint. For example, method = "montecarlo".

In the most recent version of casebase (v.0.10.3), I calculate confidence bands for absolute risks in the single-event setting.But the function"confint.absRiskCB" cannot be found. I just want to know how to calculate confidence bands for absolute risks in r package casebase.Thank you

@hejunhuicomeon Can you please provide a minimal reproducible example? Because for me the confint functions works as expected.

library(casebase)
#> See example usage at http://sahirbhatnagar.com/casebase/
library(survival)

fit <- fitSmoothHazard(DeadOfPrCa ~ pspline(Follow.Up.Time, df = 2) * ScrArm, 
                       data = ERSPC, ratio = 10)
#> 'Follow.Up.Time' will be used as the time variable

new_data <- data.frame(ScrArm = c("Control group", 
                                  "Screening group"))
new_time <- seq(0, 14, by = 0.1)
risk <- absoluteRisk(fit, time = new_time, 
                     newdata = new_data)

conf_ints <- confint(risk, fit)
head(conf_ints)
#>   time     estimate     conf.low    conf.high      cov_prof
#> 1  0.0 0.000000e+00 0.000000e+00 0.000000e+00 Control group
#> 2  0.1 2.550557e-06 3.751504e-07 1.528747e-05 Control group
#> 3  0.2 5.185857e-06 8.319090e-07 2.758015e-05 Control group
#> 4  0.3 7.933361e-06 1.458696e-06 3.787632e-05 Control group
#> 5  0.4 1.082208e-05 2.282062e-06 4.620604e-05 Control group
#> 6  0.5 1.388317e-05 3.343530e-06 5.463520e-05 Control group

Created on 2023-08-03 with reprex v2.0.2

@turgeonmaxime Thank you sooooo much for your patient response.

  1. The reason I couldn't calculate the confidence interval for absolute risk yesterday was that I used "confint.absRiskCB" function which does not exist in the casebase package. The correct approach is to use the "confint" function.
    image

  2. Based on the R package casebase documentation and the example code you provided, I recalculated the absolute risk. However, I am not entirely sure about the definition of the 'newdata' parameter in the 'absoluteRisk' function. My understanding is that the 'newdata' is used to define the population for which we want to predict the absolute risk. I would like to explain the issues I have encountered based on my current doctoral research project. I am using a matched cohort study to investigate the relationship between cancer and mental disorders. I want to calculate the time-varying absolute risk separately for the exposed group(Exposure variable: interest, level==1) and the control group (Exposure variable: interest, level==0).
    The codes are as follows:
    Event: event_psy
    Time: anypsy_time
    Exposure variable: interest
    Covariates: age at index date, sex, calendar period, education
    Data: m.sample
    First: there is something wrong about new_data!
    image

Second : It works ! The reason for my mistake is that other covariates were included in the model when calculating the absolute risk for the exposed group and the control group.
image

  1. In addition, I would like to confirm that the "newdata" parameter in the "fitSmoothHazard" function is used to define the reference group on which the model will be fitted.
    image
    On the other hand, in the "absoluteRisk" function, the "newdata" parameter is used to define the population for which you want to calculate the absolute risk.
    image

Is there something wrong in my understanding ? Thank you for taking the time to read and answer my questions.

I contacted you by email several month ago to confirm that the casebase package cannot calculate hazard ratios varying over time by establishing a competing risk model. But I want to conduct a competing risk model to calculate absolute risk and 95%CI. I wrote codes as follows, but the function" confint" has an error, I would like to ask if you have encountered this problem in the previous test? Thank you so much, looking forward to your reply.
image

@hejunhuicomeon

  1. Technically, confint.absRiskCB exists and is part of the package, but it's not exported to the namespace. But I can see now that we could improve the documentation to avoid confusion.
  2. The newdata argument is simply a way to specify the dataset for which the absolute risk (or more accurately, cumulative incidence) will be computed. It is often the case that newdata will be the same dataset you used to fit the model in fitSmoothHazard, but we provided the extra flexibility, in line with the basic glm functions that most people are familiar with. As you found out, it's important to have all the relevant columns in newdata, otherwise you will get an error.
  3. The function fitSmoothHazard doesn't have a newdata argument, just data. The latter is to specify the dataset that will be used to fit the hazard function/survival model.

Finally, we don't currently support confidence bands for absolute risks computed using a competing risk model. It is on our roadmap to eventually support it, but we don't have a clear timeline yet.

@turgeonmaxime I understand, thank you so much for your patient response!