Skip to contents

An abstract R6 Class that estimates, tests and provides intervals for a treatment effect in a completed design. This class takes a completed Design object as an input where this object contains data for a fully completed experiment (i.e. all treatment assignments were allocated and all responses were collected).

Active bindings

num_cores

Current number of cores for this inference object. Defaults to the global budget unless overridden on the object.

Methods


Inference$new()

Initialize an estimation and test object after the design is completed.

Usage

Inference$new(
  des_obj,
  verbose = FALSE,
  harden = TRUE,
  model_formula = NULL,
  smart_cold_start_default = NULL,
  seed = NULL
)

Arguments

des_obj

A completed Design object whose entire n subjects are assigned and response y is recorded within.

verbose

Whether to print progress messages.

harden

Whether to apply robustness measures (default TRUE). When TRUE, the inference methods employ defensive strategies including QR-based rank reduction of the design matrix, progressive correlation-threshold dropping, and fallback fits (e.g.\ robust survival regression, treatment-only models) to avoid crashes on ill-conditioned data. When FALSE, the vanilla algorithm runs on the full design matrix as supplied; any rank deficiency or convergence failure will surface as an error rather than being silently worked around. Set to FALSE when you want to verify that the raw model converges without intervention.

model_formula

Optional formula for covariate adjustment. If NULL (default), the formula from the design object is used and its pre-computed design matrix is reused. If a formula is provided, a new design matrix is constructed from the design's imputed covariates.

smart_cold_start_default

Whether to use smart cold start values by default for likelihood-based models. Explicit starts always override this object-level policy. NULL (default) consults the global cold-start dispatch policy.

seed

Integer seed for reproducibility.


Inference$capabilities()

Returns the effective metadata-backed capabilities for this inference object.

Usage

Inference$capabilities()

Returns

A character vector of capability names.


Inference$supports()

Returns whether this inference object supports a metadata-backed capability.

Usage

Inference$supports(capability)

Arguments

capability

Capability name or names.

Returns

A logical vector aligned with capability.


Inference$compute_exact_two_sided_pval_for_treatment_effect()

Computes an exact two-sided p-value. Subclasses that support exact inference override this; inference objects that do not support exact methods throw an error.

Usage

Inference$compute_exact_two_sided_pval_for_treatment_effect(...)

Arguments

...

Other arguments passed to the method.


Inference$compute_exact_confidence_interval()

Computes an exact confidence interval. Subclasses that support exact inference override this; inference objects that do not support exact methods throw an error.

Usage

Inference$compute_exact_confidence_interval(...)

Arguments

...

Other arguments passed to the method.


Inference$compute_asymp_two_sided_pval()

Computes an asymptotic two-sided p-value. Subclasses that support asymptotic inference override this; inference objects that do not support asymptotic methods throw an error.

Usage

Inference$compute_asymp_two_sided_pval(delta = 0)

Arguments

delta

Null treatment effect.


Inference$compute_asymp_confidence_interval()

Computes an asymptotic confidence interval. Subclasses that support asymptotic inference override this; inference objects that do not support asymptotic methods throw an error.

Usage

Inference$compute_asymp_confidence_interval(alpha = 0.05)

Arguments

alpha

Significance level.


Inference$compute_estimate()

Computes the treatment-effect estimate. Concrete subclasses implement the model-specific estimator, such as a fitted regression coefficient, maximum-likelihood parameter, estimating-equation solution, mean or risk contrast, survival contrast, or rank statistic. Interval, p-value, bootstrap, jackknife, and randomization methods use this method as the canonical point-estimate contract.

Usage

Inference$compute_estimate(estimate_only = FALSE)

Arguments

estimate_only

If TRUE, skip variance component calculations.

Returns

A numeric treatment estimate.


Inference$is_nonestimable()

Returns whether the most recent inference attempt explicitly marked the result as non-estimable.

Usage

Inference$is_nonestimable(type = c("any", "estimate", "se"))

Arguments

type

Which stage to query: "any", "estimate", or "se".

Returns

A logical scalar.


Inference$get_nonestimable_reason()

Returns the reason recorded for the most recent explicit non-estimability.

Usage

Inference$get_nonestimable_reason()

Returns

A character scalar or NULL.


Inference$get_nonestimable_stage()

Returns the stage recorded for the most recent explicit non-estimability.

Usage

Inference$get_nonestimable_stage()

Returns

A character scalar or NULL.


Inference$duplicate()

Duplicate this inference object

Usage

Inference$duplicate(verbose = FALSE, make_fork_cluster = FALSE)

Arguments

verbose

A flag indicating whether messages should be displayed.

make_fork_cluster

Whether the duplicate should be allowed to create a fork cluster. Default FALSE.

Returns

A new Inference object with the same data


Inference$get_response()

Return the response vector used by inference extension classes.

This accessor is part of the supported extension contract for user-defined R6 inference classes. Prefer this method over direct access to private fields.

Usage

Inference$get_response()

Returns

A numeric response vector.


Inference$get_treatment()

Return the treatment-assignment vector used by inference extension classes.

This accessor is part of the supported extension contract for user-defined R6 inference classes. Treatment is encoded as 0/1.

Usage

Inference$get_treatment()

Returns

A numeric or integer 0/1 treatment vector.


Inference$get_covariates()

Return the processed covariate matrix used by inference extension classes.

This accessor returns the design object's model-matrix covariates, after the package's missingness handling and encoding. It may be NULL if no covariates are available.

Usage

Inference$get_covariates()

Returns

A numeric matrix of covariates or NULL.


Inference$get_analysis_data()

Return a data frame with response, treatment, censoring status, and covariates.

This accessor is the preferred data interface for user-defined R6 inference classes. It avoids reliance on private implementation fields. The returned data frame always contains y, w, and dead; covariate columns are appended when available.

Usage

Inference$get_analysis_data()

Returns

A data frame suitable for user-defined model fitting.


Inference$get_design_object()

Return the completed design object backing this inference object.

This accessor is part of the supported extension contract. Extension classes should use this method instead of private$des_obj.

Usage

Inference$get_design_object()

Returns

The completed Design object.


Inference$get_response_type()

Return the response type for the backing design.

Usage

Inference$get_response_type()

Returns

A character scalar such as "continuous", "incidence", "proportion", "count", "survival", or "ordinal".


Inference$get_model_formula()

Return the model formula used for covariate adjustment.

Usage

Inference$get_model_formula()

Returns

A formula object or NULL.


Inference$set_optimization_alg()

Set the optimizer used by likelihood-based inference implementations.

Usage

Inference$set_optimization_alg(
  optimization_alg = NULL,
  allow_irls = private$optimization_alg_allow_irls,
  default = private$optimization_alg_default
)

Arguments

optimization_alg

The optimizer name. Valid values are configured by the concrete inference class.

allow_irls

Whether to allow IRLS (Iteratively Reweighted Least Squares) as a fallback or primary optimization algorithm.

default

The default optimizer to use if none is specified.

Returns

Invisibly returns self.


Inference$get_optimization_alg()

Return the optimizer used by likelihood-based inference implementations.

Usage

Inference$get_optimization_alg()


Inference$set_seed()

Set the seed for reproducibility.

Usage

Inference$set_seed(seed)

Arguments

seed

Integer seed for reproducibility.


Inference$clone()

The objects of this class are cloneable with this method.

Usage

Inference$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.