Author: Bilal Ahmad

# Competing Risks with the Beta-Danish Distribution

#### Bilal Ahmad

## Overview

Under independent latent failure times, the joint competing-risks likelihood factorises into one Beta-Danish marginal per cause. This vignette demonstrates fitting and diagnostic plotting.

If `cmprsk` is not installed, code chunks below are skipped.

## Simulated two-cause data

    library(BetaDanish)
    set.seed(2026)
    n  <- 400
    T1 <- rbetadanish(n, a = 1.2, b = 1.5, c = 1.0, k = 0.4)
    T2 <- rbetadanish(n, a = 1.0, b = 2.0, c = 1.0, k = 0.2)
    C  <- stats::rexp(n, 0.05)
    time  <- pmin(T1, T2, C)
    cause <- ifelse(time == C, 0L, ifelse(T1 <= T2, 1L, 2L))
    table(cause)
    #> cause
    #>   0   1   2
    #>  23 198 179

## Fitting the model

    fit <- fit_bd_competing(time = time, cause = cause)
    print(fit)
    #>
    #> Call:
    #> fit_bd_competing(time = time, cause = cause)
    #>
    #> Beta-Danish Competing Risks Model
    #> Log-Likelihood: -797.6231
    #>
    #> Coefficients:
    #>               a       b      c      k
    #> Cause_1 91.3660 34.1222 0.0371 0.0001
    #> Cause_2 10.9922  2.1813 0.1069 0.1313

## CIF comparison: Beta-Danish vs Aalen-Johansen

    res <- cif_compare(fit, plot = TRUE)

## Gray’s test

    if (!is.null(res$gray_test)) {
      print(res$gray_test)
    } else {
      cat("Gray's test was not produced.\n")
    }
    #> Gray's test was not produced.