loglik_frailty: Log-Likelihood Function for MultiFrailty Models

View source: R/loglik.R

loglik_frailtyR Documentation

Log-Likelihood Function for MultiFrailty Models

Description

Computes the log-likelihood for shared frailty models across all 10 baseline-frailty combinations with support for right, exact, left, and interval censoring, plus optional progressive censoring.

Usage

loglik_frailty(
  par_all,
  time,
  status,
  x = matrix(nrow = length(time), ncol = 0),
  baseline = c("weibull", "gw"),
  frailty = c("none", "gamma", "ig", "gl1", "gl2"),
  time2 = NULL,
  prog_cen = NULL
)

Arguments

par_all

Vector of all model parameters on estimation scale (log/logit transformed).

time

Primary event/censoring time vector.

status

Event status vector (0 = right-censored, 1 = exact event, 2 = left-censored, 3 = interval-censored).

x

Matrix of covariates (n x p). Default is 0-column matrix.

baseline

Baseline hazard distribution ("weibull" or "gw").

frailty

Frailty distribution ("none", "gamma", "ig", "gl1", or "gl2").

time2

Vector of upper interval bounds when status == 3. Default is NULL.

prog_cen

Vector of progressive censoring counts R_i per observation. Default is NULL.

Value

Scalar log-likelihood value. Returns -1e12 sentinel on numerical invalidity.

Examples

par_all <- c(log(2), log(1.5), log(0.8), 0.1) # Weibull + Gamma + 1 beta
time <- c(1, 2, 3, 4)
status <- c(1, 0, 1, 0)
x <- matrix(c(0.5, -0.2, 0.1, 0.8), ncol = 1)
ll <- loglik_frailty(par_all, time, status, x, baseline = "weibull", frailty = "gamma")

MultiFrailty documentation built on Aug. 8, 2026, 1:07 a.m.