% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/fit_models.R
\name{fit_betadanish}
\alias{fit_betadanish}
\title{Fit the Beta-Danish Distribution to Survival Data}
\usage{
fit_betadanish(formula, data, submodel = FALSE, n_starts = 10, method = "BFGS")
}
\arguments{
\item{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.}

\item{data}{A data frame containing the variables named in the formula.}

\item{submodel}{Logical; if `TRUE`, fits the 3-parameter submodel by fixing `a = 1`.}

\item{n_starts}{Integer; the number of random starting points to use for the
optimization to ensure global convergence. Default is 10.}

\item{method}{Character; the optimization method passed to `maxLik`. Default is "BFGS".}
}
\value{
An object of S3 class `"betadanish"`, containing the parameter estimates,
  log-likelihood, variance-covariance matrix, and convergence diagnostics.
}
\description{
Fits the Beta-Danish distribution using Maximum Likelihood Estimation (MLE).
Supports both complete and right-censored data via `survival::Surv` objects.
}
\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.
}
\examples{
\donttest{
# 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)
}
}
