Skip to contents

Fits the same all-subject logistic working model as InferenceIncidKKGCompRiskDiff for a KK incidence outcome using treatment and, optionally, all recorded covariates, then estimates the marginal (standardized, g-computation) risk ratio \(\hat\theta = \left(n^{-1}\sum_i \hat p(1, X_i)\right) / \left(n^{-1}\sum_i \hat p(0, X_i)\right)\) by averaging fitted-model predicted risks under all-treated and all-control assignments over the empirical covariate distribution (Robins 1986). Matched pairs are treated as clusters and reservoir subjects are treated as singletons when computing the sandwich covariance; the delta method is applied on the log-risk-ratio scale to keep the reported ratio and its confidence interval positive, then back-transformed for reporting.

Computes the randomization distribution of the treatment effect estimate under the sharp null.

Whether compute_rand_two_sided_pval() is actually usable on this instance right now – FALSE exactly when it would stop(): an incidence-response instance with no custom randomization statistic and a design not eligible for design-randomization-based incidence inference (see private$should_use_design_randomization_for_incidence()). TRUE for every other case, including every non-incidence response type. Public, self-contained (only reads already-set instance state, no side effects), so InferenceSuite can check this before attempting the sentinel instead of relying on the stop() being silently swallowed into a pval = NA "ok" row – the single source of truth for both this check and compute_rand_two_sided_pval()'s own guard, so the two can never drift apart.

Value

When debug = FALSE (default), a numeric vector of length r. When debug = TRUE, a list with: values, errors (list of character vectors, one per iteration), warnings (list of character vectors, one per iteration), num_errors, num_warnings, prop_iterations_with_errors, prop_iterations_with_warnings, and prop_illegal_values.

A single logical.

Details

This estimator has likelihood_tier = "none". If the working model fails to converge, has no treatment-arm variation, or the all-control standardized risk is zero (undefined ratio), the estimate is marked non-estimable via is_nonestimable().

Bayesian-bootstrap intervals. The type = "studentized" ("bootstrap-t") interval of $compute_bayesian_bootstrap_confidence_interval() is studentized on the raw risk-ratio scale and undercovers in small samples: in a simulation with a logistic outcome model, two covariates and a true risk ratio of about 1.4, a nominal 95% interval covered about 89% of the time at \(n = 60\) and about 93% at \(n = 200\). Large replicate estimates come with large replicate standard errors, which compresses the upper tail of the pivot, so the interval misses mostly on one side (the true ratio falls below the lower bound). For small samples prefer type = "symmetric-percentile-t", a symmetric studentized interval built on the log risk-ratio scale and back-transformed (about 93% in the same simulation), or the log-scale type = "wald" or type = "basic" intervals or type = "percentile" (about 94%). "symmetric-percentile-t" is available only for the risk-ratio classes.

Separation. When the logistic working model's fitted probabilities are numerically 0 or 1 (the data look (quasi-)completely separated) the working-model MLE does not exist and the fitted risks sit where the fitter stopped. The class then raises one warning of class edi_logistic_separation_warning per object (silent inside resampling); the returned values are unchanged. A randomization test or an exact incidence method is safer there.

Subsampling and m-out-of-n. The subsampling and m-out-of-n bootstrap p-values and intervals use the log-scale pivot \(\sqrt{b}(\log\widehat{RR}^* - \log\widehat{RR})\). At the default size \(b = m = \lfloor n^{0.7} \rfloor\) (21 at \(n = 80\)) a draw has only a few events per arm, so with non-negligible probability it is degenerate: (i) an arm of the draw has no events or only events, (ii) the logistic fit reports that it did not converge, or (iii) the fit is (quasi-)separated, i.e. some fitted probability is numerically 0 or 1 (\(|x_i^\top\hat\beta| \ge \mathrm{logit}(1 - 10^{-8})\), the criterion of the separation warning). A degenerate draw's log risk ratio is about \(\pm 20\), where the fitter stopped. Subsampling estimates the sampling law of the estimator at size \(b\) and relies on it being close to the law at size \(n\) (Politis, Romano and Wolf 1999, Theorem 2.2.1; 2001); at small \(b\) that law puts a few percent of its mass on these atoms, which land in the tail the test uses and put a floor of about twice their fraction under the p-value. Kept, they made the tests almost never reject (null size 0.005 for subsampling and 0.000 for m-out-of-n at \(n = 80\), nominal 0.05). Degenerate draws are therefore unusable: the approximate_subsampling_distribution_beta_hat_T() and approximate_m_out_of_n_bootstrap_distribution_beta_hat_T() replicates are NaN for them. If fewer than min_fraction_usable_samples (default 0.8) of the B draws are usable (not degenerate and not failed), the p-value or interval is NA, the reason ("subsampling_too_few_usable_draws_fraction" or "m_out_of_n_too_few_usable_draws_fraction") is recorded and one warning of class edi_procedure_na_warning is raised (silent inside resampling); otherwise the usable draws are used. In a null simulation at \(n = 80\) (200 data sets, event rate about 0.41, B = 199) dropping the degenerate draws alone gave null sizes of 0.040 (subsampling) and 0.030 (m-out-of-n). The default cap is 0.8 rather than the 0.95 of the ordinary bootstrap's na.rm = TRUE rule because degenerate draws pile up in the data sets where \(\log\widehat{RR}\) is extreme, which are the ones a test should reject: in the same simulation a cap of 0.95 returned NA for 9% (subsampling) and 29% (m-out-of-n) of the null data sets, including 7 and 9 of the 11 where the Wald test rejects, and the size among the rest fell to 0.016 and 0.000 (0.90: NA for 2% and 5%, size 0.031 and 0.011); at 0.8 no data set was NA and the sizes stayed 0.040 and 0.030. Set min_fraction_usable_samples higher to return NA sooner, or lower (down to 0) to use whatever usable draws there are. The p-value is symmetric (since v1.0.6-TODO-230): with the pivot draws \(T^*_j = \sqrt{b}(\log\widehat{RR}^*_j - \log\widehat{RR})\) (\(\sqrt{m}\) for m-out-of-n) and \(t = \sqrt{n}(\log\widehat{RR} - \log\delta)\), it is the share of usable draws with \(|T^*_j| \ge |t|\) (at least \(1/B\)), not the equal-tailed \(2\min\{P(T^* \le t), P(T^* \ge t)\}\). At small \(b\) the law of \(\log\widehat{RR}^*\) is skewed toward the observed effect: in a data set with an extreme estimate one arm has few events, so the draws have a heavy tail on the side of \(t\) and almost none on the other side, and the equal-tailed rule doubles that heavy tail. Null size at \(n = 80\) (200 data sets, B = 199, nominal 0.05, Wald 0.055 / 0.050): InferenceIncidGCompRiskRatio subsampling 0.040 to 0.055 and m-out-of-n 0.030 to 0.035; InferenceIncidKKGCompRiskRatio 0.015 to 0.045 and 0.010 to 0.015 (its m-out-of-n pivot is about 15% wider than the Wald scale, so it stays conservative). The confidence intervals are unchanged (basic, equal-tailed quantiles of the same pivot), so a p-value and an interval can disagree at the boundary. For the risk ratio the ordinary bootstrap (compute_bootstrap_two_sided_pval(), compute_bootstrap_confidence_interval()) is the recommended resampling method: the estimator is smooth, the \(n\)-out-of-\(n\) bootstrap is consistent, and resampling fewer than \(n\) units only adds these small-sample failures. Firth-penalized fits inside the draws are planned as an option.

Small-sample behaviour

How fast the size (and coverage) error of each procedure is expected to vanish as the effective sample size \(n_{eff}\) grows, from EDI's convergence-rate registry (inference_convergence_expectation()). Exact procedures are valid at every n by construction; the others are asymptotic, so a small-sample excess is expected, and its constant is not given by an order. The table is the expectation for a balanced complete-randomization design; it is not a measured size. Reference keys are explained under References.

ProcedureRegimeError orderEffective nRegularityBasisReferences
randfinite sampleexactpairs + reservoirregulartheory[Fisher1935], [LehmannRomano2005]
waldasymptotic\(O(n_{eff}^{-1})\)pairs + reservoirregularassumed default[Hall1992]
jackknifeasymptotic\(O(n_{eff}^{-1})\)pairs + reservoirregularassumed default[ShaoTu1995]
bootstrapasymptotic\(O(n_{eff}^{-1})\)pairs + reservoirregularassumed default[Hall1992]
bayes_bootasymptotic\(O(n_{eff}^{-1})\)pairs + reservoirregularassumed default[Rubin1981], [Lo1987]
rand_bootstrapasymptotic\(O(n_{eff}^{-1})\)pairs + reservoirregularassumed default[Hall1992], [Kallus2018]

The point estimate's bias is of order \(O(n_{eff}^{-1})\) (assumed default: [CoxSnell1968]).

Rows with basis assumed default: the order shown is the procedure's rate in a regular parametric model, and the cited works establish it for that case only. EDI has not derived it for this class.

References

Robins, J. (1986). A new approach to causal inference in mortality studies with a sustained exposure period—application to control of the healthy worker survivor effect. Mathematical Modelling, 7(9-12), 1393-1512. doi:10.1016/0270-0255(86)90088-6

[Fisher1935] Fisher, R. A. (1935). The Design of Experiments. Oliver and Boyd.

[LehmannRomano2005] Lehmann, E. L., and Romano, J. P. (2005). Testing Statistical Hypotheses (3rd ed.). Springer.

[Hall1992] Hall, P. (1992). The Bootstrap and Edgeworth Expansion. Springer.

[ShaoTu1995] Shao, J., and Tu, D. (1995). The Jackknife and Bootstrap. Springer.

[Rubin1981] Rubin, D. B. (1981). "The Bayesian Bootstrap." The Annals of Statistics, 9(1), 130-134.

[Lo1987] Lo, A. Y. (1987). "A Large Sample Study of the Bayesian Bootstrap." The Annals of Statistics, 15(1), 360-375.

[Kallus2018] Kallus, N. (2018). "Optimal a priori balance in the design of controlled experiments." Journal of the Royal Statistical Society: Series B, 80(1), 85-112. Section 5 ("Algorithms for inference"), Algorithm 4.

[CoxSnell1968] Cox, D. R., and Snell, E. J. (1968). "A General Definition of Residuals." Journal of the Royal Statistical Society: Series B, 30(2), 248-265 (discussion 265-275).

Super class

Inference -> InferenceIncidKKGCompRiskRatio

Methods

+ inherited public methods from Inference


InferenceIncidKKGCompRiskRatio$approximate_randomization_distribution_beta_hat_T()

Usage

InferenceIncidKKGCompRiskRatio$approximate_randomization_distribution_beta_hat_T(
  r = 501,
  delta = 0,
  transform_responses = "none",
  show_progress = TRUE,
  permutations = NULL,
  debug = FALSE,
  zero_one_logit_clamp = .Machine$double.eps
)

Arguments

r

Number of randomization vectors. Default 501.

delta

The null difference. Default 0.

transform_responses

Type of transformation. Default "none".

show_progress

Show progress bar. Default TRUE.

permutations

Pre-computed permutations. Default NULL.

debug

If TRUE, return a list with the distribution values and per-iteration diagnostics including error messages, warning messages, counts of each, and summary proportions for iterations with errors, warnings, and illegal (non-finite) values. Runs serially. Default FALSE.

zero_one_logit_clamp

The clamping amount for exact 0 and 1 values when logging


InferenceIncidKKGCompRiskRatio$supports_rand_pval_for_incidence()

Usage

InferenceIncidKKGCompRiskRatio$supports_rand_pval_for_incidence()


InferenceIncidKKGCompRiskRatio$clone()

The objects of this class are cloneable with this method.

Usage

InferenceIncidKKGCompRiskRatio$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# \donttest{
seq_des = DesignSeqOneByOneKK14$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), x2 = rnorm(1)))
}
seq_des$add_all_subject_responses(rbinom(10, 1, 0.5))
inf = InferenceIncidKKGCompRiskRatio$new(seq_des)
inf$compute_estimate()
#> [1] 0.9486529
# }