cmprsk cumulative incidence - comparing between two curve with different outomes I have a question regarding the extracting p-values from the cumulative incidence curves that considered competing risks.
I used cmprsk packages and cuminc function to draw the curves, and
below is the code that I used.
library(cmprsk)
CI.overall <- cuminc(ftime = dt$futime, 
     fstatus = dt$competingrisks)
    CI.overall
plot(CI.overall, curvlab = c("event1", "event2"), 
         main= "cumulative incidence", xlab = "Time(years)", 
         ylab = "probability", xlim=c(0,4), ylim=c(0,0.08), 
         cex=0.8, lty=c(1,2,0))

variables explanation:
competingrisks consists of 0:alive,1:event1,2:event2,3:death
(1,2,3 is considered competing risks each other)
The results showed a graph with 3 curves,
one curve is for the outcome 1(event1),
other curve is for the outcome 2(event2),
and the last one is for the death.

and my question is, are there any methods to compare between event1 curve and event2 curve2 and determine a p-value for their being statistically different?
I already know how to compare between 2 groups,for example like sex group, and extract pvalue using code.
CI.sex <- cuminc(ftime = dt$futime, fstatus=dt$competingrisks, 
              group=dt$sex)
    
plot(CI.sex, lty = c(1, 1, 2, 2, 3, 3), col = c("black", 
         "blue", "black", "blue", "black", "blue"), 
         curvlab = c("male, event1", "female, event1", "male, event2", 
                     "female,event2", "male,death", "female,death"),  
         xlab = "Days")
    
CI.sex$Tests


So,once again, I want to compare between event1 curve and event2 curve2 and extract p-value, and I think it is different from comparing between the 2 groups.
In other words, I want to determine whether the cumulative incidence function for event1 differs from that for event2, and just the simple competing-risks model without covariates.
 A: Just a few suggestions as a start, as there are gaps in my understanding of competing risks. I hope that someone with more expertise can provide a more complete answer. In the meantime, this should point you toward the issues that need to be addressed in further study.
The cumulative incidence curves for competing event types aren't independent. A change in the risk of one event type necessarily affects the risks of the other types. In contrast, when you compare cumulative incidence curves for the same event type across 2 or more groups, you assume that the groups are independent. Independence among groups is a fundamental assumption of Gray's method for that latter type of comparison, which as you note is the statistical comparison implemented in his cmprsk package.
I don't know whether there is a way to do the comparison that you wish over the entire length of the curve and get a p-value for the overall comparison among event types.
You can get estimated cumulative incidences and variances for each event type at specified times from your CI.overall object, via the timepoints() function in the cmprsk package. In general, you can evaluate the significance of a difference $Y-X$ by considering the variance of the difference, $\text{Var}(X) + \text{Var}(Y) - 2\text{Cov}(XY)$.
In the case of cumulative incidence curves of different types $X$ and $Y$, the lack of independence between the curves means that you might not be able to assume that $\text{Cov}(XY)=0$. My sense is that $\text{Cov}(XY) \le 0$, as an increase in the incidence of one event type should tend to decrease that of other event types, but I can't offer a formal proof. If I'm correct, then $\text{Var}(X) + \text{Var}(Y)$ is a lower limit to the variance of the difference between the curves at a time point. In that case, if the incidences at a time point can't be distinguished based on $\text{Var}(X) + \text{Var}(Y)$ then they certainly wouldn't be based on the correct variance of their difference.
You can plot confidence intervals around the cumulative incidence curves. That doesn't seem possible directly with the cmprsk package, but its timepoints() function allows you to get cumulative incidence and variance estimates for any times that you choose for each of the event types. You could use those estimates to construct plots with confidence intervals yourself. Alternatively, you could use the survival or mstate packages for such plots.
I suspect that, in your example, the point estimates for each of event1 and event2 will be well within the confidence interval of the other competing event. That would argue against a difference in their cumulative incidence curves.
One alternative that could work more generally is repeated modeling on multiple bootstrapped samples of the data. Define a statistic that defines the difference between the curves, and calculate it from models on several hundred bootstrapped samples of the data. That can give confidence intervals for the difference between the curves based on your statistic; if 0 is outside the confidence interval, then you can say the curves are different at that level of confidence. Getting a corresponding p-value for the difference from a null hypothesis is tricky, but you don't really need one.
Another thing that comes to mind is to model with multiple random permutations of the labels for event1 and event2, to get a null distribution for your difference statistic when there is no true difference between the events. Then see where along that null distribution your value from the original model sits. That should provide a p-value with respect to the null hypothesis of no difference. I'm not completely sure, however, that permutation adequately provides a null distribution with competing risks.
