% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Parameters_estimation.R
\name{Parameters_estimation}
\alias{Parameters_estimation}
\title{Unified Interface for Parameter Estimation in (Competing Risks) Frailty Models}
\usage{
Parameters_estimation(
  data,
  method = "CompRisk_frailty",
  cluster_censoring = FALSE,
  max_iter = 300,
  tol = 1e-06,
  threshold = 1e-06
)
}
\arguments{
\item{data}{A data frame containing at least the following columns:
\describe{
\item{times}{Event or censoring times.}
\item{status}{Event indicator: 0 = censored, 1 = event of interest, >1 = other types (for competing risks).}
\item{clusters}{Cluster/group variable (e.g., center ID).}
\item{covariates}{(Optional) Additional covariates from the 4th column onward.}
}}

\item{method}{Character string indicating the estimation method. One of:
\itemize{
\item \code{"CompRisk_frailty"} (default): Competing risks model for cause 1 with shared frailty.
\item \code{"CompRisk"}: Competing risks model for cause 1 without frailty.
\item \code{"Cox_frailty"}: Cox proportional hazards model with shared frailty.
\item \code{"Cox"}: Standard Cox proportional hazards model.
}}

\item{cluster_censoring}{Logical. If \code{TRUE}, adjusts for cluster-specific censoring. Only applicable when \code{method = "CompRisk_frailty"} (default = \code{FALSE}).}

\item{max_iter}{Maximum number of iterations for the selected model estimation (default = 300).}

\item{tol}{Convergence tolerance (default = 1e-6).}

\item{threshold}{Lower bound for the frailty variance parameter \eqn{\theta}. If the estimated value falls below this threshold, frailty is considered negligible (default = 1e-5).}
}
\value{
A named list whose structure depends on \code{method}.
For \code{"CompRisk"} and \code{"Cox"}, the returned list contains:
\describe{
\item{beta}{Numeric vector of estimated regression coefficients.}
}
For \code{"CompRisk_frailty"} and \code{"Cox_frailty"}, the returned list may contain:
\describe{
\item{beta}{Numeric vector of estimated fixed-effect coefficients.}
\item{u}{Numeric vector of estimated cluster-specific frailties.}
\item{theta}{Estimated frailty variance parameter.}
\item{p_value}{P-value for testing the null hypothesis of no frailty effect.}
}
Returns \code{NULL} if estimation fails.
}
\description{
Provides a unified wrapper to estimate model parameters under four different modeling strategies:
\itemize{
\item Competing risks with shared frailty for cause 1 (\code{"CompRisk_frailty"})
\item Competing risks without frailty for cause 1 (\code{"CompRisk"})
\item Standard Cox model with shared frailty (\code{"Cox_frailty"})
\item Standard Cox model without frailty (\code{"Cox"})
}
}
\details{
This wrapper allows seamless switching between various modeling frameworks. It automatically calls:
\itemize{
\item \code{\link{Reml_CompRisk_frailty}} for \code{"CompRisk_frailty"}
\item \code{\link{Ml_CompRisk}} for \code{"CompRisk"}
\item \code{\link{Reml_Cox_frailty}} for \code{"Cox_frailty"}
\item \code{\link{Ml_Cox}} for \code{"Cox"}
}

Data format is validated via the helper function \code{\link{check_data_format}}. An error is raised if input format is invalid or if \code{cluster_censoring} is used with an incompatible method.
}
\examples{
\donttest{
data <- data.frame(
  times = c(4, 6, 10, 12, 3),
  status = c(1, 0, 2, 1, 0),
  clusters = c(1, 1, 2, 2, 3),
  x1 = rnorm(5),
  x2 = sample(0:1, 5, replace = TRUE)
)
result <- Parameters_estimation(data, method = "CompRisk_frailty")
result$beta
}

}
\seealso{
\code{\link{Reml_CompRisk_frailty}}, \code{\link{Ml_CompRisk}}, \code{\link{Reml_Cox_frailty}}, \code{\link{Ml_Cox}}, \code{\link{check_data_format}}
}
