| Title: | The Beta-Danish Distribution for Lifetime Data Analysis |
|---|---|
| Description: | Implements the four-parameter Beta-Danish distribution and its three-parameter submodel for survival and reliability analysis, based on Ahmad and Danish (2025) <doi:10.2478/jamsi-2025-0010>. Provides functions for density, distribution, quantile, hazard, and random generation. Includes maximum likelihood estimation for complete and right-censored data, goodness-of-fit assessment, comparison with standard lifetime distributions, and publication-quality visualizations. Advanced modules support Accelerated Failure Time (AFT) regression, mixture and promotion-time cure models, and competing risks analysis. |
| Authors: | Bilal Ahmad [aut, cre], Muhammad Yameen Danish [aut] |
| Maintainer: | Bilal Ahmad <[email protected]> |
| License: | GPL-3 |
| Version: | 0.2.0 |
| Built: | 2026-06-04 11:06:31 UTC |
| Source: | https://github.com/bilal-aiou/betadanish |
Times to failure of 50 devices, exhibiting a classic bathtub-shaped hazard rate. This is a standard benchmark dataset in reliability engineering.
aarsetaarset
A data frame with 50 rows and 2 columns:
Failure time
Event indicator (1 = event occurred)
Aarset, M. V. (1987). How to Identify a Bathtub Hazard Rate. IEEE Transactions on Reliability, R-36(1), 106-108.
data(aarset) fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = aarset) plot(fit, type = "hazard")data(aarset) fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = aarset) plot(fit, type = "hazard")
Runs a complete end-to-end analysis: reads data, fits the 4-parameter and 3-parameter models, compares them, benchmarks against standard distributions, and generates diagnostic plots.
analyze_betadanish(file, time_col, status_col = NULL)analyze_betadanish(file, time_col, status_col = NULL)
file |
Path to the CSV or Excel file containing the data. |
time_col |
Name of the time column. |
status_col |
Name of the status column (optional). |
Invisibly returns a list containing the fitted full model and submodel objects. The function is mainly called for its side effects of printing an analysis report and producing diagnostic plots.
Samples from the posterior of the Beta-Danish or Exponentiated Danish
parameters using a random-walk Metropolis sampler with vague
priors on the positive parameters.
bayes_betadanish( time, status = NULL, submodel = TRUE, burnin = 5000, mcmc = 15000, tune = 0.5, theta_init = NULL, seed = NULL, verbose = 0 )bayes_betadanish( time, status = NULL, submodel = TRUE, burnin = 5000, mcmc = 15000, tune = 0.5, theta_init = NULL, seed = NULL, verbose = 0 )
time |
Numeric vector of observed times. |
status |
Numeric vector of event indicators (1 = event, 0 = right-censored). |
submodel |
Logical; |
burnin |
Burn-in iterations. |
mcmc |
Post-burnin iterations. |
tune |
Random-walk tuning parameter. |
theta_init |
Optional starting values on the log scale. |
seed |
Optional integer seed. |
verbose |
Integer; passed to MCMCmetrop1R (0 = silent). |
Requires MCMCpack and coda (Suggests).
An object of class "bd_bayes" with components
draws (mcmc object), summary, HPD,
submodel, call.
## Not run: set.seed(1) dat <- rbetadanish(100, a = 1.5, b = 2, c = 3, k = 0.5) fit <- bayes_betadanish(time = dat, submodel = TRUE, burnin = 500, mcmc = 1500) fit$summary ## End(Not run)## Not run: set.seed(1) dat <- rbetadanish(100, a = 1.5, b = 2, c = 3, k = 0.5) fit <- bayes_betadanish(time = dat, submodel = TRUE, burnin = 500, mcmc = 1500) fit$summary ## End(Not run)
Computes the differential Shannon entropy
for the four-parameter Beta-Danish distribution by adaptive Gauss-Kronrod
quadrature on the log-pdf.
bd_entropy_shannon(a, b, c, k, subdivisions = 2000, rel.tol = 1e-08)bd_entropy_shannon(a, b, c, k, subdivisions = 2000, rel.tol = 1e-08)
a, b, c, k
|
Positive parameters of the Beta-Danish distribution. |
subdivisions, rel.tol
|
Passed to |
Scalar Shannon entropy (in nats); NA_real_ on integration
failure.
bd_entropy_shannon(a = 1.5, b = 2.5, c = 2, k = 1)bd_entropy_shannon(a = 1.5, b = 2.5, c = 2, k = 1)
Evaluates the probability density function of the r-th order statistic from a sample of size n drawn from the Beta-Danish distribution.
bd_order_stat_pdf(x, r, n, a, b, c, k, log = FALSE)bd_order_stat_pdf(x, r, n, a, b, c, k, log = FALSE)
x |
Numeric vector of time points. |
r |
Integer order (1 = minimum, n = maximum). |
n |
Integer sample size. |
a, b, c, k
|
Positive parameters of the Beta-Danish distribution. |
log |
Logical; if |
Numeric vector (or its log).
tgrid <- seq(0.01, 5, length.out = 50) bd_order_stat_pdf(tgrid, r = 5, n = 20, a = 1.5, b = 2.5, c = 2, k = 1)tgrid <- seq(0.01, 5, length.out = 50) bd_order_stat_pdf(tgrid, r = 5, n = 20, a = 1.5, b = 2.5, c = 2, k = 1)
Density, distribution function, quantile function, hazard function, and random generation for the four-parameter Beta-Danish distribution.
dbetadanish(x, a, b, c, k, log = FALSE) pbetadanish(q, a, b, c, k, lower.tail = TRUE, log.p = FALSE) qbetadanish(p, a, b, c, k, lower.tail = TRUE, log.p = FALSE) rbetadanish(n, a, b, c, k) hbetadanish(x, a, b, c, k, log = FALSE)dbetadanish(x, a, b, c, k, log = FALSE) pbetadanish(q, a, b, c, k, lower.tail = TRUE, log.p = FALSE) qbetadanish(p, a, b, c, k, lower.tail = TRUE, log.p = FALSE) rbetadanish(n, a, b, c, k) hbetadanish(x, a, b, c, k, log = FALSE)
x, q
|
Vector of quantiles (time points). |
a |
Shape parameter (beta generator). Set 'a = 1' for the 3-parameter submodel. |
b |
Shape parameter (beta generator / tail weight). |
c |
Shape parameter (baseline shape). |
k |
Scale parameter (baseline scale). |
log, log.p
|
Logical; if TRUE, probabilities/densities are given as log. |
lower.tail |
Logical; if TRUE (default), probabilities are P[X <= x], otherwise P[X > x]. |
p |
Vector of probabilities. |
n |
Number of observations to generate. |
The Beta-Danish distribution is a highly flexible lifetime distribution capable of modeling decreasing, increasing, unimodal, and bathtub-shaped hazard rates.
'dbetadanish' gives the density, 'pbetadanish' gives the distribution function, 'qbetadanish' gives the quantile function, 'hbetadanish' gives the hazard function, and 'rbetadanish' generates random deviates.
Ahmad, B., & Danish, M. Y. (2026). Development and Characterization of a Flexible Three-Parameter Lifetime Distribution.
# Density dbetadanish(x = 2, a = 1.5, b = 2, c = 3, k = 0.5) # CDF pbetadanish(q = 2, a = 1.5, b = 2, c = 3, k = 0.5) # Hazard hbetadanish(x = 2, a = 1.5, b = 2, c = 3, k = 0.5) # Random generation rbetadanish(n = 10, a = 1.5, b = 2, c = 3, k = 0.5)# Density dbetadanish(x = 2, a = 1.5, b = 2, c = 3, k = 0.5) # CDF pbetadanish(q = 2, a = 1.5, b = 2, c = 3, k = 0.5) # Hazard hbetadanish(x = 2, a = 1.5, b = 2, c = 3, k = 0.5) # Random generation rbetadanish(n = 10, a = 1.5, b = 2, c = 3, k = 0.5)
A comprehensive dataset of 500 brain cancer patients, including survival times, censoring status, and multiple clinical covariates. This dataset was used to demonstrate Accelerated Failure Time (AFT) regression and Cure-Rate models using the Beta-Danish distribution.
brain_cancerbrain_cancer
A data frame with 500 rows and 16 columns:
Patient identifier
Patient gender (1 = Male, 0 = Female)
Age group (1 = Young, 2 = Middle, 3 = Old)
Geographic area (1 = Urban, 0 = Rural)
Family history of cancer (1 = Yes, 0 = No)
Comorbid history (1 = Yes, 0 = No)
Tumor grade (1 = I/II, 2 = III, 3 = IV)
Surgical intervention (1 = Yes, 0 = No)
Radiotherapy treatment (1 = Yes, 0 = No)
Chemotherapy treatment (1 = Yes, 0 = No)
Treatment type
Tumor morphology
Survival status (1 = Event/Death, 0 = Censored)
Survival time in months
Tumor types classification
Alternative morphology classification
Atomic Energy Cancer Hospital (NORI), Islamabad, Pakistan.
data(brain_cancer) # Fit an AFT model using the brain cancer data fit <- fit_bd_aft(survival::Surv(Survtime, Survstatus) ~ Age + Grade + Surgery, data = brain_cancer, n_starts = 2) summary(fit)data(brain_cancer) # Fit an AFT model using the brain cancer data fit <- fit_bd_aft(survival::Surv(Survtime, Survstatus) ~ Age + Grade + Surgery, data = brain_cancer, n_starts = 2) summary(fit)
Breaking stress (in Gba) of 100 carbon fibre specimens. This dataset exhibits a unimodal (increasing-then-decreasing) hazard pattern that classical distributions like the Weibull cannot adequately capture.
carbon_fibrescarbon_fibres
A data frame with 100 rows and 2 columns:
Breaking stress in Gba
Event indicator (1 = event occurred)
Nichols, M. D., & Padgett, W. J. (2006). A bootstrap control chart for Weibull percentiles. Quality and Reliability Engineering International, 22(2), 141-151.
data(carbon_fibres) fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = carbon_fibres)data(carbon_fibres) fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = carbon_fibres)
Computes the CIF for a specific cause from a fitted Beta-Danish competing risks model using numerical integration.
cif_betadanish(fit, tvec, cause_idx)cif_betadanish(fit, tvec, cause_idx)
fit |
An object of class 'bd_competing'. |
tvec |
Numeric vector of times at which to evaluate the CIF. |
cause_idx |
Integer; the specific cause to evaluate (must match one of the causes in the fitted model). |
A numeric vector of CIF probabilities corresponding to 'tvec'.
Computes the nonparametric Aalen-Johansen CIF (via cmprsk) for each competing-risks cause, overlays it on the fitted Beta-Danish CIF, and returns the Aalen-Johansen times/estimates, the fitted CIF values on a common grid, and Gray's CIF-equality test where applicable.
cif_compare(fit, tmax = NULL, n_grid = 160, plot = TRUE)cif_compare(fit, tmax = NULL, n_grid = 160, plot = TRUE)
fit |
A fitted object of class |
tmax |
Optional upper time for evaluation; default the 95th percentile of observed times. |
n_grid |
Number of time points on the evaluation grid (default 160). |
plot |
Logical; if |
Requires cmprsk (Suggests).
A list with elements tgrid, cif_fit (data frame
long format), cif_aj (data frame long format) and optionally
gray_test.
## Not run: set.seed(1) T1 <- rbetadanish(200, 1.2, 1.5, 1.0, 0.4) T2 <- rbetadanish(200, 1.0, 2.0, 1.0, 0.2) C <- stats::rexp(200, 0.05) time <- pmin(T1, T2, C) cause <- ifelse(time == C, 0L, ifelse(T1 <= T2, 1L, 2L)) fit <- fit_bd_competing(time = time, cause = cause) cif_compare(fit) # requires cmprsk to be installed ## End(Not run)## Not run: set.seed(1) T1 <- rbetadanish(200, 1.2, 1.5, 1.0, 0.4) T2 <- rbetadanish(200, 1.0, 2.0, 1.0, 0.2) C <- stats::rexp(200, 0.05) time <- pmin(T1, T2, C) cause <- ifelse(time == C, 0L, ifelse(T1 <= T2, 1L, 2L)) fit <- fit_bd_competing(time = time, cause = cause) cif_compare(fit) # requires cmprsk to be installed ## End(Not run)
Extract Coefficients
## S3 method for class 'betadanish' coef(object, ...)## S3 method for class 'betadanish' coef(object, ...)
object |
An object of class 'betadanish'. |
... |
Further arguments passed to or from other methods. |
A named numeric vector of maximum likelihood parameter estimates.
Fits standard lifetime distributions (Weibull, Log-Normal, Log-Logistic, Gamma, Exponential) using the 'flexsurv' package and compares them to the Beta-Danish fit.
compare_distributions(object)compare_distributions(object)
object |
A fitted 'betadanish' object. |
A ranked data frame of model comparisons.
Performs a Likelihood Ratio Test (LRT) between the 4-parameter full model and the 3-parameter submodel.
compare_models(full_model, sub_model)compare_models(full_model, sub_model)
full_model |
A fitted 4-parameter 'betadanish' object. |
sub_model |
A fitted 3-parameter 'betadanish' object. |
A data frame with the test statistic and p-value.
Fits an Accelerated Failure Time (AFT) regression model using the Complementary Exponentiated Danish (CED) baseline (Beta-Danish with a=1).
fit_bd_aft(formula, data, n_starts = 10, method = "BFGS")fit_bd_aft(formula, data, n_starts = 10, method = "BFGS")
formula |
A survival formula (e.g., 'Surv(time, status) ~ age + treatment'). |
data |
A data frame containing the variables. |
n_starts |
Integer; number of random starts for optimization. |
method |
Optimization method passed to 'maxLik'. |
To ensure identifiability, the shape parameter 'a' is fixed to 1. The scale parameter 'k' is linked to covariates via 'k_i = exp(X_i Positive coefficients in 'delta' indicate a larger 'k', which corresponds to shorter survival times (accelerated failure).
An object of class 'bd_aft'.
Fits a parametric competing risks model assuming independent latent failure times, where each cause-specific baseline follows a 4-parameter Beta-Danish distribution.
fit_bd_competing(time, cause, n_starts = 5, method = "BFGS")fit_bd_competing(time, cause, n_starts = 5, method = "BFGS")
time |
Numeric vector of observed times. |
cause |
Integer vector of event causes. '0' indicates right-censored, and '1, 2, ..., m' indicate specific event causes. |
n_starts |
Integer; number of random starts for the joint optimization. |
method |
Optimization method passed to 'maxLik'. |
Under the assumption of independent latent failure times, the joint likelihood factorizes. The function first fits independent Beta-Danish models for each cause (treating other causes as censored) to find robust starting values, then optimizes the joint likelihood.
An object of class 'bd_competing'.
Fits mixture and promotion-time (non-mixture) cure models using the Beta-Danish AFT baseline.
fit_bd_cure( formula_aft, formula_cure, data, type = c("mixture", "promotion"), n_starts = 10, method = "BFGS" )fit_bd_cure( formula_aft, formula_cure, data, type = c("mixture", "promotion"), n_starts = 10, method = "BFGS" )
formula_aft |
A formula for the latency component (e.g., 'Surv(time, status) ~ age'). |
formula_cure |
A one-sided formula for the incidence/cure component (e.g., '~ treatment'). |
data |
A data frame containing the variables. |
type |
Character; either '"mixture"' or '"promotion"'. |
n_starts |
Integer; number of random starts for optimization. |
method |
Optimization method passed to 'maxLik'. |
In the **mixture** model, the population is split into susceptible and cured fractions. The susceptible probability is modeled via logistic regression: 'pi = exp(Z
In the **promotion-time** (non-mixture) model, the cure fraction is derived from a latent Poisson process of clonogenic cells: 'theta = exp(Z The cure fraction is 'exp(-theta)'.
An object of class 'bd_cure'.
Fits the Beta-Danish distribution using Maximum Likelihood Estimation (MLE). Supports both complete and right-censored data via 'survival::Surv' objects.
fit_betadanish(formula, data, submodel = FALSE, n_starts = 10, method = "BFGS")fit_betadanish(formula, data, submodel = FALSE, n_starts = 10, method = "BFGS")
formula |
A formula object, with the response on the left of a '~' operator, and the terms on the right. The response must be a survival object as returned by the 'Surv' function. Use '~ 1' for models without covariates. |
data |
A data frame containing the variables named in the formula. |
submodel |
Logical; if 'TRUE', fits the 3-parameter submodel by fixing 'a = 1'. |
n_starts |
Integer; the number of random starting points to use for the optimization to ensure global convergence. Default is 10. |
method |
Character; the optimization method passed to 'maxLik'. Default is "BFGS". |
The optimization is performed on the log-transformed parameters to strictly enforce positivity constraints. The returned coefficients and variance-covariance matrix are transformed back to the natural scale using the Delta method.
An object of S3 class '"betadanish"', containing the parameter estimates, log-likelihood, variance-covariance matrix, and convergence diagnostics.
# Simulate some data set.seed(123) sim_time <- rbetadanish(100, a = 1.5, b = 2, c = 3, k = 0.5) sim_status <- sample(c(0, 1), 100, replace = TRUE, prob = c(0.2, 0.8)) dat <- data.frame(time = sim_time, status = sim_status) # Fit the 4-parameter model fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = dat) summary(fit) # Fit the 3-parameter submodel fit_sub <- fit_betadanish(survival::Surv(time, status) ~ 1, data = dat, submodel = TRUE) summary(fit_sub)# Simulate some data set.seed(123) sim_time <- rbetadanish(100, a = 1.5, b = 2, c = 3, k = 0.5) sim_status <- sample(c(0, 1), 100, replace = TRUE, prob = c(0.2, 0.8)) dat <- data.frame(time = sim_time, status = sim_status) # Fit the 4-parameter model fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = dat) summary(fit) # Fit the 3-parameter submodel fit_sub <- fit_betadanish(survival::Surv(time, status) ~ 1, data = dat, submodel = TRUE) summary(fit_sub)
Computes Information Criteria (AIC, BIC, HQIC, AICC) and the Kolmogorov-Smirnov (K-S) statistic for a fitted Beta-Danish model.
gof_betadanish(object)gof_betadanish(object)
object |
A fitted 'betadanish' object. |
A list containing the Information Criteria and the K-S statistic.
Survival times (in weeks) for 23 patients with acute myelogenous leukemia. A classic, small dataset perfect for fast testing of censored data workflows.
leukemialeukemia
A data frame with 23 rows and 3 columns:
Survival time in weeks
Event indicator (1 = event, 0 = censored)
Treatment group (Maintained vs Non-maintained)
Miller, R. G. (1997). Survival Analysis. Wiley.
data(leukemia) fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = leukemia)data(leukemia) fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = leukemia)
Extract Log-Likelihood
## S3 method for class 'betadanish' logLik(object, ...)## S3 method for class 'betadanish' logLik(object, ...)
object |
An object of class 'betadanish'. |
... |
Further arguments passed to or from other methods. |
An object of class logLik containing the maximized log-likelihood value, with degrees of freedom and number of observations stored as attributes.
Survival times for 205 patients with malignant melanoma after surgery. This rich clinical dataset includes multiple covariates and heavy censoring.
melanomamelanoma
A data frame with 205 rows and 6 columns:
Survival time in days
Event indicator (1 = died from melanoma, 0 = alive, 2 = other death)
Tumor thickness in mm
Patient sex (1 = male, 0 = female)
Patient age in years
Ulceration indicator (1 = present, 0 = absent)
Year of operation
Andersen, P. K., Borgan, O., Gill, R. D., & Keiding, N. (1993). Statistical Models Based on Counting Processes. Springer.
data(melanoma) # Treat status 1 as event, others as censored melanoma$event <- ifelse(melanoma$status == 1, 1, 0) fit <- fit_betadanish(survival::Surv(time, event) ~ age + thickness, data = melanoma)data(melanoma) # Treat status 1 as event, others as censored melanoma$event <- ifelse(melanoma$status == 1, 1, 0) fit <- fit_betadanish(survival::Surv(time, event) ~ age + thickness, data = melanoma)
Diagnostic Cox-Snell residual plot for a fitted AFT or cure model.
## S3 method for class 'bd_aft' plot(x, ...) ## S3 method for class 'bd_cure' plot(x, ...)## S3 method for class 'bd_aft' plot(x, ...) ## S3 method for class 'bd_cure' plot(x, ...)
x |
A fitted |
... |
Further graphical parameters. |
Invisibly returns x.
set.seed(42) n <- 300 x <- stats::rnorm(n) k <- exp(-0.5 - 0.3 * x) t_sim <- rbetadanish(n, a = 1, b = 2, c = 1.5, k = k) status <- stats::rbinom(n, 1, 0.85) # ~15% censoring dat <- data.frame(time = t_sim, status = status, x = x) fit <- fit_bd_aft(survival::Surv(time, status) ~ x, data = dat, n_starts = 5) plot(fit)set.seed(42) n <- 300 x <- stats::rnorm(n) k <- exp(-0.5 - 0.3 * x) t_sim <- rbetadanish(n, a = 1, b = 2, c = 1.5, k = k) status <- stats::rbinom(n, 1, 0.85) # ~15% censoring dat <- data.frame(time = t_sim, status = status, x = x) fit <- fit_bd_aft(survival::Surv(time, status) ~ x, data = dat, n_starts = 5) plot(fit)
Generates diagnostic plots for a fitted Beta-Danish model, including survival, hazard, density, PP, and QQ plots.
## S3 method for class 'betadanish' plot(x, type = c("survival", "hazard", "density", "pp", "qq", "all"), ...)## S3 method for class 'betadanish' plot(x, type = c("survival", "hazard", "density", "pp", "qq", "all"), ...)
x |
A fitted 'betadanish' object. |
type |
Character string specifying the plot type: '"survival"', '"hazard"', '"density"', '"pp"', '"qq"', or '"all"'. |
... |
Additional arguments passed to the base 'plot' function. |
Invisibly returns the input betadanish object. Called mainly for its side effect of producing diagnostic plots.
Print Method for Beta-Danish Fit
## S3 method for class 'betadanish' print(x, ...)## S3 method for class 'betadanish' print(x, ...)
x |
An object of class 'betadanish'. |
... |
Further arguments passed to or from other methods. |
Invisibly returns the input betadanish object. Called mainly for its side effect of printing the fitted model summary.
Print Summary Method for Beta-Danish Fit
## S3 method for class 'summary.betadanish' print(x, ...)## S3 method for class 'summary.betadanish' print(x, ...)
x |
An object of class 'summary.betadanish'. |
... |
Further arguments passed to or from other methods. |
Invisibly returns the input summary.betadanish object. Called mainly for its side effect of printing the coefficient table and fit statistics.
A helper function to read survival data from CSV or Excel files and prepare it for analysis with the Beta-Danish package. It automatically handles missing status columns by assuming all observations are complete (uncensored).
read_survival_data(file, time_col, status_col = NULL, covar_cols = NULL)read_survival_data(file, time_col, status_col = NULL, covar_cols = NULL)
file |
Character string specifying the path to the file. |
time_col |
Character string specifying the name of the time/survival column. |
status_col |
Character string specifying the name of the event/censoring indicator column. If 'NULL' (default), the function assumes all observations are uncensored and creates a status column filled with 1s. |
covar_cols |
Character vector specifying the names of covariate columns to keep. If 'NULL' (default), no covariates are kept. |
The function checks the file extension to determine how to read the data. For '.xlsx' or '.xls' files, the 'readxl' package must be installed. Missing values ('NA') in the specified columns will cause those rows to be dropped with a warning.
A clean 'data.frame' containing the 'time', 'status', and any specified covariates, ready to be passed to 'fit_betadanish()'.
tmp <- tempfile(fileext = ".csv") example_data <- data.frame( survival_time = c(5, 8, 12, 16), status = c(1, 1, 0, 1) ) write.csv(example_data, tmp, row.names = FALSE) dat <- read_survival_data(tmp, time_col = "survival_time", status_col = "status") unlink(tmp)tmp <- tempfile(fileext = ".csv") example_data <- data.frame( survival_time = c(5, 8, 12, 16), status = c(1, 1, 0, 1) ) write.csv(example_data, tmp, row.names = FALSE) dat <- read_survival_data(tmp, time_col = "survival_time", status_col = "status") unlink(tmp)
Remission times (in months) for 128 bladder cancer patients. This is a complete (uncensored) sample widely used in lifetime distribution literature to demonstrate decreasing or right-skewed hazard rates.
remissionremission
A data frame with 128 rows and 2 columns:
Remission time in months
Event indicator (1 = event occurred)
Lee, E. T., & Wang, J. W. (2003). Statistical Methods for Survival Data Analysis (3rd ed.). Wiley.
data(remission) fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = remission) summary(fit)data(remission) fit <- fit_betadanish(survival::Surv(time, status) ~ 1, data = remission) summary(fit)
Create a compact report from a BetaDanish model fit
report_betadanish(fit)report_betadanish(fit)
fit |
A fitted BetaDanish model object. |
A list containing model summary information.
Generates synthetic survival data from a Beta-Danish mixture or promotion-time cure model, incorporating covariates.
simulate_bd_cure_data( n, type = c("mixture", "promotion"), a = 1, b = 2, c = 1.5, delta, gamma, X, Z, target_censor = 0.3, seed = NULL )simulate_bd_cure_data( n, type = c("mixture", "promotion"), a = 1, b = 2, c = 1.5, delta, gamma, X, Z, target_censor = 0.3, seed = NULL )
n |
Integer; number of observations. |
type |
Character; '"mixture"' or '"promotion"'. |
a, b, c
|
Numeric; baseline shape parameters. |
delta |
Numeric vector; coefficients for the latency scale 'k'. |
gamma |
Numeric vector; coefficients for the incidence/cure component. |
X |
Matrix; design matrix for latency (must match length of 'delta'). |
Z |
Matrix; design matrix for incidence (must match length of 'gamma'). |
target_censor |
Numeric; target proportion of censoring to calibrate the exponential censoring rate. Default is 0.3. |
seed |
Integer; optional seed. |
A list containing the simulated 'data' (time, status), the 'cured' indicator, and the true parameters.
Generates synthetic survival data from the Beta-Danish distribution, with optional right-censoring.
simulate_bd_data(n, a, b, c, k, censor_rate = 0, seed = NULL)simulate_bd_data(n, a, b, c, k, censor_rate = 0, seed = NULL)
n |
Integer; number of observations to simulate. |
a, b, c, k
|
Numeric; parameters of the Beta-Danish distribution. |
censor_rate |
Numeric; rate parameter for the exponential censoring distribution. If '0' (default), no censoring is applied. |
seed |
Integer; optional seed for reproducibility. |
A data frame with columns 'time' and 'status'.
# Simulate complete data dat <- simulate_bd_data(n = 100, a = 1.5, b = 2, c = 3, k = 0.5) # Simulate censored data dat_cens <- simulate_bd_data(n = 100, a = 1.5, b = 2, c = 3, k = 0.5, censor_rate = 0.1)# Simulate complete data dat <- simulate_bd_data(n = 100, a = 1.5, b = 2, c = 3, k = 0.5) # Simulate censored data dat_cens <- simulate_bd_data(n = 100, a = 1.5, b = 2, c = 3, k = 0.5, censor_rate = 0.1)
Summary Method for Beta-Danish Fit
## S3 method for class 'betadanish' summary(object, ...)## S3 method for class 'betadanish' summary(object, ...)
object |
An object of class 'betadanish'. |
... |
Further arguments passed to or from other methods. |
An object of class summary.betadanish containing coefficient estimates, standard errors, test statistics, p-values, log-likelihood, and model selection criteria.
Survival times for 91 patients with refractory acute lymphoblastic leukemia who received either an allogeneic or autologous bone marrow transplant. This dataset includes right-censoring and a treatment covariate, making it ideal for demonstrating cure-rate models and AFT regression.
transplanttransplant
A data frame with 91 rows and 3 columns:
Survival time in days
Event indicator (1 = death/relapse, 0 = censored)
Treatment group (0 = Allogeneic, 1 = Autologous)
Klein, J. P., & Moeschberger, M. L. (2003). Survival Analysis: Techniques for Censored and Truncated Data (2nd ed.). Springer.
data(transplant) # Fit a model with a covariate fit <- fit_bd_aft(survival::Surv(time, status) ~ group, data = transplant)data(transplant) # Fit a model with a covariate fit <- fit_bd_aft(survival::Surv(time, status) ~ group, data = transplant)
Extract Variance-Covariance Matrix
## S3 method for class 'betadanish' vcov(object, ...)## S3 method for class 'betadanish' vcov(object, ...)
object |
An object of class 'betadanish'. |
... |
Further arguments passed to or from other methods. |
A numeric variance-covariance matrix for the estimated model parameters.