The likelihood.model package provides a framework for likelihood-based inference. The package is organized in layers:

Core Concept (core-generics.R): The likelihood_model "concept" – an abstract interface that any model can implement. At minimum, implement loglik(). Optionally provide score() and hess_loglik() for analytical derivatives; defaults use numerical differentiation via numDeriv.

Core Infrastructure:

Model Builders:

  • likelihood_contr_model: R6 class for building models from heterogeneous observation types (exact, censored, etc.) with dynamic dispatch to type-specific functions.

  • likelihood_name(): Wraps any standard R distribution (norm, weibull, exp, ...) with automatic censoring support.

Example Implementations: Reference implementations showing how to satisfy the likelihood_model concept with hand-derived analytical solutions:

  • weibull_uncensored: Weibull with exact observations only. Demonstrates analytical score and hessian (10-100x faster than numerical).

  • exponential_lifetime: Exponential with right-censoring support. Demonstrates closed-form MLE (no optim needed), analytical FIM, and rdata() for Monte Carlo validation.

Author

Maintainer: Alexander Towell lex@metafunctor.com (ORCID)