--- title: "Which procedure can I trust at my sample size?" output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Which procedure can I trust at my sample size?} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>", eval = FALSE) ``` `run_all_inference()` returns many tests and intervals for the same data. They do not all deserve the same trust at a small sample size. This page says which ones are valid at every sample size, which ones are valid only as the sample grows, how fast, and for which classes nobody knows. Citation keys in square brackets, such as `[Hall1992]`, are entries of `REFERENCES.md`. The tables below are not typed by hand. They are rendered from the registry in `R/inference_procedure_regime.R` by `R/package_tests/render_procedure_trust_tables.R`, and a test fails if this page and the registry disagree. Nothing on this page was tuned to simulation output. ## Two regimes Every procedure is in one of two regimes. * **Finite sample.** Valid at every sample size by construction: the `exact` tests and the randomization test `rand`. Their size should be at the nominal level at n = 10 as well as n = 1000. If one is off, that is a defect, not an expected small-sample effect. The `rand` test is exact under the sharp null `[Fisher1935]`. * **Asymptotic.** Everything else: Wald, jackknife, score, likelihood-ratio, gradient, the Bartlett-corrected likelihood ratios, the parametric, ordinary and Bayesian bootstraps, and the randomization bootstrap. These are valid as the sample size grows. At a small sample, a size above the nominal level is expected, and the question is how large it is. The regime is a property of the procedure, not of the class. A finite-sample procedure that falls back to a normal approximation in some cell is still labelled finite sample, so a miss there counts as a defect to fix. ## How fast, and in what sample size For an asymptotic procedure, the registry gives the order of the two-sided size (or coverage) error, written O(n^-k) and read "the error shrinks like n to the power minus k". A larger k means the procedure becomes reliable at a smaller sample size. The orders for a regular parametric model are in the first table. They come from Edgeworth expansions `[Hall1992]` and chi-square approximation errors `[BarndorffNielsenCox1994]`. The bias of the point estimate is O(n^-1) for a regular maximum-likelihood estimate `[CoxSnell1968]`. The difference in means is unbiased under randomization `[Neyman1923]`. The "n" in an order is not always the number of subjects. The effective-n rule says which count drives the error. Matched designs are limited by the number of pairs, survival models by the number of events, hurdle models by the number of nonzero counts, and an unequal allocation by the smaller arm. The second table lists the rules. An order says how the error shrinks. It does not give the constant in front of it. A procedure with a better order can still be worse at n = 30. **Procedures.** | Procedure | Regime | Size error in a regular model | Basis of that rate | Citations | |---|---|---|---|---| | `exact` | finite sample | exact | theory | none | | `rand` | finite sample | exact | theory | [Fisher1935] [LehmannRomano2005] | | `wald` | asymptotic | O(n^-1) | theory | [Hall1992] [CoxSnell1968] | | `jackknife` | asymptotic | O(n^-1) | literature | [ShaoTu1995] | | `score` | asymptotic | O(n^-1) | theory | [BarndorffNielsenCox1994] | | `lik_ratio` | asymptotic | O(n^-1) | theory | [BarndorffNielsenCox1994] | | `gradient` | asymptotic | O(n^-1) | literature | [Terrell2002] [Lemonte2016] | | `lik_ratio_bartlett_approx` | asymptotic | O(n^-2) | literature | [Lawley1956] [BarndorffNielsenHall1988] | | `lik_ratio_bartlett_exact` | asymptotic | O(n^-2) | literature | [Lawley1956] [BarndorffNielsenHall1988] | | `param_boot` | asymptotic | O(n^-2) | literature | [Beran1988] [DiCiccioMartinStern2001] | | `param_boot_direct` | asymptotic | O(n^-1) | literature | [Hall1992] | | `bootstrap` | asymptotic | O(n^-1) | literature | [Hall1992] | | `bayes_boot` | asymptotic | O(n^-1) | literature | [Rubin1981] [Lo1987] | | `rand_bootstrap` | asymptotic | O(n^-1) | assumed default | none | **Effective-n rules** (every rule other than `n`). | Effective n | Meaning | Applies to | |---|---|---| | `n` | number of subjects | every other class and design | | `n_pairs` | number of matched pairs | `InferenceOrdinalPairedSignTest` | | `n_pairs_plus_reservoir` | matched pairs plus unmatched subjects | 26 classes | | `n_min_arm` | size of the smaller arm | designs `@prob_T` | | `n_events` | number of events (failures, or incident cases) | 25 classes | | `n_nonzero` | number of nonzero counts | `InferenceCountHurdleNegBin`, `InferenceCountHurdlePoisson`, `InferenceCountKKHurdlePoissonOneLik` | | `n_clusters` | number of clusters | designs `DesignFixedBlockedCluster`, `DesignFixedCluster` | | `n_strata` | number of strata | `InferenceIncidCMH` | **Non-regular cases.** Classes counted once per kind. | Kind | Classes | Size error | Why | Citations | |---|---|---|---|---| | boundary | 2 | unknown | The estimate can sit on the edge of the parameter space (a fitted probability at 0 or 1), where the usual limit does not apply. | [SelfLiang1987] | | variance component | 10 | unknown | A random-effect variance near zero is on the boundary, and the likelihood limit for it is not chi-square. | [SelfLiang1987] [StramLee1994] | | mixture | 3 | unknown | The inflation probability can be on the boundary, where the information is singular. | [SelfLiang1987] | | nonparametric rate | 4 | O(n^-2/3) | The standard error needs an estimate of the density at the quantile (the sparsity), which converges slower than n^-1/2. | [HallSheather1988] [Koenker2005] [Powell1991] | | design mismatch | 2 | O(1) | The variance formula ignores the covariate balancing of the design, so the interval stays conservative as n grows. | [BaiRomanoShaikh2021] [BugniCanayShaikh2018] [LiDingRubin2018] | | other | 3 | unknown | Non-standard limit: unidentified nuisance parameters under the null, or an estimated scale. | [Davies1977] [Huber1981] | **Classes whose rate is not known.** | Kind | Classes whose rate is not known | |---|---| | boundary | `InferenceIncidBinomialIdentityRiskDiff`, `InferenceIncidLogBinomial` | | mixture | `InferenceCountZeroInflatedNegBin`, `InferenceCountZeroInflatedPoisson`, `InferencePropZeroOneInflatedBetaRegr` | | other | `InferenceContinKKRobustRegrOneLik`, `InferenceContinRobustRegr`, `InferenceOrdinalStereotypeLogitRegr` | | variance component | `InferenceContinKKGLMM`, `InferenceCountKKGLMM`, `InferenceOrdinalKKCLMM`, `InferenceOrdinalKKCLMMCauchit`, `InferenceOrdinalKKCLMMCloglog`, `InferenceOrdinalKKCLMMProbit`, `InferenceOrdinalKKGLMM`, `InferencePropKKGLMM`, `InferenceSurvivalGLMMWeibullFrailtyLoggammaOneLik`, `InferenceSurvivalGLMMWeibullFrailtyNormalOneLik` | Two cautions on the first table. The default `bootstrap` type is BCa, whose two-sided error is O(n^-2) in theory, but it falls back to a percentile interval in some cases and some classes are pinned to it, so the table gives the percentile order as a lower bound. The order of `rand_bootstrap` was not derived anywhere I could find; the bootstrap order is assumed and no citation is given. ## The non-regular cases The orders above hold in a regular model. Some classes are not regular. The last two tables list them. For most of them the registry records the rate as **unknown**, which means exactly that: no order was derived or measured. It does not mean the procedure is bad. It means do not read the first table as a promise for these classes. * **Boundary.** A log-binomial or identity-link risk-difference fit can put a fitted probability on the edge of its range. The usual limit theory assumes an interior point `[SelfLiang1987]`. * **Variance components.** The mixed-model classes carry a random-effect variance that can be near zero. A variance on the boundary has a non-chi-square limit `[SelfLiang1987]` `[StramLee1994]`, and its effect on the treatment test is not characterised here. * **Zero (and one) inflation.** The inflation probability can sit on the boundary of its range, where the information matrix is singular `[SelfLiang1987]`. * **Quantile-regression sparsity.** The Wald standard error needs the density of the response at the quantile. Estimating it converges slower than the usual rate. For a studentised sample quantile the coverage error is O(n^-2/3) `[HallSheather1988]`; extending that to the regression Wald is by analogy, not proved (see `[Koenker2005]`, `[Powell1991]`). * **Design mismatch.** The unadjusted two-sample classes, with a variance formula that ignores covariate balancing, on a matched, blocked, rerandomized or minimized design. The interval is conservative and stays conservative as n grows, so the error order is O(1). This is an upper-bound statement: it is zero when the balanced covariates do not predict the outcome `[BaiRomanoShaikh2021]` `[BugniCanayShaikh2018]` `[LiDingRubin2018]`. * **Other.** Stereotype logit has category scores that are not identified under the null `[Davies1977]`. Robust regression with an estimated scale has a known first-order limit but no known higher-order rate `[Huber1981]`. ## How much of this is known Each (design, class, procedure) cell has a basis for its rate: * **theory**: derived. This is every `exact` and `rand` cell, and the bias of a difference in means. * **literature**: taken from a published result for a close case. * **assumed default**: the procedure's rate in a regular model, applied because nothing contradicts it for this class. It was not checked for the class. * **unknown**: no rate is known. * **empirical**: measured. None yet. The simulations so far are at a single sample size, which cannot give an order. Scope: 33 designs, 88 inference classes, 17,139 (design, class, procedure) triples, the ones the calibration study runs. | Regime | Triples | theory | literature | empirical | assumed default | unknown | |---|---|---|---|---|---|---| | finite sample | 1,826 | 1,826 | 0 | 0 | 0 | 0 | | asymptotic | 15,313 | 0 | 114 | 0 | 12,307 | 2,892 | | **all** | 17,139 | 1,826 | 114 | 0 | 12,307 | 2,892 | | Regularity (asymptotic procedures) | Triples | Share | |---|---|---| | regular | 12,307 | 80.4% | | boundary | 792 | 5.2% | | variance component | 364 | 2.4% | | mixture | 1,188 | 7.8% | | nonparametric rate | 74 | 0.5% | | design mismatch | 40 | 0.3% | | other | 548 | 3.6% | Of the 15,313 asymptotic triples, 80.4% rest on an assumed default and 18.9% have an unknown rate. Most asymptotic cells are assumed defaults. Treat the order of such a cell as a reasonable guess, not as a result. ## Measured results The calibration study measures the size, coverage and bias of each cell at fixed sample sizes, with Monte Carlo intervals. The published results are on the `calibration-results` branch: . Use them to see how far a particular cell is from its nominal level at your sample size. They are measurements at the design and sample sizes studied, not guarantees for other settings. ## What to do with this 1. Find your effective n for your design and class (second table). 2. If a finite-sample procedure fits your question, prefer it: it does not depend on n being large. 3. Otherwise, take an asymptotic procedure with a better order, and check the cell in the calibration results at a sample size near yours. 4. If your class is in the non-regular list, do not rely on the orders. Use the measured results, or a randomization test.