Skip to contents

Fits 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

+ inherited public methods from Inference


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_obj

A completed DesignSeqOneByOne object with an incidence response.

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.

verbose

Whether 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.

Usage

InferenceIncidMiettinenNurminenRiskDiff$compute_estimate(estimate_only = FALSE)

Arguments

estimate_only

If TRUE, skip variance component calculations.


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.

Usage

InferenceIncidMiettinenNurminenRiskDiff$compute_estimate_with_bootstrap_weights(
  subject_or_block_weights,
  estimate_only = FALSE
)

Arguments

subject_or_block_weights

Bootstrap weights at the subject or block level.

estimate_only

Present for interface parity; this method never computes variance components regardless of its value.


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.

Usage

InferenceIncidMiettinenNurminenRiskDiff$compute_asymp_confidence_interval(
  alpha = 0.05,
  pval_epsilon = 1e-07
)

Arguments

alpha

The confidence level in the computed confidence interval is 1 - alpha. The default is 0.05.

pval_epsilon

Bisection tolerance for CI bounds.


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).

Usage

InferenceIncidMiettinenNurminenRiskDiff$compute_asymp_two_sided_pval(delta = 0)

Arguments

delta

The null treatment effect on the risk-difference scale.


InferenceIncidMiettinenNurminenRiskDiff$clone()

The objects of this class are cloneable with this method.

Usage

InferenceIncidMiettinenNurminenRiskDiff$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

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()
} # }