This vignette provides a structural view of the core C++ / R interface objects in the bayestransmission package: models, parameter components, system histories, and events. It complements function-level documentation by showing how likelihood evaluation traverses linked event histories (HistoryLink) and consumes parameter components from the active model.
LogNormalModelParams() or LinearAbxModel()).newCppModel() calls into C++ and constructs a concrete model (e.g. CppLogNormalModel).System is built from raw event data (facility, unit, time, patient, type).SystemHistory indexes events by unit and patient via HistoryLink objects.logLikelihood() iterates over HistoryLinks, combining gap and event contributions from each parameter component (InColParams, OutColParams, InsituParams, test parameters, antibiotics).Below we attempt to render the Mermaid diagram. If DiagrammeR is not installed, a fallback textual representation is shown.
An alternate ER-style view emphasizing cardinalities:
Note: MODEL here abstracts over any concrete Cpp*Model instance created by newCppModel().
library(bayestransmission)
params <- LogNormalModelParams("LogNormalModel")
model <- newCppModel(params)
# Build a minimal empty system to demonstrate object creation
sys <- CppSystem$new(integer(0), integer(0), numeric(0), integer(0), integer(0))
hist <- CppSystemHistory$new(sys, model, FALSE)
model$logLikelihood(hist) # should be 0 with no eventsSplitting parameters into distinct components enables targeted updates and diagnostic decomposition of the likelihood. HistoryLink objects provide both sequential (unit-level) and patient-level traversal, allowing gap contributions (time intervals) and instantaneous event contributions to be combined cleanly.
To add a new model variant:
CppLogNormalModel (or CppBasicModel).newModel() and newCppModelInternal().NewModelParams() mirroring existing parameter list structure.Thomas et al. (2015) DOI:10.1093/imammb/dqt021 – foundational description of the transmission modeling approach.