
Simple Mean-Difference Inference with Pooled Variance
Source:R/inference_all_simple_mean_diff_pooled_var.R
InferenceAllSimpleMeanDiffPooledVar.RdFits the same unadjusted mean-difference point estimate as
InferenceAllSimpleAverageDiff,
\(\hat\beta_T = \bar y_T - \bar y_C\), but performs inference via the
classical pooled equal-variance Student's t-test instead of
Welch's unequal-variance version: pooled variance \(s_p^2 =
\left((n_T-1)s_T^2 + (n_C-1)s_C^2\right)/(n_T+n_C-2)\), standard error
\(s_p\sqrt{1/n_T + 1/n_C}\), and exact degrees of freedom \(n_T+n_C-2\)
— see $compute_asymp_confidence_interval() for the full formula.
This assumes the two arms have equal population variance; prefer
InferenceAllSimpleAverageDiff
when that assumption is doubtful, since the pooled estimator's nominal
coverage degrades under heteroskedasticity with unequal arm sizes. This
class does not support censored survival data (enforced at construction).
This class has no likelihood tier (likelihood_tier = "none") and
provides asymptotic Wald, randomization, and bootstrap (including Bayesian
bootstrap) confidence intervals and p-values. Warm starts are disabled for
this class, since the simple mean difference is a closed-form estimator
(no iterative fit to warm-start).
Initialize simple pooled-variance mean-difference inference
for continuous responses and prepare the pooled standard-error
calculation used by
InferenceAllSimpleMeanDiffPooledVar.
Disables warm starts (closed-form estimator) and asserts
des_obj has no censored observations (unsupported by this
class).
Computes a \(1-\alpha\) level confidence interval for the
simple (unadjusted) mean-difference treatment effect
\(\hat\beta_T = \bar y_T - \bar y_C\), using the classical
pooled equal-variance Student's t-test formula (unlike
InferenceAllSimpleAverageDiff's
Welch unequal-variance version): the pooled variance estimate
\(s_p^2 = \left((n_T-1)s_T^2 + (n_C-1)s_C^2\right) / (n_T+n_C-2)\)
gives standard error \(\widehat{\mathrm{SE}}(\hat\beta_T) =
s_p\sqrt{1/n_T + 1/n_C}\) with exact degrees of freedom \(n_T + n_C -
2\); the interval is \(\hat\beta_T \pm t_{\mathrm{df}, 1-\alpha/2}\,
\widehat{\mathrm{SE}}(\hat\beta_T)\). Assumes equal population
variances in the two arms — use
InferenceAllSimpleAverageDiff
instead when that assumption is doubtful. Requires at least 2
observations per arm; otherwise returns c(NA, NA). See
InferenceAsymp for the shared
asymptotic confidence-interval contract this participates in.
Computes a two-sided pooled-variance Student's t-test
p-value testing \(H_0: \beta_T = \code{delta}\), from the same
pooled standard error and exact \(n_T+n_C-2\) degrees of freedom
used by $compute_asymp_confidence_interval() — see that
method's documentation for the full formula. See
InferenceAsymp for the shared
asymptotic two-sided p-value contract this participates in.
References
Student [Gosset, W. S.] (1908). "The Probable Error of a Mean." Biometrika, 6(1), 1-25, doi:10.1093/biomet/6.1.1 , for the pooled-variance two-sample t-test used here.
Super class
Inference -> InferenceAllSimpleMeanDiffPooledVar
Methods
Public methods
+ inherited public methods from Inference
Inference$capabilities()Inference$compute_estimate()Inference$compute_exact_confidence_interval()Inference$compute_exact_two_sided_pval_for_treatment_effect()Inference$duplicate()Inference$get_analysis_data()Inference$get_covariates()Inference$get_design_object()Inference$get_model_formula()Inference$get_nonestimable_reason()Inference$get_nonestimable_stage()Inference$get_optimization_alg()Inference$get_response()Inference$get_response_type()Inference$get_treatment()Inference$is_nonestimable()Inference$set_optimization_alg()Inference$set_seed()Inference$supports()
InferenceAllSimpleMeanDiffPooledVar$new()
Usage
InferenceAllSimpleMeanDiffPooledVar$new(
des_obj,
model_formula = NULL,
verbose = FALSE,
smart_cold_start_default = NULL
)Arguments
des_objA completed design object.
model_formulaOptional 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.verboseWhether to print progress messages.
smart_cold_start_defaultWhether to use smart cold start values.
InferenceAllSimpleMeanDiffPooledVar$compute_estimate_with_bootstrap_weights()
Recomputes the pooled-variance difference in means and its
pooled (equal-variance) standard error under bootstrap weights, so
bootstrap and studentized intervals use the same variance convention as
the asymptotic methods; see
InferenceBayesianBootstrap.
Examples
# \donttest{
seq_des = DesignSeqOneByOneBernoulli$new(n = 10, response_type = 'continuous')
for (i in 1:10) {
seq_des$add_one_subject_to_experiment_and_assign(data.frame(x1 = rnorm(1)))
}
seq_des$add_all_subject_responses(rnorm(10))
inf = InferenceAllSimpleMeanDiffPooledVar$new(seq_des)
inf$compute_estimate()
#> [1] 0.6736107
# }