
Miettinen-Nurminen Risk-Difference Inference for Binary Responses
Source:R/inference_incidence_miettinen_nurminen_univ.R
InferenceIncidMiettinenNurminenRiskDiff.RdFits the classical Miettinen-Nurminen score method for the risk difference in a two-arm binary trial. The point estimate is the observed risk difference, while confidence intervals and p-values are obtained by inverting the constrained score test under the null \(p_T - p_C = \delta\).
This class is intentionally unadjusted. It operates on the \(2 \times 2\)
table induced by treatment assignment and incidence response (counts
\(x_T, x_C\) of events among \(n_T, n_C\) treated/control subjects), and
is therefore the natural classical binary-endpoint complement to the
regression-based incidence methods already in the package. The point
estimate is the plain risk difference \(\hat p_T - \hat p_C\); the
Miettinen-Nurminen confidence interval and p-value invert a
restricted-maximum-likelihood score test of \(H_0: p_T - p_C =
\delta\) (via mn_ci_cpp/mn_pvalue_cpp) — under the null, the two
arms' event probabilities are re-estimated subject to the constraint
\(\hat p_T - \hat p_C = \delta\), and the resulting score statistic is
compared to its asymptotic normal distribution, with a small-sample bias
correction factor \((n_T+n_C)/(n_T+n_C-1)\) applied to the naive Wald
variance used elsewhere (e.g. in $compute_estimate_with_bootstrap_weights(),
which never gets this correction since it skips the score-test path
entirely). This score-based interval generally has better small-sample
coverage than the naive normal-approximation Wald interval on the risk
difference.
References
Miettinen, O., and Nurminen, M. (1985). "Comparative Analysis of Two Rates." Statistics in Medicine, 4(2), 213-226, doi:10.1002/sim.4780040211 , for the restricted-maximum-likelihood score method used here.
Super class
Inference -> InferenceIncidMiettinenNurminenRiskDiff
Methods
Public methods
+ inherited public methods from Inference
Inference$capabilities()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()
InferenceIncidMiettinenNurminenRiskDiff$new()
Uses the shared randomization two-sided p-value contract; see
InferenceRand.
Initialize a Miettinen-Nurminen risk-difference inference object for a completed design with an incidence response.
Usage
InferenceIncidMiettinenNurminenRiskDiff$new(
des_obj,
model_formula = NULL,
verbose = FALSE
)Arguments
des_objA completed
DesignSeqOneByOneobject with an incidence response.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.
Examples
seq_des = DesignSeqOneByOneBernoulli$new(n = 20, response_type = "incidence")
for (i in 1:20) {
x_i = data.frame(x1 = rnorm(1), x2 = rnorm(1))
w_i = seq_des$add_one_subject_to_experiment_and_assign(x_i)
p_i = plogis(-0.8 + 0.5 * w_i)
seq_des$add_one_subject_response(i, rbinom(1, 1, p_i))
}
seq_des_inf = InferenceIncidMiettinenNurminenRiskDiff$new(seq_des)
seq_des_inf$compute_estimate()InferenceIncidMiettinenNurminenRiskDiff$compute_estimate()
Computes the observed (unadjusted) risk-difference estimate
\(\hat p_T - \hat p_C\) (see class documentation for the full
Miettinen-Nurminen inference model). NA if either arm is empty.
InferenceIncidMiettinenNurminenRiskDiff$compute_estimate_with_bootstrap_weights()
Recomputes the risk-difference estimate under subject/block
bootstrap weights: the weighted event proportions \(\hat p_T^w =
\sum_i r_i y_i \mathbb{1}[w_i=1] / \sum_i r_i \mathbb{1}[w_i=1]\) (and
analogously for control), differenced. Used by the Bayesian bootstrap
and related weighted-resampling machinery; see
InferenceBayesianBootstrap.
Always leaves the standard error and degrees of freedom unavailable
(NA) regardless of estimate_only — this weighted path
never computes the Miettinen-Nurminen score-based variance.
InferenceIncidMiettinenNurminenRiskDiff$compute_asymp_confidence_interval()
Computes a \(1-\alpha\) Miettinen-Nurminen restricted-MLE
score confidence interval for the risk difference (see class
documentation for the full method), by bisection-inverting the score
test (mn_ci_cpp) to pval_epsilon tolerance.
InferenceIncidMiettinenNurminenRiskDiff$compute_asymp_two_sided_pval()
Computes a two-sided Miettinen-Nurminen restricted-MLE
score p-value (mn_pvalue_cpp) testing \(H_0: p_T - p_C =
\code{delta}\) (see class documentation for the full method).
Examples
# \donttest{
seq_des = DesignSeqOneByOneBernoulli$new(n = 10, response_type = 'incidence')
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(rbinom(10, 1, 0.5))
inf = InferenceIncidMiettinenNurminenRiskDiff$new(seq_des)
inf$compute_estimate()
#> [1] -0.3809524
# }
## ------------------------------------------------
## Method `InferenceIncidMiettinenNurminenRiskDiff$new()`
## ------------------------------------------------
if (FALSE) { # \dontrun{
seq_des = DesignSeqOneByOneBernoulli$new(n = 20, response_type = "incidence")
for (i in 1:20) {
x_i = data.frame(x1 = rnorm(1), x2 = rnorm(1))
w_i = seq_des$add_one_subject_to_experiment_and_assign(x_i)
p_i = plogis(-0.8 + 0.5 * w_i)
seq_des$add_one_subject_response(i, rbinom(1, 1, p_i))
}
seq_des_inf = InferenceIncidMiettinenNurminenRiskDiff$new(seq_des)
seq_des_inf$compute_estimate()
} # }