fit_betadanish: Fit the Beta-Danish Distribution to Survival Data

View source: R/fit_models.R

fit_betadanishR Documentation

Fit the Beta-Danish Distribution to Survival Data

Description

Fits the Beta-Danish distribution using Maximum Likelihood Estimation (MLE). Supports both complete and right-censored data via 'survival::Surv' objects.

Usage

fit_betadanish(formula, data, submodel = FALSE, n_starts = 10, method = "BFGS")

Arguments

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".

Details

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.

Value

An object of S3 class '"betadanish"', containing the parameter estimates, log-likelihood, variance-covariance matrix, and convergence diagnostics.

Examples


# 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)


BetaDanish documentation built on May 20, 2026, 5:07 p.m.