
Marginal vs. Conditional Estimand Switch
Source:R/inference_all_abstract_marginal_estimand.R
InferenceMarginalEstimand.RdComponent scaffold providing set_estimand()/
get_estimand()/get_supported_estimands() for classes whose
reported treatment coefficient is conditional on a latent mixture
component – e.g. the interior beta submodel in zero/one-inflated beta
regression, or the count-process submodel in zero-augmented/hurdle
Poisson – rather than the unconditional response mean \(E[Y]\). See
marginal_estimand_report.md for the full design discussion.
Mirrors the testing_type switch (InferenceAsympLik) on its
own, orthogonal axis: default "conditional" (today's behavior,
fully backward compatible – every class that does not compose this
component is implicitly conditional-only), with "marginal_mean_diff"
and "marginal_ratio" available to classes that declare support for
them via their own get_supported_estimands_impl() override (the
same override pattern already used for
get_supported_testing_types_impl()).
Scope note (2026-08-18): this component provides only the
get/set/supported-values switch and the cache-key helper. It does not
itself compute any marginal estimate – no class currently composes it.
Wiring a class's own compute_estimate() to consult
self$get_estimand() and, for a marginal estimand, call into a
family-specific model-implied mean function plus a shared
g-computation-average/delta-method-gradient helper, is
marginal_estimand_report.md → TODO-4/5/9 – deliberately deferred
until their target classes (still on the legacy deep-hierarchy ladder as
of this writing) migrate to the shallow hierarchy under
fix_inference_hierarchy.md's Full-Likelihood Estimators remainder.
compute_estimate() itself stays 100 percent class-owned either way
– this component never overrides or wraps it, so no
allowed_host_overrides declaration is needed.
Methods
InferenceMarginalEstimand$set_estimand()
Sets the target estimand for this inference object.
Arguments
estimandOne of
get_supported_estimands(). Accepts the canonical values ("conditional","marginal_mean_diff","marginal_ratio") case-insensitively.
Details
If this object also composes LikelihoodTests (checked
via self$supports("likelihood_tests"), the sanctioned
capability query – see
marginal_estimand_report.md → TODO-6), switching to a
non-"conditional" estimand shrinks the set of supported
testing types to "wald" only. If the currently configured
testing_type is no longer in that shrunk set, this errors
loudly and leaves the estimand unchanged, rather than silently
leaving the object in an inconsistent state – the same guarantee
holds regardless of which of set_testing_type()/
set_estimand() is called first.
InferenceMarginalEstimand$get_supported_estimands()
Gets the estimands supported by this inference object.
Returns
A character vector. Always includes "conditional".
Canonicalizes a requested estimand value, rejecting anything not in
the fixed set of recognized spellings – unlike
`get_supported_estimands_impl()` below (host-overridable, varies by
class), this recognizes syntax, not per-class support.
Default: every class implicitly supports only the conditional
estimand until it declares otherwise. Concrete classes override this
private method (via `define_inference_class()`'s `overrides`
argument, the same pattern `get_supported_testing_types_impl()`
already uses) once they wire a marginal mean function.
Cache-key fragment for the current estimand, generalizing
`likelihood_test_delta_key()`'s testing_type/delta pattern to this
orthogonal axis. Any cache keyed partly by estimand should prefix or
combine with this so a cache entry built under one estimand is never
reused under another.