# A Case Study Using the Beta-Danish Distribution

# Introduction

This vignette demonstrates a typical survival analysis workflow using the BetaDanish package.

    library(BetaDanish)
    #> BetaDanish 0.1.0: see ?BetaDanish for help.
    library(survival)
    #> Warning: package 'survival' was built under R version 4.5.3
    #>
    #> Attaching package: 'survival'
    #> The following objects are masked from 'package:BetaDanish':
    #>
    #>     leukemia, transplant
    data('remission', package = 'BetaDanish')
    head(remission)
    #>   time status
    #> 1 0.08      1
    #> 2 2.09      1
    #> 3 3.48      1
    #> 4 4.87      1
    #> 5 6.94      1
    #> 6 8.66      1

# Fitting the Beta-Danish model

    fit <- fit_betadanish(Surv(time, status) ~ 1, data = remission, n_starts = 1)
    #> Warning in dbetadanish(time, a_par, b_par, c_par, k_par, log = TRUE):
    #> Parameters a, b, c, and k must be strictly positive.
    summary(fit)
    #>
    #> Call:
    #> fit_betadanish(formula = Surv(time, status) ~ 1, data = remission,
    #>     n_starts = 1)
    #>
    #> Beta-Danish Distribution Fit
    #> Model: Full 4-Parameter Model
    #>
    #>      Estimate  Std. Error   Lower 95%   Upper 95% z value Pr(>|z|)
    #> a  189.106079  173.021934 -150.016912  528.229071  1.0930  0.27441
    #> b    4.672827    2.251973    0.258961    9.086693  2.0750  0.03799 *
    #> c    0.013018    0.012241   -0.010974    0.037011  1.0635  0.28755
    #> k    0.033940    0.031263   -0.027335    0.095214  1.0856  0.27765
    #> ---
    #> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
    #> ---
    #> Log-Likelihood: -410.5329
    #> AIC: 829.0658  | BIC: 840.4739

# Three-parameter submodel

    fit_sub <- fit_betadanish(Surv(time, status) ~ 1, data = remission, submodel = TRUE, n_starts = 1)
    compare_models(fit, fit_sub)
    #> Warning in compare_models(fit, fit_sub): Full model log-likelihood is lower
    #> than submodel. Check convergence.
    #> Likelihood Ratio Test (a = 1 vs a != 1)
    #>
    #>                  Model    LogLik Chisq Df Pr(>Chisq)
    #> 1   Submodel (3-param) -409.9541    NA NA         NA
    #> 2 Full Model (4-param) -410.5329     0  1          1

# Diagnostic plots

    plot(fit, type = 'survival')

    plot(fit, type = 'hazard')

# Interpretation

The fitted model can be used to estimate survival probabilities, hazard behavior, and overall model fit. Users should compare the Beta-Danish model with alternative lifetime distributions and inspect diagnostic plots before drawing final conclusions.