<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Jiahong Sun</title>
<link>https://sunjh22.github.io/</link>
<atom:link href="https://sunjh22.github.io/index.xml" rel="self" type="application/rss+xml"/>
<description>Bioinformatics, omics, algorithms, statistics, and scientific computing</description>
<generator>quarto-1.10.19</generator>
<lastBuildDate>Fri, 16 Oct 2026 00:00:00 GMT</lastBuildDate>
<item>
  <title>Logistic Regression</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/logistic-regression.html</link>
  <description><![CDATA[ 





<section id="the-binary-outcome-model" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> The Binary-outcome Model</h1>
<p>For independent experimental units <img src="https://latex.codecogs.com/png.latex?i=1,%5Cldots,n">, let <img src="https://latex.codecogs.com/png.latex?Y_i=1"> denote an event and <img src="https://latex.codecogs.com/png.latex?Y_i=0"> its complement. Logistic regression specifies a Bernoulli sampling model and a linear predictor:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_i%5Cmid%20%5Cmathbf%20x_i%5Csim%5Coperatorname%7BBernoulli%7D(p_i),%0A%5Cqquad%0A%5Clog%5C!%5Cleft(%5Cfrac%7Bp_i%7D%7B1-p_i%7D%5Cright)%0A=%5Ceta_i=%5Cmathbf%20x_i%5E%5Cmathsf%20T%5Cboldsymbol%5Cbeta.%0A"></p>
<p>The inverse-logit transformation keeps fitted probabilities between zero and one:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%0Ap_i=%5CPr(Y_i=1%5Cmid%5Cmathbf%20x_i)%0A=%5Cfrac%7B%5Cexp(%5Ceta_i)%7D%7B1+%5Cexp(%5Ceta_i)%7D%0A%7D.%0A"></p>
<p>The outcome coding, time horizon, target population, and experimental unit must be declared. “Response” might mean disease within one year, successful amplification, or membership in a cell type; changing its definition changes the estimand and model. The model concerns a conditional event probability. It does not say that a unit’s realized zero or one is deterministic.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th>Quantity</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="https://latex.codecogs.com/png.latex?p_i"></td>
<td>Conditional event probability for covariates <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20x_i"></td>
</tr>
<tr class="even">
<td><img src="https://latex.codecogs.com/png.latex?%5Ceta_i"></td>
<td>Linear predictor, or log odds</td>
</tr>
<tr class="odd">
<td><img src="https://latex.codecogs.com/png.latex?%5Cbeta_j"></td>
<td>Conditional log-odds coefficient</td>
</tr>
<tr class="even">
<td><img src="https://latex.codecogs.com/png.latex?%5Cexp(%5Cbeta_j)"></td>
<td>Conditional odds ratio for a one-unit predictor contrast</td>
</tr>
<tr class="odd">
<td><img src="https://latex.codecogs.com/png.latex?%5Chat%20p_i"></td>
<td>Fitted probability after estimating the coefficients</td>
</tr>
</tbody>
</table>
<p>An estimand might be a conditional log odds ratio, a standardized risk difference, or out-of-sample event probability. The coefficient vector is a parameter under the working model; <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cboldsymbol%5Cbeta%7D"> is an estimator before observing data and a numerical estimate afterward.</p>
</section>
<section id="coefficients-and-contrasts" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Coefficients and Contrasts</h1>
<p>With one continuous predictor,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7Blogit%7D%5C%7Bp(x)%5C%7D=%5Cbeta_0+%5Cbeta_1x.%0A"></p>
<p>A one-unit increase in <img src="https://latex.codecogs.com/png.latex?x"> multiplies the conditional odds by <img src="https://latex.codecogs.com/png.latex?%5Cexp(%5Cbeta_1)">. For a contrast of <img src="https://latex.codecogs.com/png.latex?d"> units, the odds ratio is <img src="https://latex.codecogs.com/png.latex?%5Cexp(d%5Cbeta_1)">. The associated probability difference is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap(x+d)-p(x)%0A=%5Coperatorname%7Bexpit%7D%5C%7B%5Cbeta_0+%5Cbeta_1(x+d)%5C%7D%0A-%5Coperatorname%7Bexpit%7D(%5Cbeta_0+%5Cbeta_1x),%0A"></p>
<p>which depends on the starting value <img src="https://latex.codecogs.com/png.latex?x"> and all other predictors. A constant odds ratio therefore does not imply a constant risk difference.</p>
<p>For a binary predictor <img src="https://latex.codecogs.com/png.latex?A"> in</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7Blogit%7D%5CPr(Y=1%5Cmid%20A,%5Cmathbf%20Z)%0A=%5Cbeta_0+%5Cbeta_AA+%5Cboldsymbol%5Cgamma%5E%5Cmathsf%20T%5Cmathbf%20Z,%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cexp(%5Cbeta_A)"> compares conditional odds at common modeled values of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20Z">. This is an adjusted association. A causal interpretation additionally requires a defensible treatment definition, exchangeability, positivity, consistency, and appropriate handling of selection, missingness, and measurement.</p>
<p>Interactions make the log-odds contrast depend on another predictor. With <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7BAX%7DAX">, the conditional odds ratio for <img src="https://latex.codecogs.com/png.latex?A"> at <img src="https://latex.codecogs.com/png.latex?X=x"> is <img src="https://latex.codecogs.com/png.latex?%5Cexp(%5Cbeta_A+%5Cbeta_%7BAX%7Dx)">. As with linear regression, lower-order coefficients refer to the other variable’s reference value.</p>
</section>
<section id="likelihood-and-estimation" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Likelihood and Estimation</h1>
<p>Conditional independence across experimental units gives the likelihood</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AL(%5Cboldsymbol%5Cbeta)%0A=%5Cprod_%7Bi=1%7D%5E%7Bn%7Dp_i%5E%7By_i%7D(1-p_i)%5E%7B1-y_i%7D,%0A"></p>
<p>and log-likelihood</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cell(%5Cboldsymbol%5Cbeta)%0A=%5Csum_%7Bi=1%7D%5E%7Bn%7D%5Cleft%5B%0Ay_i%5Cmathbf%20x_i%5E%5Cmathsf%20T%5Cboldsymbol%5Cbeta%0A-%5Clog%5C%7B1+%5Cexp(%5Cmathbf%20x_i%5E%5Cmathsf%20T%5Cboldsymbol%5Cbeta)%5C%7D%0A%5Cright%5D.%0A"></p>
<p>Let <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20p=(p_1,%5Cldots,p_n)%5E%5Cmathsf%20T"> and <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20W=%5Coperatorname%7Bdiag%7D%5C%7Bp_i(1-p_i)%5C%7D">. Differentiation gives</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbf%20U(%5Cboldsymbol%5Cbeta)%0A=%5Cfrac%7B%5Cpartial%5Cell%7D%7B%5Cpartial%5Cboldsymbol%5Cbeta%7D%0A=%5Cmathbf%20X%5E%5Cmathsf%20T(%5Cmathbf%20y-%5Cmathbf%20p),%0A%5Cqquad%0A-%5Cfrac%7B%5Cpartial%5E2%5Cell%7D%0A%7B%5Cpartial%5Cboldsymbol%5Cbeta%5Cpartial%5Cboldsymbol%5Cbeta%5E%5Cmathsf%20T%7D%0A=%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20W%5Cmathbf%20X.%0A"></p>
<p>The maximum-likelihood estimate solves <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20U=%5Cmathbf0">. There is generally no closed form, so software uses Newton–Raphson, Fisher scoring, or the equivalent iteratively reweighted least-squares calculation. Concavity makes a finite, identified solution unique when the design has full rank and the outcomes are not separated by the predictors.</p>
<p>At a regular finite solution, the model-based covariance estimate is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%7B%5Coperatorname%7BVar%7D%7D(%5Chat%7B%5Cboldsymbol%5Cbeta%7D)%0A=(%5Cmathbf%20X%5E%5Cmathsf%20T%5Chat%7B%5Cmathbf%20W%7D%5Cmathbf%20X)%5E%7B-1%7D.%0A"></p>
<p>Wald intervals use this local quadratic approximation. Likelihood-ratio or profile- likelihood intervals often behave better for sparse data or asymmetric likelihoods. All are conditional on the model, sampling structure, and prespecified analysis.</p>
</section>
<section id="a-small-calculation" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> A Small Calculation</h1>
<p>Suppose a fitted model for a binary assay failure is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7Blogit%7D(p)=-2+0.8x,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?x"> is a centered quality score. At <img src="https://latex.codecogs.com/png.latex?x=0">,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap(0)=%5Coperatorname%7Bexpit%7D(-2)%5Capprox0.119.%0A"></p>
<p>At <img src="https://latex.codecogs.com/png.latex?x=1">, the odds are multiplied by <img src="https://latex.codecogs.com/png.latex?%5Cexp(0.8)%5Capprox2.23">, but the probability is <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7Bexpit%7D(-1.2)%5Capprox0.231">, a risk increase of about 0.112 rather than 123%. At <img src="https://latex.codecogs.com/png.latex?x=2">, the probability is about 0.401. The example shows why the coefficient, odds ratio, and probability contrast answer related but different questions.</p>
</section>
<section id="assumptions-diagnostics-and-sensitivity" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Assumptions, Diagnostics, and Sensitivity</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Assumption or issue</th>
<th>Why it matters</th>
<th>Assessment</th>
<th>Response or sensitivity analysis</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Correct binary outcome and sampling model</td>
<td>Misclassification or informative sampling changes the target and likelihood</td>
<td>Audit outcome timing, labeling, and sampling fractions</td>
<td>Validation subset, misclassification or sampling model</td>
</tr>
<tr class="even">
<td>Independent experimental units</td>
<td>Naive information and standard errors count correlated observations repeatedly</td>
<td>Map donors, batches, families, sites, and repeated measures</td>
<td>Cluster-aware covariance, GEE, mixed model, or justified aggregation</td>
</tr>
<tr class="odd">
<td>Correct logit-scale mean structure</td>
<td>Omitted curvature or interaction distorts probabilities and odds ratios</td>
<td>Flexible plots, component-plus-residual ideas, held-out calibration</td>
<td>Splines, prespecified interactions, alternative links</td>
</tr>
<tr class="even">
<td>Full-rank design and overlap</td>
<td>Coefficients may be unidentified or extrapolative</td>
<td>Cross-tabulations, predictor support, rank and condition checks</td>
<td>Redesign, combine parameters, restrict the target population</td>
</tr>
<tr class="odd">
<td>No separation</td>
<td>Ordinary MLEs may diverge</td>
<td>Perfect or near-perfect prediction, huge estimates/SEs, iteration warnings</td>
<td>Verify data; use bias reduction or justified penalization</td>
</tr>
<tr class="even">
<td>Adequate information</td>
<td>Sparse events make asymptotic intervals unstable</td>
<td>Event/non-event counts and effective design information</td>
<td>Profile likelihood, bootstrap when valid, penalization, more independent units</td>
</tr>
<tr class="odd">
<td>No influential unit</td>
<td>One covariate pattern can determine a coefficient</td>
<td>Leverage, deviance/Pearson residuals, deletion diagnostics</td>
<td>Verify records and report leave-one-unit-out sensitivity</td>
</tr>
</tbody>
</table>
<p>Residuals are not normally distributed in a Bernoulli model. Deviance and Pearson residuals can reveal unusual patterns, but a binary observation contains little unit-level residual information. Binning residuals or probabilities can aid a display, yet conclusions can depend on arbitrary bins. Diagnostics cannot prove that confounding is absent or that a future population follows the same process.</p>
<section id="separation-and-finite-estimates" class="level2" data-number="5.1">
<h2 data-number="5.1" class="anchored" data-anchor-id="separation-and-finite-estimates"><span class="header-section-number">5.1</span> Separation and finite estimates</h2>
<p>If a linear combination of predictors perfectly distinguishes events from non-events, increasing a coefficient without bound keeps improving the ordinary likelihood. Software may report nonconvergence, fitted probabilities numerically equal to zero or one, enormous estimates, or misleading Wald results. Dropping a predictor solely to force convergence changes the estimand.</p>
<p>Firth’s bias-reducing score modification yields finite estimates in separated logistic models and reduces first-order bias. It is not a substitute for adequate design, and penalized estimates, intervals, and predicted probabilities must be reported as such. Bayesian regularization is another explicit modeling choice; its prior sensitivity matters when the data are weak.</p>
</section>
</section>
<section id="bioinformatics-design-and-interpretation" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Bioinformatics Design and Interpretation</h1>
<p>Consider whether 80 independent patient biopsies show a molecular response after treatment. A logistic model includes treatment, prespecified baseline severity, tissue type, and sequencing batch. Patients are the experimental units. Cells, reads, technical libraries, and repeated aliquots nested within one biopsy are not 80 additional independent treatment replicates.</p>
<p>If the outcome is instead defined for every cell, cell responses remain clustered within donors. A cell-level logistic model must represent donor dependence and the level at which treatment was assigned; pseudoreplication can otherwise make uncertainty implausibly small. If every responder was sequenced in one batch and every nonresponder in another, outcome and batch effects are not separately identified.</p>
<p>Statistically, a treatment coefficient describes a conditional log-odds contrast under the fitted model. Biologically, the result also depends on how response was defined, assay error, effect magnitude on an interpretable probability scale, patient heterogeneity, and transport to the target population. A small p-value or large odds ratio alone does not establish clinical or mechanistic importance.</p>
</section>
<section id="prediction-is-a-separate-goal" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Prediction Is a Separate Goal</h1>
<p>Likelihood fit on development data does not establish predictive usefulness. For risk prediction, evaluate probabilities on data not used for flexible model development. Report calibration, discrimination, and an overall proper score; none replaces the others. A classification threshold additionally encodes the relative consequences of false positives and false negatives and should not be chosen from accuracy alone.</p>
<p>For explanation or causal estimation, held-out prediction is informative about transport but does not diagnose confounding. Conversely, a causally interpretable coefficient need not produce an accurate individual risk model. State the goal before selecting predictors, regularization, metrics, and validation design.</p>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/odds-ratios-probabilities-and-calibration.html">Odds ratios, probabilities, and calibration</a> develops effect-scale interpretation and probability validation.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/likelihood-and-log-likelihood.html">Likelihood and log-likelihood</a> gives the inferential foundation for the Bernoulli likelihood.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/maximum-likelihood-estimation.html">Maximum-likelihood estimation</a> explains score equations, information, and nonregular failures.</li>
<li><a href="../../../knowledge/statistics/regression-models/categorical-predictors-and-contrasts.html">Categorical predictors and contrasts</a> covers coding and estimable comparisons.</li>
<li><a href="../../../knowledge/statistics/regression-models/interaction-terms-and-effect-modification.html">Interaction terms and effect modification</a> explains conditional effects and scale dependence.</li>
<li><a href="../../../knowledge/statistics/regression-models/robust-standard-errors-and-robust-regression.html">Robust standard errors and robust regression</a> separates covariance robustness from mean-model correctness.</li>
</ul>
<ol type="1">
<li>Logistic regression models a conditional Bernoulli probability through a linear predictor on the log-odds scale.</li>
<li>Exponentiated coefficients are conditional odds ratios, not probability differences or automatically causal effects.</li>
<li>Maximum likelihood is numerical and can fail to have a finite solution under separation.</li>
<li>Valid uncertainty depends on independent experimental units, adequate outcome information, identification, and a suitable data-generating model.</li>
<li>Prediction requires external or resampling-based validation of probabilities; coefficient inference and predictive performance are different tasks.</li>
</ol>
</section>
<section id="references" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> References</h1>
<ul>
<li>Cox, D. R. (1958). The regression analysis of binary sequences. <em>Journal of the Royal Statistical Society: Series B</em>, 20(2), 215–232. <a href="https://doi.org/10.1111/j.2517-6161.1958.tb00292.x" class="uri">https://doi.org/10.1111/j.2517-6161.1958.tb00292.x</a></li>
<li>McCullagh, P., and Nelder, J. A. (1989). <em>Generalized Linear Models</em> (2nd ed.). Chapman and Hall/CRC. <a href="https://doi.org/10.1201/9780203753736" class="uri">https://doi.org/10.1201/9780203753736</a></li>
<li>Firth, D. (1993). Bias reduction of maximum likelihood estimates. <em>Biometrika</em>, 80(1), 27–38. <a href="https://doi.org/10.1093/biomet/80.1.27" class="uri">https://doi.org/10.1093/biomet/80.1.27</a></li>
<li>Heinze, G., and Schemper, M. (2002). A solution to the problem of separation in logistic regression. <em>Statistics in Medicine</em>, 21(16), 2409–2419. <a href="https://doi.org/10.1002/sim.1047" class="uri">https://doi.org/10.1002/sim.1047</a></li>
<li>R Core Team. <code>glm</code>: fitting generalized linear models; <code>family</code>: family objects for models. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/glm.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/glm.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Logistic Regression</category>
  <category>Binary Outcomes</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/logistic-regression.html</guid>
  <pubDate>Fri, 16 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Odds Ratios, Probabilities, and Calibration</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/odds-ratios-probabilities-and-calibration.html</link>
  <description><![CDATA[ 





<section id="one-model-several-quantities" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> One Model, Several Quantities</h1>
<p>A binary-outcome model can yield a log-odds coefficient, an odds ratio, an individual predicted probability, or a population-average risk contrast. These quantities are not interchangeable.</p>
<p>For outcome <img src="https://latex.codecogs.com/png.latex?Y">, exposure <img src="https://latex.codecogs.com/png.latex?A">, and covariates <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20Z">, suppose</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7Blogit%7D%5CPr(Y=1%5Cmid%20A,%5Cmathbf%20Z)%0A=%5Cbeta_0+%5Cbeta_AA+%5Cboldsymbol%5Cgamma%5E%5Cmathsf%20T%5Cmathbf%20Z.%0A"></p>
<p>Then <img src="https://latex.codecogs.com/png.latex?%5Cexp(%5Cbeta_A)"> is a <strong>conditional odds ratio</strong> comparing <img src="https://latex.codecogs.com/png.latex?A=1"> with <img src="https://latex.codecogs.com/png.latex?A=0"> at common values of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20Z">. Conditional risks are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap_a(%5Cmathbf%20z)%0A=%5Coperatorname%7Bexpit%7D%5Cleft(%0A%5Cbeta_0+%5Cbeta_Aa+%5Cboldsymbol%5Cgamma%5E%5Cmathsf%20T%5Cmathbf%20z%0A%5Cright).%0A"></p>
<p>At covariate value <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20z">, the risk difference and risk ratio are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BRD%7D(%5Cmathbf%20z)=p_1(%5Cmathbf%20z)-p_0(%5Cmathbf%20z),%0A%5Cqquad%0A%5Coperatorname%7BRR%7D(%5Cmathbf%20z)=%5Cfrac%7Bp_1(%5Cmathbf%20z)%7D%7Bp_0(%5Cmathbf%20z)%7D.%0A"></p>
<p>The odds ratio can stay constant while these probability-scale effects change with baseline risk. Report the measure that answers the scientific question, rather than treating the easiest model coefficient as the estimand.</p>
</section>
<section id="odds-are-not-probabilities" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Odds Are Not Probabilities</h1>
<p>For probability <img src="https://latex.codecogs.com/png.latex?p">, the odds are <img src="https://latex.codecogs.com/png.latex?p/(1-p)">. If <img src="https://latex.codecogs.com/png.latex?p_0"> is a baseline probability and <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BOR%7D"> is an odds ratio, the corresponding exposed probability is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%0Ap_1=%5Cfrac%7B%5Coperatorname%7BOR%7D%5C,p_0%7D%0A%7B1-p_0+%5Coperatorname%7BOR%7D%5C,p_0%7D%0A%7D.%0A"></p>
<p>An odds ratio of 2 does not mean that the probability doubles. For example:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">Baseline risk <img src="https://latex.codecogs.com/png.latex?p_0"></th>
<th style="text-align: right;">Risk with OR = 2</th>
<th style="text-align: right;">Risk difference</th>
<th style="text-align: right;">Risk ratio</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0.01</td>
<td style="text-align: right;">0.0198</td>
<td style="text-align: right;">0.0098</td>
<td style="text-align: right;">1.98</td>
</tr>
<tr class="even">
<td style="text-align: right;">0.20</td>
<td style="text-align: right;">0.3333</td>
<td style="text-align: right;">0.1333</td>
<td style="text-align: right;">1.67</td>
</tr>
<tr class="odd">
<td style="text-align: right;">0.60</td>
<td style="text-align: right;">0.7500</td>
<td style="text-align: right;">0.1500</td>
<td style="text-align: right;">1.25</td>
</tr>
</tbody>
</table>
<p>The rare-outcome approximation <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BOR%7D%5Capprox%5Coperatorname%7BRR%7D"> is useful only when both risks are small enough for the intended precision. It does not turn a conditional association into a causal effect.</p>
</section>
<section id="conditional-and-marginal-effects" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Conditional and Marginal Effects</h1>
<p>Logistic odds ratios are <strong>non-collapsible</strong>. Even if a covariate is not a confounder, a conditional odds ratio adjusted for that covariate can differ from the marginal odds ratio because averaging probabilities and taking odds are nonlinear operations. A change after adjustment is therefore not, by itself, evidence of confounding.</p>
<p>To obtain a population-average risk under exposure level <img src="https://latex.codecogs.com/png.latex?a">, standardize the fitted probabilities over a declared target covariate distribution:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%20R_a%0A=%5Csum_%7Bi=1%7D%5E%7Bn%7Dw_i%0A%5Coperatorname%7Bexpit%7D%5Cleft(%0A%5Chat%5Cbeta_0+%5Chat%5Cbeta_Aa+%0A%5Chat%7B%5Cboldsymbol%5Cgamma%7D%5E%5Cmathsf%20T%5Cmathbf%20z_i%0A%5Cright),%0A%5Cqquad%20%5Csum_iw_i=1.%0A"></p>
<p>Then <img src="https://latex.codecogs.com/png.latex?%5Chat%20R_1-%5Chat%20R_0"> and <img src="https://latex.codecogs.com/png.latex?%5Chat%20R_1/%5Chat%20R_0"> are standardized risk difference and risk ratio estimates for the population represented by weights <img src="https://latex.codecogs.com/png.latex?w_i">. Equal weights over the study sample, survey weights, and external target- population weights define different estimands. Confidence intervals should carry coefficient-estimation uncertainty and, where relevant, uncertainty in the target distribution; delta-method, bootstrap, or simulation-based propagation can be used under their respective assumptions.</p>
<p>For a causal interpretation, standardization additionally needs conditional exchangeability, positivity, consistency, and correct treatment/outcome and covariate modeling. It is still valuable descriptively when causal identification is not claimed, provided the target and model are explicit.</p>
</section>
<section id="calibration-do-probabilities-mean-what-they-say" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Calibration: Do Probabilities Mean What They Say?</h1>
<p>A model is calibrated in a target setting when predicted probabilities agree with event frequencies at the relevant level. If all units assigned probability 0.20 were repeatedly observed under the same process, approximately 20% should have the event. Calibration is a property of predictions in a population and time period, not a permanent label attached to an algorithm.</p>
<p>Useful levels include:</p>
<ul>
<li><p><strong>Calibration-in-the-large:</strong> Is the mean predicted risk equal to the observed event proportion? Systematic overprediction or underprediction shifts this.</p></li>
<li><p><strong>Calibration slope:</strong> Regress the outcome on the original prediction logit, <img src="https://latex.codecogs.com/png.latex?%5Ceta=%5Coperatorname%7Blogit%7D(%5Chat%20p)">, in validation data:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7Blogit%7D%5CPr(Y=1%5Cmid%5Ceta)=%5Calpha+%5Czeta%5Ceta.%0A"></p>
<p>Ideal values are <img src="https://latex.codecogs.com/png.latex?%5Calpha=0"> and <img src="https://latex.codecogs.com/png.latex?%5Czeta=1">. A slope below one often signals predictions that are too extreme, as after overfitting; a slope above one means they vary too little in that population.</p></li>
<li><p><strong>Flexible calibration:</strong> Compare observed risk with predicted risk using a smooth curve and uncertainty, revealing local departures hidden by two numbers.</p></li>
</ul>
<p>An intercept-only recalibration can correct a changed event rate while preserving relative predictions. Intercept-and-slope recalibration can also shrink or expand the prediction logit. Such updating should use appropriate data and be evaluated again; it does not repair missing predictors, changed outcome definitions, selection bias, or unsupported covariate regions.</p>
</section>
<section id="calibration-discrimination-and-overall-accuracy" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Calibration, Discrimination, and Overall Accuracy</h1>
<p>These properties answer different questions:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Property</th>
<th>Question</th>
<th>Example measure</th>
<th>Important limitation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Calibration</td>
<td>Do predicted risks agree with observed risks?</td>
<td>Calibration curve, intercept, slope</td>
<td>Can change across settings and time</td>
</tr>
<tr class="even">
<td>Discrimination</td>
<td>Are events generally ranked above non-events?</td>
<td>ROC AUC / c-statistic</td>
<td>Invariant to many transformations that ruin probability calibration</td>
</tr>
<tr class="odd">
<td>Overall probabilistic accuracy</td>
<td>Are probability forecasts close to outcomes?</td>
<td>Brier score, log loss</td>
<td>Mixes calibration and resolution; depends on outcome prevalence</td>
</tr>
<tr class="even">
<td>Decision value</td>
<td>Do predictions improve decisions at relevant tradeoffs?</td>
<td>Expected utility, net benefit</td>
<td>Requires explicit consequences or threshold probabilities</td>
</tr>
</tbody>
</table>
<p>For binary outcomes, the Brier score is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BBS%7D=%5Cfrac1n%5Csum_%7Bi=1%7D%5E%7Bn%7D(y_i-%5Chat%20p_i)%5E2.%0A"></p>
<p>The mean log loss is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A-%5Cfrac1n%5Csum_%7Bi=1%7D%5E%7Bn%7D%0A%5C%7By_i%5Clog(%5Chat%20p_i)+(1-y_i)%5Clog(1-%5Chat%20p_i)%5C%7D.%0A"></p>
<p>Both are proper scoring rules: in expectation, honest probabilities optimize the score under the scoring convention. Log loss penalizes confident wrong predictions especially strongly. Compare scores with a meaningful reference model and use uncertainty intervals rather than reporting an isolated decimal.</p>
<p>A high AUC can coexist with poor calibration because ranking can remain unchanged when all probabilities are systematically too high. Conversely, a useful recalibration may improve probability accuracy without changing the AUC.</p>
</section>
<section id="validation-without-optimism" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Validation Without Optimism</h1>
<p>Apparent performance on the development data is optimistic, especially after predictor selection, transformation searches, hyperparameter tuning, or threshold selection. Every data-dependent modeling step must occur inside the resampling loop. Bootstrap validation or nested cross-validation can estimate internal optimism; a genuinely external sample tests transport to a new place, time, or population.</p>
<p>Calibration assessment itself needs enough independent events and non-events. Small validation sets yield noisy curves, intercepts, and slopes. Grouping predictions into arbitrary deciles hides within-bin structure and can create misleading shapes; show a smooth curve with the prediction distribution and uncertainty when possible.</p>
<p>Prevalence altered by case-control sampling requires special care. Slopes and exposure odds ratios can be estimable under the design, while the raw sample event fraction and uncorrected intercept do not estimate population risk. Absolute probabilities require known sampling fractions or another valid route to the target prevalence.</p>
</section>
<section id="thresholds-and-decisions" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Thresholds and Decisions</h1>
<p>Turning <img src="https://latex.codecogs.com/png.latex?%5Chat%20p"> into a class label at 0.5 discards probability information and quietly assumes a particular balance of consequences. The relevant threshold is determined by the decision: costs of false positives and false negatives, available interventions, resource constraints, and patient or scientific values.</p>
<p>Sensitivity and specificity describe classification at a chosen threshold; they do not assess probability calibration. Accuracy can favor predicting the majority class for rare outcomes. Select and evaluate a threshold using data independent of model fitting, or account for selection in the validation procedure.</p>
</section>
<section id="bioinformatics-example" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Bioinformatics Example</h1>
<p>Suppose a gene-expression signature predicts whether a patient-derived organoid responds to a drug. Donor lines are experimental units. Multiple wells, cells, reads, or library preparations within a donor can improve measurement but are technical or subsample replication; treating them as independent validation cases exaggerates precision and permits donor identity to leak across train and test sets.</p>
<p>Split or resample at the donor level and keep all preprocessing, feature selection, normalization choices, and tuning inside each training fold. Report the number of independent donors, events and non-events, missingness, prediction horizon, and outcome definition. Validate calibration in the intended target population, whose response prevalence and assay pipeline may differ from the development study.</p>
<p>Statistically, a calibrated 0.70 prediction means that comparable predictions correspond to an event frequency near 70% in the target setting. Biologically, it does not identify the causal mechanism of response, guarantee benefit from an intervention, or establish that the signature transports across tissues, platforms, laboratories, and patient populations.</p>
</section>
<section id="diagnostics-and-sensitivity-checklist" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Diagnostics and Sensitivity Checklist</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th>Question</th>
<th>Diagnostic or sensitivity analysis</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Is the estimand conditional or population-average?</td>
<td>State the target contrast and standardization weights</td>
</tr>
<tr class="even">
<td>Are predictions supported by the data?</td>
<td>Plot predictor and probability distributions; identify extrapolation</td>
</tr>
<tr class="odd">
<td>Does prevalence differ across settings?</td>
<td>Compare outcome definitions and rates; assess intercept updating</td>
</tr>
<tr class="even">
<td>Are predictions too extreme?</td>
<td>Calibration slope, flexible curve, shrinkage sensitivity</td>
</tr>
<tr class="odd">
<td>Was performance estimated independently?</td>
<td>External validation or fully nested resampling</td>
</tr>
<tr class="even">
<td>Is dependence respected?</td>
<td>Group resampling by donor, family, site, or other experimental unit</td>
</tr>
<tr class="odd">
<td>Does missingness or selection change the target?</td>
<td>Compare inclusion patterns; weighting or imputation sensitivity</td>
</tr>
<tr class="even">
<td>Are conclusions metric-dependent?</td>
<td>Report calibration, discrimination, proper scores, and decision consequences</td>
</tr>
</tbody>
</table>
</section>
<section id="common-misinterpretations" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> Common Misinterpretations</h1>
<ul>
<li><strong>“An odds ratio of 2 doubles risk.”</strong> It doubles odds; the risk ratio depends on baseline risk.</li>
<li><strong>“Adjustment moved the odds ratio, proving confounding.”</strong> Non-collapsibility can move conditional and marginal odds ratios even without confounding.</li>
<li><strong>“AUC of 0.9 means probabilities are accurate.”</strong> AUC evaluates ranking, not agreement between predicted and observed risks.</li>
<li><strong>“The Hosmer–Lemeshow p-value proves fit.”</strong> A grouped test is sensitive to grouping and sample size and cannot summarize calibration, specification, and transportability.</li>
<li><strong>“Technical replicates enlarge the validation sample.”</strong> Independent biological units determine generalization and inferential precision.</li>
</ul>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/logistic-regression.html">Logistic regression</a> derives the Bernoulli likelihood, coefficients, estimation, and separation.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/effect-sizes.html">Effect sizes</a> compares differences, ratios, odds ratios, and standardized effects.</li>
<li><a href="../../../knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html">Regression uncertainty and coefficient interpretation</a> distinguishes coefficient, contrast, mean-response, and prediction uncertainty.</li>
<li><a href="../../../knowledge/statistics/regression-models/interaction-terms-and-effect-modification.html">Interaction terms and effect modification</a> explains why effects depend on scale and covariate level.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/parametric-bootstrap.html">Parametric bootstrap</a> and <a href="../../../knowledge/statistics/statistical-inference/nonparametric-bootstrap.html">nonparametric bootstrap</a> describe two different uncertainty and validation tools.</li>
</ul>
<ol type="1">
<li>Odds ratios, risk ratios, risk differences, and predicted probabilities answer different questions and should be named explicitly.</li>
<li>Logistic coefficients are conditional; standardized probabilities can target a declared population-average contrast.</li>
<li>Calibration must be checked in the intended population and period, separately from discrimination.</li>
<li>Honest validation repeats the entire modeling pipeline and respects the true experimental unit.</li>
<li>Probability thresholds are decisions with consequences, not intrinsic properties of a fitted model.</li>
</ol>
</section>
<section id="references" class="level1" data-number="12">
<h1 data-number="12"><span class="header-section-number">12</span> References</h1>
<ul>
<li>Cox, D. R. (1958). The regression analysis of binary sequences. <em>Journal of the Royal Statistical Society: Series B</em>, 20(2), 215–232. <a href="https://doi.org/10.1111/j.2517-6161.1958.tb00292.x" class="uri">https://doi.org/10.1111/j.2517-6161.1958.tb00292.x</a></li>
<li>Greenland, S., Robins, J. M., and Pearl, J. (1999). Confounding and collapsibility in causal inference. <em>Statistical Science</em>, 14(1), 29–46. <a href="https://doi.org/10.1214/ss/1009211805" class="uri">https://doi.org/10.1214/ss/1009211805</a></li>
<li>Brier, G. W. (1950). Verification of forecasts expressed in terms of probability. <em>Monthly Weather Review</em>, 78(1), 1–3. <a href="https://doi.org/10.1175/1520-0493(1950)078%3C0001:VOFEIT%3E2.0.CO;2" class="uri">https://doi.org/10.1175/1520-0493(1950)078%3C0001:VOFEIT%3E2.0.CO;2</a></li>
<li>Steyerberg, E. W., Vickers, A. J., Cook, N. R., et al.&nbsp;(2010). Assessing the performance of prediction models: a framework for traditional and novel measures. <em>Epidemiology</em>, 21(1), 128–138. <a href="https://doi.org/10.1097/EDE.0b013e3181c30fb2" class="uri">https://doi.org/10.1097/EDE.0b013e3181c30fb2</a></li>
<li>Van Calster, B., Nieboer, D., Vergouwe, Y., et al.&nbsp;(2016). A calibration hierarchy for risk models was defined: from utopia to empirical data. <em>Journal of Clinical Epidemiology</em>, 74, 167–176. <a href="https://doi.org/10.1016/j.jclinepi.2015.12.005" class="uri">https://doi.org/10.1016/j.jclinepi.2015.12.005</a></li>
<li>Van Calster, B., McLernon, D. J., van Smeden, M., Wynants, L., and Steyerberg, E. W. (2019). Calibration: the Achilles heel of predictive analytics. <em>BMC Medicine</em>, 17, 230. <a href="https://doi.org/10.1186/s12916-019-1466-7" class="uri">https://doi.org/10.1186/s12916-019-1466-7</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Odds Ratios</category>
  <category>Calibration</category>
  <category>Prediction</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/odds-ratios-probabilities-and-calibration.html</guid>
  <pubDate>Fri, 16 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>ANCOVA and Regression-based ANOVA</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/ancova-and-regression-based-anova.html</link>
  <description><![CDATA[ 





<section id="why-add-covariates-to-a-group-comparison" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Why Add Covariates to a Group Comparison?</h1>
<p>Analysis of covariance (ANCOVA) is a linear regression containing categorical group indicators and continuous or additional categorical covariates. It can improve precision by explaining outcome variation known before treatment, adjust an observational comparison for measured confounding under strong assumptions, or describe how group differences vary across a covariate.</p>
<p>For group <img src="https://latex.codecogs.com/png.latex?G_i"> and covariate <img src="https://latex.codecogs.com/png.latex?X_i">, a basic model is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_i=%5Cbeta_0+%5Cbeta_GG_i+%5Cbeta_X(X_i-x_0)+%5Cvarepsilon_i,%0A%5Cqquad%0A%5Coperatorname%7BE%7D(%5Cvarepsilon_i%5Cmid%20G_i,X_i)=0.%0A"></p>
<p>If <img src="https://latex.codecogs.com/png.latex?G_i"> is binary and there is no <img src="https://latex.codecogs.com/png.latex?G_iX_i"> interaction, <img src="https://latex.codecogs.com/png.latex?%5Cbeta_G"> is the adjusted mean difference at every value of <img src="https://latex.codecogs.com/png.latex?X"> represented by this model. Centering at <img src="https://latex.codecogs.com/png.latex?x_0"> makes the intercept scientifically meaningful but does not change fitted values or <img src="https://latex.codecogs.com/png.latex?%5Cbeta_G">. With multiple groups, the indicators are simply a multi-degree-of-freedom regression term.</p>
<p>The estimand must precede the method. It might be a treatment effect at a common baseline value, an average adjusted contrast over a target covariate distribution, or a purely descriptive conditional association. The fitted coefficient is an estimator; its realized value is an estimate. Adjustment alone does not determine which interpretation is justified.</p>
</section>
<section id="adjusted-means-are-model-based-predictions" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Adjusted Means Are Model-based Predictions</h1>
<p>Let the fitted model have coefficient vector <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cboldsymbol%5Cbeta%7D">. An adjusted mean for group <img src="https://latex.codecogs.com/png.latex?g"> at covariate value <img src="https://latex.codecogs.com/png.latex?x_0"> is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%20m_g(x_0)=%5Cmathbf%20x(g,x_0)%5E%5Cmathsf%7BT%7D%0A%5Chat%7B%5Cboldsymbol%5Cbeta%7D.%0A"></p>
<p>An adjusted contrast is therefore</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%5CDelta(x_0)%0A=%5C%7B%5Cmathbf%20x(1,x_0)-%5Cmathbf%20x(0,x_0)%5C%7D%5E%5Cmathsf%7BT%7D%0A%5Chat%7B%5Cboldsymbol%5Cbeta%7D.%0A"></p>
<p>Its estimated variance is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%7B%5Coperatorname%7BVar%7D%7D%5C%7B%5Cwidehat%5CDelta(x_0)%5C%7D%0A=%5Cmathbf%20c(x_0)%5E%5Cmathsf%7BT%7D%0A%5Cwidehat%7B%5Coperatorname%7BVar%7D%7D(%5Chat%7B%5Cboldsymbol%5Cbeta%7D)%0A%5Cmathbf%20c(x_0).%0A"></p>
<p>“Adjusted mean” is incomplete unless the analyst states where or how covariates were averaged. Equal weighting across groups targets a different population from weighting by the observed sample frequencies. Predictions at the grand mean of a covariate may describe no actual unit when the distribution is multimodal or when covariates interact.</p>
</section>
<section id="the-parallel-slopes-assumption" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> The Parallel-slopes Assumption</h1>
<p>The model above assumes the same covariate slope in every group. A model allowing effect modification is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_i=%5Cbeta_0+%5Cbeta_GG_i+%5Cbeta_X(X_i-x_0)%0A+%5Cbeta_%7BGX%7DG_i(X_i-x_0)+%5Cvarepsilon_i.%0A"></p>
<p>Now the adjusted group contrast at <img src="https://latex.codecogs.com/png.latex?X=x"> is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5CDelta(x)=%5Cbeta_G+%5Cbeta_%7BGX%7D(x-x_0).%0A"></p>
<p>Thus <img src="https://latex.codecogs.com/png.latex?%5Cbeta_G"> is only the contrast at the centering value. If an interaction is present, deleting it to recover a single ANCOVA p-value answers the wrong question. Show conditional contrasts or predictions over the region with support, and define any average contrast with explicit target-population weights.</p>
<p>Linearity in <img src="https://latex.codecogs.com/png.latex?X"> is also an assumption, not a property of covariance adjustment. Transformations or splines can model curvature while retaining regression-based group contrasts. Categorizing a continuous covariate usually discards information, creates artificial thresholds, and leaves residual confounding.</p>
</section>
<section id="regression-based-anova-and-nested-models" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Regression-based ANOVA and Nested Models</h1>
<p>ANOVA, ANCOVA, and ordinary regression use the same least-squares machinery. Suppose a reduced model has design matrix <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X_R"> and a full model adds <img src="https://latex.codecogs.com/png.latex?q"> estimable columns, producing residual sums of squares <img src="https://latex.codecogs.com/png.latex?RSS_R"> and <img src="https://latex.codecogs.com/png.latex?RSS_F">. Under the classical Gaussian linear model,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AF=%0Crac%7B(RSS_R-RSS_F)/q%7D%7BRSS_F/(n-p_F)%7D%0A%5Csim%20F_%7Bq,n-p_F%7Dquad%5Ctext%7Bunder%20the%20reduced-model%20null%7D.%0A"></p>
<p>The test asks whether the added coefficients are jointly zero conditional on all terms retained in both models. This formulation makes the hypothesis explicit:</p>
<ul>
<li>adding all group indicators tests an adjusted group effect;</li>
<li>adding group-by-covariate terms tests whether slopes differ;</li>
<li>adding a block or batch factor tests that term conditional on the specified biological design;</li>
<li>adding nonlinear basis terms tests the chosen departure from linearity.</li>
</ul>
<p>Models compared by this partial <img src="https://latex.codecogs.com/png.latex?F"> test must be fitted to the same observations. If missingness changes the analysis set, a difference in residual sum of squares mixes model change with data change. Robust or cluster-aware Wald tests may be preferable when the classical variance assumptions fail.</p>
</section>
<section id="baseline-adjustment-in-randomized-studies" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Baseline Adjustment in Randomized Studies</h1>
<p>In a randomized two-arm study with baseline measurement <img src="https://latex.codecogs.com/png.latex?Y_0"> and follow-up <img src="https://latex.codecogs.com/png.latex?Y_1">, a common model is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_%7B1i%7D=%5Cbeta_0+%5Cbeta_TT_i+%5Cbeta_BY_%7B0i%7D+%5Cvarepsilon_i.%0A"></p>
<p>Because treatment is randomized, chance baseline imbalance does not confound the treatment effect. Adjusting for a prognostic baseline value generally improves precision and targets the follow-up mean difference conditional on the prespecified model. It is commonly more efficient than analyzing change <img src="https://latex.codecogs.com/png.latex?Y_1-Y_0">, which implicitly fixes the baseline coefficient at one and can amplify measurement error.</p>
<p>Baseline must be measured before assignment or treatment. Adjusting for a post-treatment variable can remove part of the effect, induce collider bias, or change the estimand. In observational studies, pre-exposure covariates may address measured confounding only if the adjustment set, functional forms, positivity, measurement, and missingness assumptions are defensible. More covariates are not automatically safer.</p>
</section>
<section id="imbalance-coding-and-sums-of-squares" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Imbalance, Coding, and Sums of Squares</h1>
<p>With balanced orthogonal designs, sequential and partial decompositions coincide. With imbalance, a reported “adjusted effect” depends on the other terms in the model and on the contrast being tested. A useful workflow is:</p>
<ol type="1">
<li>draw the design and identify experimental units, randomization, blocks, and measured covariates;</li>
<li>define the target contrast and target covariate distribution;</li>
<li>encode the full mean structure, including prespecified interactions and nonlinearities;</li>
<li>verify rank, overlap, and estimability;</li>
<li>express the hypothesis as a coefficient contrast or reduced-versus-full model;</li>
<li>report predicted means and contrasts with uncertainty.</li>
</ol>
<p>Software “Type I,” “Type II,” or “Type III” labels cannot replace steps 2 and 5. In particular, a main-effect test in the presence of interaction may average over factor levels using weights unrelated to the target population. Empty or sparse factor-by-covariate regions can turn adjusted comparisons into extrapolation.</p>
</section>
<section id="assumptions-and-diagnostics" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Assumptions and Diagnostics</h1>
<p>ANCOVA inherits the linear-model assumptions and adds special risks around covariate choice and overlap.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Assumption or risk</th>
<th>Consequence</th>
<th>Diagnostic or sensitivity analysis</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Independent experimental units</td>
<td>Pseudoreplication understates uncertainty</td>
<td>Map sampling and assignment; use cluster-aware or multilevel analysis</td>
</tr>
<tr class="even">
<td>Correct conditional mean</td>
<td>Adjusted contrasts can be biased or target a projection</td>
<td>Plot residual and partial relationships; compare justified interactions and smooths</td>
</tr>
<tr class="odd">
<td>Common slope when interaction is omitted</td>
<td>One number masks changing contrasts</td>
<td>Fit and display prespecified group-by-covariate interactions</td>
</tr>
<tr class="even">
<td>Covariate overlap across groups</td>
<td>Adjustment otherwise extrapolates</td>
<td>Plot distributions and joint support; restrict the target population if needed</td>
</tr>
<tr class="odd">
<td>Valid covariate timing and role</td>
<td>Post-treatment or collider adjustment can bias causal claims</td>
<td>Use design chronology and a causal diagram; report alternative justified sets</td>
</tr>
<tr class="even">
<td>Valid variance and dependence model</td>
<td>Standard errors and tests can be miscalibrated</td>
<td>Inspect heteroskedasticity and clustering; use appropriate robust covariance or models</td>
</tr>
<tr class="odd">
<td>Reliable covariate measurement</td>
<td>Error leaves residual confounding and can alter slopes</td>
<td>Use validation data or measurement-error sensitivity analysis</td>
</tr>
</tbody>
</table>
<p>Residual diagnostics cannot prove that the adjustment set controls confounding. Conversely, a chance correlation between treatment and baseline in a randomized sample is not evidence that randomization failed. Design knowledge supplies assumptions that the observed data alone cannot verify.</p>
</section>
<section id="worked-bioinformatics-example" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Worked Bioinformatics Example</h1>
<p>Suppose 48 patient-derived organoid lines are randomized to control or drug, and log-expression of a pathway at 24 hours is the outcome. Prespecified covariates are baseline pathway expression, tissue of origin, and sequencing batch.</p>
<p>The organoid donor line is the experimental unit. Replicate wells, libraries, and reads nested within one line are technical replication. If wells receive treatment independently but share a donor, the model must still represent donor clustering and the precise assignment scheme.</p>
<p>An ANCOVA contrast estimates the adjusted drug-control difference at specified baseline and tissue values, or averaged over a declared tissue and baseline distribution. A drug-by-baseline interaction would make that difference vary with baseline expression. Batch adjustment can improve precision when treatment is represented within batches; if treatment and batch are perfectly confounded, no regression can identify their separate effects.</p>
<p>Statistically, an interval quantifies uncertainty about the adjusted contrast under the model and design. Biologically, a nonzero contrast supports a treatment- associated change in this pathway for the sampled donor population and assay; it does not alone prove pathway mediation, clinical relevance, or transferability to patients.</p>
</section>
<section id="reporting-and-connections" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Reporting and Connections</h1>
<p>Report the estimand, experimental unit, design, covariate timing and selection, model formula, coding and centering, overlap, adjusted means and contrasts with their weighting scheme, intervals, joint tests, diagnostics, missing-data handling, and sensitivity to interactions, nonlinearities, influential units, and alternative justified adjustment sets.</p>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/one-way-and-factorial-anova.html">One-way and factorial ANOVA</a> introduces designed group comparisons, factorial interactions, and omnibus tests.</li>
<li><a href="../../../knowledge/statistics/regression-models/multiple-linear-regression.html">Multiple linear regression</a> supplies the conditional-mean and partial-regression foundation.</li>
<li><a href="../../../knowledge/statistics/regression-models/categorical-predictors-and-contrasts.html">Categorical predictors and contrasts</a> explains coding, estimability, and marginal-mean weights.</li>
<li><a href="../../../knowledge/statistics/regression-models/interaction-terms-and-effect-modification.html">Interaction terms and effect modification</a> develops conditional contrasts and scale dependence.</li>
<li><a href="../../../knowledge/statistics/regression-models/linear-model-assumptions-and-diagnostics.html">Linear-model assumptions and diagnostics</a> separates mean, variance, dependence, and causal assumptions.</li>
<li><a href="../../../knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html">Regression uncertainty and coefficient interpretation</a> derives uncertainty for linear combinations and predictions.</li>
</ul>
<ol type="1">
<li>ANCOVA is multiple regression with group indicators and covariates; adjusted means are model-based predictions.</li>
<li>Define where or over whom a contrast is averaged before interpreting it.</li>
<li>A common adjusted group effect requires an adequate parallel-slopes model; interaction makes the contrast covariate-dependent.</li>
<li>Baseline adjustment in randomized studies can improve precision, but post-treatment adjustment can change or bias the target effect.</li>
<li>Regression cannot repair absent overlap, treatment-batch confounding, or technical pseudoreplication.</li>
</ol>
</section>
<section id="references" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> References</h1>
<ul>
<li>Cochran, W. G. (1957). Analysis of covariance: Its nature and uses. <em>Biometrics</em>, 13(3), 261–281. <a href="https://doi.org/10.2307/2527916" class="uri">https://doi.org/10.2307/2527916</a></li>
<li>Frison, L., and Pocock, S. J. (1992). Repeated measures in clinical trials: Analysis using mean summary statistics and its implications for design. <em>Statistics in Medicine</em>, 11(13), 1685–1704. <a href="https://doi.org/10.1002/sim.4780111304" class="uri">https://doi.org/10.1002/sim.4780111304</a></li>
<li>Vickers, A. J., and Altman, D. G. (2001). Statistics notes: Analysing controlled trials with baseline and follow up measurements. <em>BMJ</em>, 323, 1123–1124. <a href="https://doi.org/10.1136/bmj.323.7321.1123" class="uri">https://doi.org/10.1136/bmj.323.7321.1123</a></li>
<li>Van Breukelen, G. J. P. (2006). ANCOVA versus change from baseline: More power in randomized studies, more bias in nonrandomized studies. <em>Journal of Clinical Epidemiology</em>, 59(9), 920–925. <a href="https://doi.org/10.1016/j.jclinepi.2006.02.007" class="uri">https://doi.org/10.1016/j.jclinepi.2006.02.007</a></li>
<li>Senn, S. (2006). Change from baseline and analysis of covariance revisited. <em>Statistics in Medicine</em>, 25(24), 4334–4344. <a href="https://doi.org/10.1002/sim.2682" class="uri">https://doi.org/10.1002/sim.2682</a></li>
<li>R Core Team. <code>lm</code>: fitting linear models; <code>anova.lm</code>: ANOVA tables for fitted linear models. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>ANCOVA</category>
  <category>Experimental Design</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/ancova-and-regression-based-anova.html</guid>
  <pubDate>Thu, 15 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>One-way and Factorial ANOVA</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/one-way-and-factorial-anova.html</link>
  <description><![CDATA[ 





<section id="the-question-anova-answers" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> The Question ANOVA Answers</h1>
<p>Analysis of variance (ANOVA) compares systematic differences in group means with variation among independent units receiving the same conditions. Despite its name, its primary targets are usually mean contrasts. Variance is the accounting device used to quantify signal and residual noise.</p>
<p>For outcome <img src="https://latex.codecogs.com/png.latex?Y_%7Bij%7D"> from independent unit <img src="https://latex.codecogs.com/png.latex?j"> in group <img src="https://latex.codecogs.com/png.latex?i">, the one-way model is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_%7Bij%7D=%5Cmu+%5Calpha_i+%5Cvarepsilon_%7Bij%7D,%0A%5Cqquad%0A%5Coperatorname%7BE%7D(%5Cvarepsilon_%7Bij%7D%5Cmid%20i)=0.%0A"></p>
<p>The population group means <img src="https://latex.codecogs.com/png.latex?%5Cmu_i=%5Coperatorname%7BE%7D(Y%5Cmid%20i)">, or prespecified contrasts such as <img src="https://latex.codecogs.com/png.latex?%5Cmu_2-%5Cmu_1">, are the estimands. The sample means and fitted contrasts are estimates. ANOVA does not turn an observational group label into a cause; causal interpretation comes from random assignment or defensible identification assumptions.</p>
<p>The experimental unit is the smallest unit independently assigned to a condition or sampled from the target population. Repeated wells, reads, images, cells, or technical runs from one specimen may improve measurement, but they do not create new independent biological replicates.</p>
</section>
<section id="one-way-anova-as-a-linear-model" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> One-way ANOVA as a Linear Model</h1>
<p>With <img src="https://latex.codecogs.com/png.latex?g"> groups, the cell-means parameterization is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_%7Bij%7D=%5Cmu_i+%5Cvarepsilon_%7Bij%7D.%0A"></p>
<p>An equivalent regression uses an intercept and <img src="https://latex.codecogs.com/png.latex?g-1"> indicator columns. The coefficient values depend on the chosen coding, but fitted group means and the same estimable contrasts do not. This is why scientific conclusions should be reported as group means and contrasts rather than as unexplained “main-effect” coefficients.</p>
<p>For a balanced design with <img src="https://latex.codecogs.com/png.latex?n_i=n_0"> and total <img src="https://latex.codecogs.com/png.latex?N=gn_0">, the total corrected sum of squares decomposes as</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cunderbrace%7B%5Csum_i%5Csum_j(Y_%7Bij%7D-%5Cbar%20Y_%7B%5Ccdot%5Ccdot%7D)%5E2%7D_%7BSS_%7B%5Cmathrm%7Btotal%7D%7D%7D%0A=%0A%5Cunderbrace%7Bn_0%5Csum_i(%5Cbar%20Y_%7Bi%5Ccdot%7D-%5Cbar%20Y_%7B%5Ccdot%5Ccdot%7D)%5E2%7D_%7BSS_%7B%5Cmathrm%7Bgroup%7D%7D%7D%0A+%0A%5Cunderbrace%7B%5Csum_i%5Csum_j(Y_%7Bij%7D-%5Cbar%20Y_%7Bi%5Ccdot%7D)%5E2%7D_%7BSS_%7B%5Cmathrm%7Berror%7D%7D%7D.%0A"></p>
<p>The equality follows by writing <img src="https://latex.codecogs.com/png.latex?Y_%7Bij%7D-%5Cbar%20Y_%7B%5Ccdot%5Ccdot%7D=(Y_%7Bij%7D-%5Cbar%20Y_%7Bi%5Ccdot%7D)+%0A(%5Cbar%20Y_%7Bi%5Ccdot%7D-%5Cbar%20Y_%7B%5Ccdot%5Ccdot%7D)">; the cross-product vanishes because residuals sum to zero within each group. In matrix terms, it is a projection decomposition from <a href="../../../knowledge/statistics/regression-models/least-squares-and-regression-geometry.html">least-squares geometry</a>.</p>
<p>Under independent Gaussian errors with common variance <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E2">, the omnibus hypothesis</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AH_0:%5Cmu_1=%5Ccdots=%5Cmu_g%0A"></p>
<p>is tested by</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AF=%5Cfrac%7BSS_%7B%5Cmathrm%7Bgroup%7D%7D/(g-1)%7D%0A%20%20%20%20%20%20%20%20%7BSS_%7B%5Cmathrm%7Berror%7D%7D/(N-g)%7D%0A%5Csim%20F_%7Bg-1,N-g%7D%5Cquad%5Ctext%7Bunder%20%7DH_0.%0A"></p>
<p>The numerator measures improvement over an intercept-only model; the denominator estimates within-group noise. Rejecting the omnibus null says that the vector of means is not constant. It does not identify which differences matter, measure their size, or establish biological importance.</p>
</section>
<section id="factorial-designs-and-interactions" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Factorial Designs and Interactions</h1>
<p>A factorial experiment studies two or more factors together. For factors <img src="https://latex.codecogs.com/png.latex?A"> and <img src="https://latex.codecogs.com/png.latex?B">, a two-way fixed-effects model is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_%7Bijk%7D=%5Cmu+%5Calpha_i+%5Cbeta_j+(%5Calpha%5Cbeta)_%7Bij%7D+%5Cvarepsilon_%7Bijk%7D.%0A"></p>
<p>The interaction term allows the contrast between levels of <img src="https://latex.codecogs.com/png.latex?A"> to vary across levels of <img src="https://latex.codecogs.com/png.latex?B">. For two-level factors, an interaction contrast is a difference in differences:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A(%5Cmu_%7B11%7D-%5Cmu_%7B01%7D)-(%5Cmu_%7B10%7D-%5Cmu_%7B00%7D).%0A"></p>
<p>If interaction is scientifically plausible, marginal main effects can hide the pattern. Report cell means, conditional contrasts, and an interaction plot with uncertainty. A nonsignificant interaction is not evidence that effects are identical; the design may simply be imprecise.</p>
<p>Factorial designs are efficient because every unit informs more than one factor. They also distinguish a biological interaction from a nuisance block or batch effect. Blocking reduces residual variation when blocks are known before randomization. Treating a block as a biological factor changes the question, so the design and estimands must be declared first.</p>
</section>
<section id="contrasts-omnibus-tests-and-multiplicity" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Contrasts, Omnibus Tests, and Multiplicity</h1>
<p>A contrast is a linear function</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AL=%5Csum_%7Bi=1%7D%5E%7Bg%7Dc_i%5Cmu_i,%0A%5Cqquad%20%5Csum_i%20c_i=0.%0A"></p>
<p>Examples include one treatment versus control, a linear dose trend, or the average of two treatments versus another pair. Prespecified contrasts often answer the scientific question more directly and with more power than an omnibus test followed by every pairwise comparison.</p>
<p>For fitted coefficient vector <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cboldsymbol%5Cbeta%7D"> and contrast vector <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20c">,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%20L=%5Cmathbf%20c%5E%5Cmathsf%7BT%7D%5Chat%7B%5Cboldsymbol%5Cbeta%7D,%0A%5Cqquad%0A%5Cwidehat%7B%5Coperatorname%7BVar%7D%7D(%5Cwidehat%20L)%0A=%5Cmathbf%20c%5E%5Cmathsf%7BT%7D%5Cwidehat%7B%5Coperatorname%7BVar%7D%7D(%5Chat%7B%5Cboldsymbol%5Cbeta%7D)%5Cmathbf%20c.%0A"></p>
<p>Report <img src="https://latex.codecogs.com/png.latex?%5Cwidehat%20L">, an interval, the outcome scale, and the multiplicity strategy. Tukey procedures suit all pairwise comparisons under their conditions; Dunnett procedures suit several treatments versus one control. Planned contrasts need not be delayed until an omnibus test rejects, but the full family of claims still determines the appropriate error control.</p>
</section>
<section id="balanced-and-unbalanced-data" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Balanced and Unbalanced Data</h1>
<p>In a balanced, complete factorial design, orthogonal model terms yield the same sums of squares regardless of fitting order. With unequal cell sizes, missing cells, or correlated predictors, “the sum of squares for factor <img src="https://latex.codecogs.com/png.latex?A">” is not unique.</p>
<ul>
<li><strong>Sequential sums of squares</strong> compare each term with those entered before it.</li>
<li><strong>Partial sums of squares</strong> compare a term after adjusting for specified other terms.</li>
<li>Different software labels such comparisons Type I, II, or III, but the label is less informative than the exact nested models or contrasts tested.</li>
</ul>
<p>Type III tests depend on parameterization and may target averages over cell combinations that are poorly represented or absent. Empty cells can make some main effects or interactions non-estimable. Inspect the design matrix, cell counts, rank, and the weighting used for marginal means. State the hypothesis as a contrast or explicit reduced-versus-full model comparison.</p>
</section>
<section id="assumptions-diagnostics-and-alternatives" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Assumptions, Diagnostics, and Alternatives</h1>
<p>The classical fixed-effects ANOVA <img src="https://latex.codecogs.com/png.latex?F"> reference law uses independent Gaussian errors with common variance and a correctly specified mean structure.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Issue</th>
<th>Why it matters</th>
<th>Check and response</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Wrong experimental unit</td>
<td>Degrees of freedom and standard errors become artificially small</td>
<td>Reconstruct assignment and nesting; aggregate or model clusters</td>
</tr>
<tr class="even">
<td>Unequal variances</td>
<td>Classical pooled standard errors may be wrong</td>
<td>Plot group spreads; use Welch’s one-way test, variance modeling, or robust covariance when justified</td>
</tr>
<tr class="odd">
<td>Dependence</td>
<td>Replicates contribute less information than assumed</td>
<td>Use blocked, repeated-measures, cluster-aware, or mixed models</td>
</tr>
<tr class="even">
<td>Skewness or heavy tails</td>
<td>Small-sample <img src="https://latex.codecogs.com/png.latex?F"> calibration and means may be unstable</td>
<td>Check residuals and influence; consider transformation, robust methods, or design-respecting randomization inference</td>
</tr>
<tr class="odd">
<td>Sparse or empty cells</td>
<td>Contrasts may rely on extrapolation or be non-estimable</td>
<td>Show cell counts, rank, and contrast weights; simplify claims</td>
</tr>
<tr class="even">
<td>Many post hoc comparisons</td>
<td>False-positive risk increases</td>
<td>Prespecify priorities and control the relevant error family</td>
</tr>
</tbody>
</table>
<p>ANOVA is often reasonably robust to moderate nonnormality in balanced designs, but balance does not rescue pseudoreplication, severe outliers, or dependence. Rank-based tests change the estimand and generally do not provide a drop-in factorial analysis. Permutation tests require transformations that are valid under the design and null being tested.</p>
</section>
<section id="worked-bioinformatics-design" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Worked Bioinformatics Design</h1>
<p>Suppose 36 mice are randomized equally to three drugs, with sex used as a second factor and RNA-seq pathway score as the outcome. The factorial model estimates six drug-by-sex cell means. Primary estimands might be each drug-versus-control contrast averaged equally across sexes and the drug-by-sex interactions.</p>
<p>The mouse is the experimental unit. Two library preparations and thousands of reads from one mouse are technical observations, not extra randomized units. Sequencing lane can be included as a design or processing factor if it is not confounded with drug. If every control library was sequenced in one lane and every treated library in another, drug and lane effects cannot be separated by ANOVA.</p>
<p>Statistically, a drug contrast estimates a difference in mean pathway score on the declared scale. Biologically, it supports a treatment-associated change in that pathway under this organism, tissue, dose, and time point; it does not by itself demonstrate a molecular mechanism or generalize to other settings.</p>
</section>
<section id="reporting-and-connections" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Reporting and Connections</h1>
<p>Report the design, experimental unit, allocation, cell counts, outcome scale, model formula, prespecified contrasts, estimated means and contrasts with intervals, multiplicity adjustment, residual and influence checks, missing-data handling, and sensitivity analyses. An ANOVA table alone is not a scientific result.</p>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/categorical-predictors-and-contrasts.html">Categorical predictors and contrasts</a> develops coding-invariant group comparisons.</li>
<li><a href="../../../knowledge/statistics/regression-models/interaction-terms-and-effect-modification.html">Interaction terms and effect modification</a> explains conditional effects and effect-scale dependence.</li>
<li><a href="../../../knowledge/statistics/regression-models/linear-model-assumptions-and-diagnostics.html">Linear-model assumptions and diagnostics</a> links each regression assumption to the claim it supports.</li>
<li><a href="../../../knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html">Regression uncertainty and coefficient interpretation</a> derives uncertainty for coefficients, contrasts, and predictions.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/family-wise-error-rate.html">Family-wise error rate</a> distinguishes weak and strong control over families of tests.</li>
<li><a href="../../../knowledge/statistics/regression-models/ancova-and-regression-based-anova.html">ANCOVA and regression-based ANOVA</a> adds continuous covariates and explicit nested-model comparisons.</li>
</ul>
<ol type="1">
<li>ANOVA is a linear model for means and contrasts, not merely a table of sums of squares.</li>
<li>The independent experimental unit determines the information and degrees of freedom.</li>
<li>In factorial designs, interactions make effects conditional on other factors.</li>
<li>With imbalance, define hypotheses through contrasts or nested models instead of relying on an unexplained sums-of-squares type.</li>
<li>Effect estimates, intervals, diagnostics, and biological context matter more than an omnibus p-value alone.</li>
</ol>
</section>
<section id="references" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> References</h1>
<ul>
<li>Fisher, R. A. (1925). <em>Statistical Methods for Research Workers</em>. Oliver and Boyd. <a href="https://psychclassics.yorku.ca/Fisher/Methods/" class="uri">https://psychclassics.yorku.ca/Fisher/Methods/</a></li>
<li>Box, G. E. P., Hunter, J. S., and Hunter, W. G. (2005). <em>Statistics for Experimenters</em> (2nd ed.). Wiley.</li>
<li>Searle, S. R. (1971). <em>Linear Models</em>. Wiley.</li>
<li>Langsrud, O. (2003). ANOVA for unbalanced data: Use Type II instead of Type III sums of squares. <em>Statistics and Computing</em>, 13, 163–167. <a href="https://doi.org/10.1023/A:1023260610025" class="uri">https://doi.org/10.1023/A:1023260610025</a></li>
<li>R Core Team. <code>aov</code>: fit an analysis of variance model; <code>anova.lm</code>: ANOVA tables for fitted linear models. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/aov.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/aov.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>ANOVA</category>
  <category>Experimental Design</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/one-way-and-factorial-anova.html</guid>
  <pubDate>Thu, 15 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Categorical Predictors and Contrasts</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/categorical-predictors-and-contrasts.html</link>
  <description><![CDATA[ 





<section id="categories-enter-through-a-design-matrix" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Categories Enter through a Design Matrix</h1>
<p>A categorical predictor records membership in a finite set of levels: treatment arm, genotype, tissue, sequencing batch, or disease subtype. Regression software cannot estimate a separate unconstrained coefficient for every level together with an intercept, because the level indicators sum to the intercept. It therefore represents a factor with <img src="https://latex.codecogs.com/png.latex?K"> levels using <img src="https://latex.codecogs.com/png.latex?K-1"> independent columns.</p>
<p>For a one-factor conditional-mean model,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_i=%5Cmu_%7Bg(i)%7D+%5Cvarepsilon_i,%0A%5Cqquad%0A%5Coperatorname%7BE%7D(%5Cvarepsilon_i%5Cmid%20g(i))=0,%0A"></p>
<p>the scientifically meaningful parameters are the level means <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%5Cmu=(%5Cmu_1,%5Cldots,%5Cmu_K)%5E%5Cmathsf%7BT%7D">. A coding scheme chooses a full-rank coordinate system for the same <img src="https://latex.codecogs.com/png.latex?K"> means. Changing coordinates changes the displayed coefficients, but not fitted values or any estimable comparison computed consistently from the model.</p>
<p>This distinction is central:</p>
<ul>
<li><strong>Coding coefficients</strong> describe a parameterization.</li>
<li><strong>A contrast</strong> describes a scientific comparison.</li>
<li><strong>An estimate</strong> is the contrast evaluated from the fitted model.</li>
</ul>
</section>
<section id="treatment-coding-and-its-interpretation" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Treatment Coding and Its Interpretation</h1>
<p>With three levels—control, drug A, and drug B—and control as the reference, treatment coding gives</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(Y_i%5Cmid%20g_i)%0A=%5Cbeta_0+%5Cbeta_A%20I(g_i=A)+%5Cbeta_B%20I(g_i=B).%0A"></p>
<p>The coefficients are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbeta_0=%5Cmu_C,%0A%5Cqquad%0A%5Cbeta_A=%5Cmu_A-%5Cmu_C,%0A%5Cqquad%0A%5Cbeta_B=%5Cmu_B-%5Cmu_C.%0A"></p>
<p>Thus the intercept is the control mean and each slope is a difference from control. Changing the reference level changes all three coefficient meanings, but the fitted group means remain <img src="https://latex.codecogs.com/png.latex?(%5Chat%5Cmu_C,%5Chat%5Cmu_A,%5Chat%5Cmu_B)">.</p>
<p>Reference coding is convenient when one level is a genuine scientific baseline. It is less useful when the questions concern a dose trend, an average of several controls, or A versus B. Those questions should be stated as contrasts rather than inferred indirectly from whichever coefficients software happens to print.</p>
</section>
<section id="a-contrast-is-the-estimand" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> A Contrast Is the Estimand</h1>
<p>A linear contrast of level means is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cpsi=%5Cmathbf%20c%5E%5Cmathsf%7BT%7D%5Cboldsymbol%5Cmu%0A=%5Csum_%7Bk=1%7D%5E%7BK%7Dc_k%5Cmu_k,%0A%5Cqquad%0A%5Csum_%7Bk=1%7D%5E%7BK%7Dc_k=0.%0A"></p>
<p>The zero-sum condition makes the comparison invariant to adding the same constant to every level. Examples for <img src="https://latex.codecogs.com/png.latex?(C,A,B)"> include</p>
<table class="caption-top table">
<colgroup>
<col style="width: 30%">
<col style="width: 40%">
<col style="width: 30%">
</colgroup>
<thead>
<tr class="header">
<th>Question</th>
<th style="text-align: right;">Contrast weights <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20c"></th>
<th>Estimand</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>A versus control</td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?(-1,1,0)"></td>
<td><img src="https://latex.codecogs.com/png.latex?%5Cmu_A-%5Cmu_C"></td>
</tr>
<tr class="even">
<td>B versus control</td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?(-1,0,1)"></td>
<td><img src="https://latex.codecogs.com/png.latex?%5Cmu_B-%5Cmu_C"></td>
</tr>
<tr class="odd">
<td>A versus B</td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?(0,1,-1)"></td>
<td><img src="https://latex.codecogs.com/png.latex?%5Cmu_A-%5Cmu_B"></td>
</tr>
<tr class="even">
<td>Average drug versus control</td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?(-1,1/2,1/2)"></td>
<td><img src="https://latex.codecogs.com/png.latex?(%5Cmu_A+%5Cmu_B)/2-%5Cmu_C"></td>
</tr>
</tbody>
</table>
<p>Let <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cboldsymbol%5Cbeta%7D"> be the fitted coefficient vector with covariance <img src="https://latex.codecogs.com/png.latex?%5Cwidehat%7B%5Cmathbf%20V%7D">. If the desired comparison is <img src="https://latex.codecogs.com/png.latex?%5Cpsi=%5Cmathbf%20l%5E%5Cmathsf%7BT%7D%5Cboldsymbol%5Cbeta">, then</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%5Cpsi=%5Cmathbf%20l%5E%5Cmathsf%7BT%7D%5Chat%7B%5Cboldsymbol%5Cbeta%7D,%0A%5Cqquad%0A%5Cwidehat%7B%5Coperatorname%7BSE%7D%7D(%5Chat%5Cpsi)%0A=%5Csqrt%7B%5Cmathbf%20l%5E%5Cmathsf%7BT%7D%5Cwidehat%7B%5Cmathbf%20V%7D%5Cmathbf%20l%7D.%0A"></p>
<p>An interval or test follows from this estimate and standard error using a reference distribution appropriate to the design and covariance estimator. The contrast should be chosen because it answers a prespecified question, not because it produces the smallest p-value.</p>
</section>
<section id="other-coding-systems" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Other Coding Systems</h1>
<p>Different full-rank codings emphasize different coordinates:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Coding</th>
<th>Typical coefficient interpretation</th>
<th>Important caution</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Treatment/reference</td>
<td>Each nonreference level minus a baseline</td>
<td>Intercept and slopes depend on the chosen reference</td>
</tr>
<tr class="even">
<td>Sum-to-zero</td>
<td>Deviations from an equally weighted grand mean</td>
<td>The grand mean is not the sample-size-weighted mean in an unbalanced design</td>
</tr>
<tr class="odd">
<td>Helmert</td>
<td>A level compared with an average of subsequent or previous levels</td>
<td>Direction and scaling conventions differ among software</td>
</tr>
<tr class="even">
<td>Polynomial</td>
<td>Linear, quadratic, and higher-order patterns across ordered levels</td>
<td>Meaningful only when ordering and spacing are defensible</td>
</tr>
<tr class="odd">
<td>Custom</td>
<td>Coordinates aligned with planned scientific hypotheses</td>
<td>Must have adequate rank and documented weights</td>
</tr>
</tbody>
</table>
<p>Orthogonal contrast vectors satisfy <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20c_j%5E%5Cmathsf%7BT%7D%5Cmathbf%20c_k=0"> for <img src="https://latex.codecogs.com/png.latex?j%5Cne%20k">. In a balanced one-way design, their sums of squares partition the factor sum of squares. In unbalanced or covariate-adjusted data, algebraic orthogonality of the weights does not necessarily imply uncorrelated estimates.</p>
<p>A factor with <img src="https://latex.codecogs.com/png.latex?K"> levels contributes <img src="https://latex.codecogs.com/png.latex?K-1"> degrees of freedom. A single coefficient test answers one coordinate-specific question; an omnibus <img src="https://latex.codecogs.com/png.latex?K-1"> degree-of-freedom test asks whether all relevant level differences are zero. A nonsignificant omnibus test does not validate every equality, and a significant omnibus test does not identify which contrast matters.</p>
</section>
<section id="adjustment-changes-what-is-being-compared" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Adjustment Changes What Is Being Compared</h1>
<p>With additional covariates,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(Y_i%5Cmid%20g_i,%5Cmathbf%20z_i)%0A=%5Calpha+%5Ctext%7Bfactor%20terms%7D(g_i)+%5Cmathbf%20z_i%5E%5Cmathsf%7BT%7D%5Cboldsymbol%5Cgamma,%0A"></p>
<p>factor coefficients are conditional comparisons at the same <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20z">. If there are no factor-by-covariate interactions, the adjusted difference is constant over <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20z">. With interactions, there is no single group difference until values or a distribution of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20z"> are specified.</p>
<p>Estimated marginal means compute model-based predictions for each level and average them over a declared reference distribution of covariates. Equal weighting across cells, weighting by the observed sample, and weighting by a target population answer different questions. In unbalanced observational data, calling one of them “the adjusted mean” without stating the averaging rule hides part of the estimand.</p>
<p>Adjusted comparisons also require overlap. If a treatment occurs only in one batch, the treatment and batch columns are aliased: no coding scheme can recover their separate effects. Sparse treatment-by-tissue cells may technically permit a fit while making the requested contrast largely extrapolative.</p>
</section>
<section id="worked-example-three-library-preparation-methods" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Worked Example: Three Library-preparation Methods</h1>
<p>Suppose RNA integrity is measured for independent donor samples processed by a standard method <img src="https://latex.codecogs.com/png.latex?S"> or alternatives <img src="https://latex.codecogs.com/png.latex?A"> and <img src="https://latex.codecogs.com/png.latex?B">. The fitted adjusted means are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A(%5Chat%5Cmu_S,%5Chat%5Cmu_A,%5Chat%5Cmu_B)=(7.10,7.45,7.20).%0A"></p>
<p>The planned contrast comparing the average alternative with the standard method is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%5Cpsi%0A=-%5Chat%5Cmu_S+%5Ctfrac12%5Chat%5Cmu_A+%5Ctfrac12%5Chat%5Cmu_B%0A=0.225.%0A"></p>
<p>That estimate does not equal the A-versus-S coefficient, the B-versus-S coefficient, or an unweighted average of all three means. Its standard error must use the covariance among the three fitted means; treating their individual standard errors as independent is generally wrong.</p>
<p>If the same donor material was split across methods, donor is a blocking or repeated-measures unit and the model must retain that pairing. If different donors received different methods, donors are the independent experimental units. Technical lanes, aliquots, and reads do not increase the biological replication unless the target explicitly concerns technical repeatability.</p>
</section>
<section id="diagnostics-sensitivity-and-reporting" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Diagnostics, Sensitivity, and Reporting</h1>
<p>Before interpreting a factor or contrast:</p>
<ol type="1">
<li><strong>Verify levels and reference meaning.</strong> Check spelling, unused levels, ordering, and whether a numeric code was accidentally treated as continuous.</li>
<li><strong>Inspect the design matrix.</strong> Confirm rank, columns, aliases, empty cells, and the coding actually used by the software.</li>
<li><strong>Inspect cell counts and overlap.</strong> Report independent units per relevant factor combination, not only the total record count.</li>
<li><strong>Check the outcome model.</strong> Residual, variance, dependence, and influence diagnostics still apply; factor coding does not repair misspecification.</li>
<li><strong>Define the contrast family.</strong> Prespecify the comparisons and use simultaneous intervals or multiplicity adjustment when many claims form one family.</li>
<li><strong>Test coding invariance.</strong> Refit with another full-rank coding and confirm that fitted values and explicitly reconstructed contrasts agree.</li>
<li><strong>State the averaging population.</strong> For marginal means, document covariate values and weights.</li>
</ol>
<p>Report the contrast weights or plain-language comparison, estimate, uncertainty interval, scale and units, covariance method, adjustment set, and multiplicity procedure. A coefficient table alone is not a complete account of a multi-level factor.</p>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/multiple-linear-regression.html">Multiple linear regression</a> defines the design-matrix model in which factor columns are fitted.</li>
<li><a href="../../../knowledge/statistics/regression-models/least-squares-and-regression-geometry.html">Least squares and the geometry of regression</a> explains rank, estimability, and covariance of linear functions.</li>
<li><a href="../../../knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html">Regression uncertainty and coefficient interpretation</a> develops conditional coefficients, contrasts, and prediction uncertainty.</li>
<li><a href="../../../knowledge/statistics/regression-models/interaction-terms-and-effect-modification.html">Interaction terms and effect modification</a> shows why a factor effect can depend on another predictor.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/bonferroni-holm-and-hochberg-procedures.html">Bonferroni, Holm, and Hochberg procedures</a> addresses multiplicity across planned or exploratory contrasts.</li>
</ul>
<ol type="1">
<li>A coding scheme parameterizes group means; a contrast defines the scientific comparison.</li>
<li>Full-rank recoding changes coefficient labels, not fitted values or consistently computed estimable contrasts.</li>
<li>In unbalanced data, adjusted or marginal means depend on an explicit covariate distribution and weighting rule.</li>
<li>Empty cells, aliasing, and poor overlap are design problems that recoding cannot solve.</li>
<li>Biological inference follows the number and structure of independent samples, not the number of technical observations.</li>
</ol>
</section>
<section id="references" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> References</h1>
<ul>
<li>Fisher, R. A. (1935). <em>The Design of Experiments</em>. Oliver and Boyd.</li>
<li>Searle, S. R., Speed, F. M., and Milliken, G. A. (1980). Population marginal means in the linear model: an alternative to least squares means. <em>The American Statistician</em>, 34(4), 216–221. <a href="https://doi.org/10.1080/00031305.1980.10483031" class="uri">https://doi.org/10.1080/00031305.1980.10483031</a></li>
<li>Schad, D. J., Vasishth, S., Hohenstein, S., and Kliegl, R. (2020). How to capitalize on a priori contrasts in linear (mixed) models: a tutorial. <em>Journal of Memory and Language</em>, 110, 104038. <a href="https://doi.org/10.1016/j.jml.2019.104038" class="uri">https://doi.org/10.1016/j.jml.2019.104038</a></li>
<li>Gelman, A., Hill, J., and Vehtari, A. (2020). <em>Regression and Other Stories</em>. Cambridge University Press. <a href="https://doi.org/10.1017/9781139161879" class="uri">https://doi.org/10.1017/9781139161879</a></li>
<li>R Core Team. <code>contrasts</code>: get and set contrast matrices, and <code>model.matrix</code>: construct design matrices. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/contrasts.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/contrasts.html</a></li>
<li>Lenth, R. V. <code>emmeans</code>: estimated marginal means. <em>R package documentation</em>. <a href="https://rvlenth.github.io/emmeans/" class="uri">https://rvlenth.github.io/emmeans/</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Categorical Predictors</category>
  <category>Contrasts</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/categorical-predictors-and-contrasts.html</guid>
  <pubDate>Wed, 14 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Interaction Terms and Effect Modification</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/interaction-terms-and-effect-modification.html</link>
  <description><![CDATA[ 





<section id="an-effect-can-depend-on-context" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> An Effect Can Depend on Context</h1>
<p>An interaction term represents nonadditivity on the scale of a statistical model: the association between one predictor and the outcome changes with another predictor. Effect modification is the corresponding scientific idea that a specified effect differs across levels of a modifier or across populations.</p>
<p>These statements are incomplete until the outcome scale, effect measure, covariates, and target population are specified. The same data can exhibit no interaction in mean differences but interaction in ratios, or vice versa. Statistical interaction also does not by itself establish a physical or causal mechanism.</p>
</section>
<section id="the-product-term-model" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> The Product-term Model</h1>
<p>For predictors <img src="https://latex.codecogs.com/png.latex?X"> and <img src="https://latex.codecogs.com/png.latex?Z">, the linear conditional-mean model</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(Y%5Cmid%20X,Z)%0A=%5Cbeta_0+%5Cbeta_1X+%5Cbeta_2Z+%5Cbeta_3XZ%0A"></p>
<p>has conditional slope</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7B%5Cpartial%5Coperatorname%7BE%7D(Y%5Cmid%20X,Z)%7D%7B%5Cpartial%20X%7D%0A=%5Cbeta_1+%5Cbeta_3Z.%0A"></p>
<p>Thus <img src="https://latex.codecogs.com/png.latex?%5Cbeta_3"> is the change in the <img src="https://latex.codecogs.com/png.latex?X"> slope for a one-unit increase in <img src="https://latex.codecogs.com/png.latex?Z">. The “main effect” <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> is the <img src="https://latex.codecogs.com/png.latex?X"> slope specifically at <img src="https://latex.codecogs.com/png.latex?Z=0">, while <img src="https://latex.codecogs.com/png.latex?%5Cbeta_2"> is the <img src="https://latex.codecogs.com/png.latex?Z"> slope at <img src="https://latex.codecogs.com/png.latex?X=0">. They are not average effects unless the coding and design make them so.</p>
<p>Centering <img src="https://latex.codecogs.com/png.latex?Z"> at a meaningful value <img src="https://latex.codecogs.com/png.latex?z_0"> makes <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> the <img src="https://latex.codecogs.com/png.latex?X"> slope at <img src="https://latex.codecogs.com/png.latex?Z=z_0">. It changes the lower-order coefficients but not fitted values or the interaction coefficient when the same linear scale is used. Centering can improve interpretability; it cannot create overlap or remove genuine collinearity between the scientific quantities of interest.</p>
</section>
<section id="categorical-interactions-are-differences-in-differences" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Categorical Interactions Are Differences in Differences</h1>
<p>Let <img src="https://latex.codecogs.com/png.latex?A"> and <img src="https://latex.codecogs.com/png.latex?B"> be binary indicators. The model</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(Y%5Cmid%20A,B)%0A=%5Cbeta_0+%5Cbeta_AA+%5Cbeta_BB+%5Cbeta_%7BAB%7DAB%0A"></p>
<p>implies four conditional means:</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?A"></th>
<th style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?B"></th>
<th>Conditional mean</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td><img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"></td>
</tr>
<tr class="even">
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td><img src="https://latex.codecogs.com/png.latex?%5Cbeta_0+%5Cbeta_A"></td>
</tr>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">1</td>
<td><img src="https://latex.codecogs.com/png.latex?%5Cbeta_0+%5Cbeta_B"></td>
</tr>
<tr class="even">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td><img src="https://latex.codecogs.com/png.latex?%5Cbeta_0+%5Cbeta_A+%5Cbeta_B+%5Cbeta_%7BAB%7D"></td>
</tr>
</tbody>
</table>
<p>The interaction is the difference in differences:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%0A%5Cbeta_%7BAB%7D%0A=%5C%7B%5Cmu_%7B11%7D-%5Cmu_%7B01%7D%5C%7D-%5C%7B%5Cmu_%7B10%7D-%5Cmu_%7B00%7D%5C%7D%0A%7D.%0A"></p>
<p>It asks whether the A difference at <img src="https://latex.codecogs.com/png.latex?B=1"> differs from the A difference at <img src="https://latex.codecogs.com/png.latex?B=0">. Reversing the order gives the same additive interaction. With factors having more than two levels, an interaction is a set of contrasts and should usually be assessed through scientifically chosen comparisons or an omnibus multi-degree-of-freedom test rather than one arbitrarily selected coefficient.</p>
</section>
<section id="scale-determines-the-interaction" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Scale Determines the Interaction</h1>
<p>In a generalized linear model,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ag%5C%7B%5Coperatorname%7BE%7D(Y%5Cmid%20X,Z)%5C%7D%0A=%5Cbeta_0+%5Cbeta_1X+%5Cbeta_2Z+%5Cbeta_3XZ,%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbeta_3"> describes interaction on the link scale.</p>
<ul>
<li>In a linear model with identity link, it is departure from additivity of means.</li>
<li>In a log-link model, it is departure from multiplicativity of means or risks.</li>
<li>In logistic regression, it is departure from multiplicativity of odds.</li>
</ul>
<p>A zero product coefficient in logistic regression does not imply constant risk differences or risk ratios. Conversely, heterogeneous odds ratios can coexist with nearly constant risk differences. For binary outcomes, report predicted risks for joint exposure groups and contrasts on scientifically relevant scales; do not let the default link silently define “no interaction.”</p>
<p>For two binary exposures, additive interaction in risks can be summarized by</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BRERI%7D%0A=RR_%7B11%7D-RR_%7B10%7D-RR_%7B01%7D+1,%0A"></p>
<p>when risk ratios use the unexposed group as reference. <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BRERI%7D=0"> means no departure from additivity of risk relative to baseline. This is a different null from a product-term coefficient of zero in a log or logit model.</p>
</section>
<section id="statistical-interaction-and-causal-effect-modification" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Statistical Interaction and Causal Effect Modification</h1>
<p>An observed conditional association is not automatically a causal effect. A causal effect modifier is defined relative to an intervention contrast, outcome scale, covariate set, and target population. For example, an additive conditional average treatment effect at <img src="https://latex.codecogs.com/png.latex?Z=z"> is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ctau(z)=%0A%5Coperatorname%7BE%7D%5C%7BY(1)-Y(0)%5Cmid%20Z=z%5C%7D,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?Y(a)"> is the potential outcome under exposure <img src="https://latex.codecogs.com/png.latex?a">. Identifying <img src="https://latex.codecogs.com/png.latex?%5Ctau(z)"> from observational data requires consistency, conditional exchangeability, positivity within modifier strata, and an adequate measurement and sampling process. A regression product term supplies a functional form; it does not supply those assumptions.</p>
<p>Effect modification is population dependent. Stratum-specific effects may be stable while a marginal effect changes because the distribution of baseline risk or other covariates changes. Noncollapsible measures such as the odds ratio can also change between conditional and marginal analyses without confounding. Specify whether the target is conditional or marginal and how standardization to the target population is performed.</p>
</section>
<section id="estimation-and-uncertainty" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Estimation and Uncertainty</h1>
<p>Suppose the fitted covariance matrix of <img src="https://latex.codecogs.com/png.latex?(%5Chat%5Cbeta_1,%5Chat%5Cbeta_3)"> is <img src="https://latex.codecogs.com/png.latex?%5Cwidehat%7B%5Cmathbf%20V%7D_%7B13%7D">. The estimated <img src="https://latex.codecogs.com/png.latex?X"> slope at <img src="https://latex.codecogs.com/png.latex?Z=z"> is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%20s(z)=%5Chat%5Cbeta_1+z%5Chat%5Cbeta_3,%0A"></p>
<p>with variance</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%7B%5Coperatorname%7BVar%7D%7D%5C%7B%5Chat%20s(z)%5C%7D%0A=%0A%5Cbegin%7Bpmatrix%7D1&amp;z%5Cend%7Bpmatrix%7D%0A%5Cwidehat%7B%5Cmathbf%20V%7D_%7B13%7D%0A%5Cbegin%7Bpmatrix%7D1%5C%5Cz%5Cend%7Bpmatrix%7D.%0A"></p>
<p>Plotting <img src="https://latex.codecogs.com/png.latex?%5Chat%20s(z)"> or predicted outcomes with pointwise or simultaneous uncertainty is usually clearer than reporting only the p-value for <img src="https://latex.codecogs.com/png.latex?%5Cbeta_3">. Inference must still respect heteroskedasticity, clustering, repeated measures, and the number of independent experimental units.</p>
<p>Interaction tests often have low power because the modifier splits the available information and the product term is correlated with lower-order terms. Absence of statistical significance is not evidence of homogeneous effects. Report effect estimates and intervals in prespecified strata, and design studies around the interaction contrast rather than the easier main-effect calculation.</p>
</section>
<section id="the-hierarchy-principle-and-model-specification" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> The Hierarchy Principle and Model Specification</h1>
<p>When <img src="https://latex.codecogs.com/png.latex?XZ"> is included, retain <img src="https://latex.codecogs.com/png.latex?X"> and <img src="https://latex.codecogs.com/png.latex?Z"> unless a scientifically justified parameterization deliberately omits them. Dropping lower-order terms imposes constraints such as equality of groups at <img src="https://latex.codecogs.com/png.latex?Z=0">; it does not merely simplify the model. Keeping hierarchy also makes the model invariant to shifts of the predictor origin.</p>
<p>Product terms encode a linear change in a linear slope. They may be inadequate when either predictor has a nonlinear effect. A flexible model can include spline-by-group interactions, but flexibility increases data requirements and the risk of discovering unstable subgroups. Choices of cutpoints, modifiers, transformations, and outcome scales should be prespecified or transparently treated as exploratory.</p>
</section>
<section id="worked-bioinformatics-example" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Worked Bioinformatics Example</h1>
<p>Suppose normalized expression of a pathway score is measured in independent patient biopsies. Treatment <img src="https://latex.codecogs.com/png.latex?A"> is randomized, tissue type <img src="https://latex.codecogs.com/png.latex?Z"> is measured at baseline, and the model includes treatment, tissue, their interaction, and prespecified batch covariates.</p>
<p>If fitted treatment differences are <img src="https://latex.codecogs.com/png.latex?1.2"> log-expression units in tissue 0 and <img src="https://latex.codecogs.com/png.latex?0.3"> in tissue 1, then the additive interaction estimate is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A0.3-1.2=-0.9.%0A"></p>
<p>Statistically, the data suggest that the treatment contrast on this scale is smaller in tissue 1. Biologically, that pattern might motivate a tissue-specific mechanism, but the interaction alone does not prove one. Tissue-specific assay behavior, batch imbalance, compositional shifts, or sparse treatment-by-tissue cells may produce the same pattern.</p>
<p>The patient is the experimental unit. Multiple cells, spots, images, or technical runs from one biopsy refine its measurement but do not become independent replicates of the treatment-by-tissue interaction. A cell-level model must retain patient clustering or aggregate to justified sample-level summaries. If tissue was not randomized, causal claims about tissue and mechanistic synergy require additional assumptions beyond treatment randomization.</p>
</section>
<section id="diagnostics-and-sensitivity" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Diagnostics and Sensitivity</h1>
<p>An interaction analysis should examine more than the product-term p-value:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th>Question</th>
<th>Diagnostic or sensitivity analysis</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Is there support for every comparison?</td>
<td>Cell counts, predictor overlap, joint-density plots, leverage</td>
</tr>
<tr class="even">
<td>Is the chosen functional form adequate?</td>
<td>Predicted-versus-observed patterns, residuals by modifier, splines or prespecified transformations</td>
</tr>
<tr class="odd">
<td>Does one unit determine the interaction?</td>
<td>Interaction-specific influence and leave-one-independent-unit-out fits</td>
</tr>
<tr class="even">
<td>Does the conclusion depend on scale?</td>
<td>Report predictions and contrasts on additive and multiplicative scales when relevant</td>
</tr>
<tr class="odd">
<td>Is uncertainty calibrated?</td>
<td>Cluster-aware covariance or model, finite-sample corrections, design-respecting bootstrap</td>
</tr>
<tr class="even">
<td>Was the modifier selected after inspection?</td>
<td>Distinguish confirmatory from exploratory analysis; validate in new samples</td>
</tr>
<tr class="odd">
<td>Is a causal interpretation defensible?</td>
<td>Check exchangeability, positivity, consistency, measurement, and target-population assumptions</td>
</tr>
</tbody>
</table>
<p>Dichotomizing a continuous modifier discards information, creates an arbitrary threshold, and can make subgroup conclusions unstable. Prefer a continuous functional form and show predictions over regions with adequate data. Avoid claims that an effect exists in one subgroup but not another merely because one subgroup p-value crosses 0.05 and the other does not; the relevant test compares the subgroup effects directly.</p>
</section>
<section id="reporting-the-scientific-result" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> Reporting the Scientific Result</h1>
<p>Report:</p>
<ol type="1">
<li>the outcome scale and effect measure;</li>
<li>the modifier, coding, reference values, and target population;</li>
<li>joint cell counts or the range of continuous-modifier support;</li>
<li>predicted outcomes and conditional effects with intervals at meaningful values;</li>
<li>the interaction contrast with uncertainty, not two separate significance labels;</li>
<li>adjustment, clustering, multiplicity, and exploratory selection procedures;</li>
<li>sensitivity to functional form, influential units, and alternative effect scales.</li>
</ol>
<p>The result should say “the estimated treatment difference changed by … on the … scale,” rather than vaguely claiming that two variables “interact.”</p>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/categorical-predictors-and-contrasts.html">Categorical predictors and contrasts</a> shows how group comparisons become estimable linear functions.</li>
<li><a href="../../../knowledge/statistics/regression-models/multiple-linear-regression.html">Multiple linear regression</a> provides the conditional-mean and design-matrix foundation.</li>
<li><a href="../../../knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html">Regression uncertainty and coefficient interpretation</a> derives uncertainty for linear combinations of coefficients.</li>
<li><a href="../../../knowledge/statistics/regression-models/linear-model-assumptions-and-diagnostics.html">Linear-model assumptions and diagnostics</a> covers functional-form, leverage, dependence, and extrapolation checks.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-power-and-sample-size-calculation.html">Statistical power and sample-size calculation</a> explains why the intended interaction must drive design planning.</li>
</ul>
<ol type="1">
<li>An interaction is a departure from additivity on a declared model or effect scale; it is not an intrinsic property of two variables.</li>
<li>Lower-order coefficients in a product-term model are conditional effects at the other predictor’s reference value.</li>
<li>Interpret and plot conditional effects or predicted outcomes, with uncertainty, rather than relying on a product-term p-value.</li>
<li>Causal effect modification requires design and identification assumptions that regression algebra cannot provide.</li>
<li>Sparse joint cells, data-driven subgroup searches, and technical pseudoreplication make interaction estimates especially unstable.</li>
</ol>
</section>
<section id="references" class="level1" data-number="12">
<h1 data-number="12"><span class="header-section-number">12</span> References</h1>
<ul>
<li>Cox, D. R. (1984). Interaction. <em>International Statistical Review</em>, 52(1), 1–31. <a href="https://doi.org/10.2307/1403235" class="uri">https://doi.org/10.2307/1403235</a></li>
<li>VanderWeele, T. J. (2009). On the distinction between interaction and effect modification. <em>Epidemiology</em>, 20(6), 863–871. <a href="https://doi.org/10.1097/EDE.0b013e3181ba333c" class="uri">https://doi.org/10.1097/EDE.0b013e3181ba333c</a></li>
<li>Knol, M. J., and VanderWeele, T. J. (2012). Recommendations for presenting analyses of effect modification and interaction. <em>International Journal of Epidemiology</em>, 41(2), 514–520. <a href="https://doi.org/10.1093/ije/dyr218" class="uri">https://doi.org/10.1093/ije/dyr218</a></li>
<li>VanderWeele, T. J., and Knol, M. J. (2014). A tutorial on interaction. <em>Epidemiologic Methods</em>, 3(1), 33–72. <a href="https://doi.org/10.1515/em-2013-0005" class="uri">https://doi.org/10.1515/em-2013-0005</a></li>
<li>Gelman, A., Hill, J., and Vehtari, A. (2020). <em>Regression and Other Stories</em>. Cambridge University Press. <a href="https://doi.org/10.1017/9781139161879" class="uri">https://doi.org/10.1017/9781139161879</a></li>
<li>R Core Team. <code>formula</code>: model formulae and <code>model.matrix</code>: construct design matrices. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/formula.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/formula.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Interaction</category>
  <category>Effect Modification</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/interaction-terms-and-effect-modification.html</guid>
  <pubDate>Wed, 14 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Linear-model Assumptions and Diagnostics</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/linear-model-assumptions-and-diagnostics.html</link>
  <description><![CDATA[ 





<section id="assumptions-belong-to-claims" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Assumptions Belong to Claims</h1>
<p>For independent experimental units, a linear model starts with a conditional mean:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_i=%5Cmathbf%7Bx%7D_i%5E%5Cmathsf%7BT%7D%5Cboldsymbol%5Cbeta+%5Cvarepsilon_i,%0A%5Cqquad%0A%5Coperatorname%7BE%7D(%5Cvarepsilon_i%5Cmid%5Cmathbf%20X)=0.%0A"></p>
<p>Different conclusions require different assumptions. Ordinary least squares (OLS) can always compute the best-fitting linear projection when the design matrix has full column rank. Interpreting its coefficients as a correctly specified conditional mean additionally requires the mean model to be adequate. Classical standard errors require the variance and dependence model; exact small-sample <img src="https://latex.codecogs.com/png.latex?t"> and <img src="https://latex.codecogs.com/png.latex?F"> inference adds conditional normality. Causal interpretation needs design assumptions that residual plots cannot establish.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th>Goal</th>
<th>Central requirements</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Compute a unique OLS fit</td>
<td>Full column rank and more observations than fitted coefficients</td>
</tr>
<tr class="even">
<td>Estimate the stated conditional-mean coefficients without bias</td>
<td><img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BE%7D(%5Cboldsymbol%5Cvarepsilon%5Cmid%5Cmathbf%20X)=%5Cmathbf%200"></td>
</tr>
<tr class="odd">
<td>Use the classical covariance formula</td>
<td>Constant conditional variance and uncorrelated errors</td>
</tr>
<tr class="even">
<td>Use exact small-sample <img src="https://latex.codecogs.com/png.latex?t"> and <img src="https://latex.codecogs.com/png.latex?F"> laws</td>
<td>Conditional Gaussian errors in addition to the classical conditions</td>
</tr>
<tr class="odd">
<td>Generalize to a target population</td>
<td>A defensible sampling frame and stable data-generating process</td>
</tr>
<tr class="even">
<td>Interpret a coefficient causally</td>
<td>Exchangeability or randomization, positivity, consistency, and an appropriate adjustment set</td>
</tr>
</tbody>
</table>
<p>The experimental unit is the unit whose error contributes independent information. Replicate reads, wells, images, or cells nested within the same specimen are not automatically independent experimental units.</p>
</section>
<section id="the-assumptions-one-by-one" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> The Assumptions, One by One</h1>
<section id="linear-conditional-mean" class="level2" data-number="2.1">
<h2 data-number="2.1" class="anchored" data-anchor-id="linear-conditional-mean"><span class="header-section-number">2.1</span> Linear conditional mean</h2>
<p>The model asserts</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(Y_i%5Cmid%5Cmathbf%20x_i)%0A=%5Cmathbf%20x_i%5E%5Cmathsf%7BT%7D%5Cboldsymbol%5Cbeta.%0A"></p>
<p>“Linear” means linear in <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%5Cbeta">; predictors may enter through polynomials, splines, indicators, or interactions. A curved residual trend can indicate a missing transformation or nonlinear term. A group-specific trend can indicate a missing interaction. If the mean is misspecified, an OLS coefficient usually estimates a design-dependent linear projection rather than the intended scientific contrast.</p>
</section>
<section id="zero-conditional-mean" class="level2" data-number="2.2">
<h2 data-number="2.2" class="anchored" data-anchor-id="zero-conditional-mean"><span class="header-section-number">2.2</span> Zero conditional mean</h2>
<p>The condition</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(%5Cvarepsilon_i%5Cmid%5Cmathbf%20X)=0%0A"></p>
<p>rules out systematic residual association with the included design. It can fail because of omitted causes, selection, reverse causation, measurement error, or a wrong mean function. Residuals are algebraically orthogonal to fitted design columns, so a residual plot against an included predictor cannot prove this population condition. Study design, subject-matter knowledge, negative controls, and sensitivity analysis are essential.</p>
</section>
<section id="variance-and-dependence" class="level2" data-number="2.3">
<h2 data-number="2.3" class="anchored" data-anchor-id="variance-and-dependence"><span class="header-section-number">2.3</span> Variance and dependence</h2>
<p>The classical model uses</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BVar%7D(%5Cboldsymbol%5Cvarepsilon%5Cmid%5Cmathbf%20X)%0A=%5Csigma%5E2%5Cmathbf%20I.%0A"></p>
<p>Its two parts are distinct:</p>
<ul>
<li><strong>Homoskedasticity:</strong> every unit has the same conditional error variance.</li>
<li><strong>No residual dependence:</strong> off-diagonal conditional covariances are zero.</li>
</ul>
<p>Heteroskedasticity does not by itself bias OLS coefficients under a correct mean model, but it invalidates the usual covariance estimator and makes OLS inefficient. Correlation within people, plates, families, time series, or spatial regions requires a cluster-aware, longitudinal, spatial, mixed, or generalized least-squares analysis. A heteroskedasticity-consistent standard error does not repair dependence.</p>
</section>
<section id="rank-overlap-and-extrapolation" class="level2" data-number="2.4">
<h2 data-number="2.4" class="anchored" data-anchor-id="rank-overlap-and-extrapolation"><span class="header-section-number">2.4</span> Rank, overlap, and extrapolation</h2>
<p>With <img src="https://latex.codecogs.com/png.latex?k"> fitted coefficients, <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X"> must have rank <img src="https://latex.codecogs.com/png.latex?k"> for a unique coefficient vector. Near collinearity can leave fitted values stable while making individual coefficients highly variable. Even with full rank, a conditional contrast may depend on sparse combinations of covariates. Diagnostics should therefore examine predictor distributions, cross-tabulations, condition numbers, and the range over which predictions are requested—not only residuals.</p>
</section>
<section id="conditional-normality" class="level2" data-number="2.5">
<h2 data-number="2.5" class="anchored" data-anchor-id="conditional-normality"><span class="header-section-number">2.5</span> Conditional normality</h2>
<p>Gaussian errors are not needed to define OLS or to make it unbiased under the mean model. They yield exact finite-sample reference distributions:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7B%5Chat%5Cbeta_j-%5Cbeta_j%7D%7B%5Cwidehat%7B%5Coperatorname%7BSE%7D%7D(%5Chat%5Cbeta_j)%7D%0A%5Csim%20t_%7Bn-k%7D.%0A"></p>
<p>Without normality, large-sample inference may still work under suitable moment, leverage, and independence conditions. Severe skewness, heavy tails, sparse groups, or a few dominant observations can make that approximation inaccurate.</p>
</section>
</section>
<section id="residuals-and-leverage" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Residuals and Leverage</h1>
<p>Let</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbf%20H=%5Cmathbf%20X(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20X%5E%5Cmathsf%7BT%7D,%0A%5Cqquad%0A%5Cmathbf%20e=(%5Cmathbf%20I-%5Cmathbf%20H)%5Cmathbf%20Y.%0A"></p>
<p>The diagonal <img src="https://latex.codecogs.com/png.latex?h_%7Bii%7D"> is the leverage of unit <img src="https://latex.codecogs.com/png.latex?i">. It depends only on the design matrix and measures how unusual the predictor configuration is relative to the others. Because <img src="https://latex.codecogs.com/png.latex?%5Csum_i%20h_%7Bii%7D=k">, average leverage is <img src="https://latex.codecogs.com/png.latex?k/n">.</p>
<p>Raw residual variances are unequal even under the homoskedastic model:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BVar%7D(e_i%5Cmid%5Cmathbf%20X)=%5Csigma%5E2(1-h_%7Bii%7D).%0A"></p>
<p>An internally studentized residual is therefore</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ar_i=%5Cfrac%7Be_i%7D%7Bs%5Csqrt%7B1-h_%7Bii%7D%7D%7D.%0A"></p>
<p>Externally studentized residuals replace <img src="https://latex.codecogs.com/png.latex?s"> with an estimate computed after deleting unit <img src="https://latex.codecogs.com/png.latex?i">, making them more useful for judging an unusual response. A large residual means poor vertical fit; high leverage means an unusual predictor pattern. Influence requires the combination: an observation far out in predictor space can materially move the fit when its response disagrees with the trend.</p>
<p>Cook’s distance summarizes the change in all fitted values after deleting unit <img src="https://latex.codecogs.com/png.latex?i">:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AD_i=%0A%5Cfrac%7Be_i%5E2%7D%7Bk%20s%5E2%7D%0A%5Cfrac%7Bh_%7Bii%7D%7D%7B(1-h_%7Bii%7D)%5E2%7D.%0A"></p>
<p>There is no universal cutoff that turns an observation into an error. Leverage, studentized residuals, Cook’s distance, DFBETAs, and deletion fits are prompts for record verification and sensitivity analysis, not automatic deletion rules.</p>
</section>
<section id="a-diagnostic-sequence" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> A Diagnostic Sequence</h1>
<p>Diagnostics work best as a structured comparison between observed data and the model’s implications.</p>
<ol type="1">
<li><strong>Verify design and units.</strong> Confirm randomization, nesting, repeated measures, batches, missingness, coding, and which units are independent.</li>
<li><strong>Inspect predictors before fitting.</strong> Check ranges, sparse categories, impossible combinations, overlap, rank, and potential extrapolation.</li>
<li><strong>Check the mean structure.</strong> Plot residuals against fitted values, continuous predictors, time or order, and scientifically important groups. Add a smooth trend as a diagnostic, not as proof of a replacement model.</li>
<li><strong>Check conditional spread.</strong> Look for funnels, group-specific variance, and variance related to expected measurement scale.</li>
<li><strong>Check distributional shape when it matters.</strong> A normal quantile–quantile plot is relevant to exact small-sample inference and tail behavior, not to the existence of the OLS estimate.</li>
<li><strong>Assess influence.</strong> Examine leverage, externally studentized residuals, Cook’s distance, and coefficient changes under justified deletion checks.</li>
<li><strong>Refit scientifically plausible alternatives.</strong> Compare transformations, curvature, interactions, variance models, cluster-aware uncertainty, and robust procedures.</li>
<li><strong>Validate the intended use.</strong> For prediction, assess held-out calibration and error. For explanation, check whether the coefficient still answers the prespecified estimand.</li>
</ol>
<p>Formal tests of normality or heteroskedasticity can supplement this workflow, but they do not replace plots and design reasoning. With small <img src="https://latex.codecogs.com/png.latex?n">, they have little power; with very large <img src="https://latex.codecogs.com/png.latex?n">, they can flag negligible deviations. Repeatedly changing a model until every diagnostic test is nonsignificant also makes the reported inference conditional on an unreported selection process.</p>
</section>
<section id="reading-common-diagnostic-displays" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Reading Common Diagnostic Displays</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Display or quantity</th>
<th>Pattern worth investigating</th>
<th>Possible mechanisms</th>
<th>Appropriate response</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Residuals versus fitted values</td>
<td>Curvature</td>
<td>Nonlinear mean, omitted interaction, wrong link</td>
<td>Add justified structure; compare partial effects and predictions</td>
</tr>
<tr class="even">
<td>Scale–location plot</td>
<td>Increasing or group-specific spread</td>
<td>Heteroskedasticity, scale-dependent measurement</td>
<td>Transform, model variance, or use valid robust covariance</td>
</tr>
<tr class="odd">
<td>Normal Q–Q plot</td>
<td>Strong tail departures or asymmetry</td>
<td>Heavy tails, mixture, coding error, wrong outcome model</td>
<td>Verify records; use robust or outcome-appropriate model; simulate finite-sample behavior</td>
</tr>
<tr class="even">
<td>Residuals versus order, time, or batch</td>
<td>Runs or shifts</td>
<td>Drift, autocorrelation, unmodeled batch</td>
<td>Include design factors or use dependence-aware model</td>
</tr>
<tr class="odd">
<td>Leverage and Cook’s distance</td>
<td>A few dominant units</td>
<td>Sparse design, extreme predictor values, unusual outcomes</td>
<td>Verify and report deletion or perturbation sensitivity</td>
</tr>
<tr class="even">
<td>Component-plus-residual plot</td>
<td>Predictor-specific curvature</td>
<td>Missing transformation or nonlinear partial effect</td>
<td>Use a prespecified transformation or flexible smooth</td>
</tr>
</tbody>
</table>
<p>The same visual pattern can have several causes. A funnel may reflect true heteroskedasticity, an inappropriate response scale, or a mean–variance relation requiring a generalized linear model. Diagnostics localize tension; they do not identify a unique repair.</p>
</section>
<section id="worked-bioinformatics-example" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Worked Bioinformatics Example</h1>
<p>Suppose normalized gene expression is measured for 48 independent patient specimens, with treatment, age, and sequencing batch as predictors. Each specimen was sequenced in two lanes and lane counts were combined before analysis.</p>
<ul>
<li>The 48 patients—not the 96 lanes or millions of reads—are the experimental units for treatment inference.</li>
<li>A residual shift by batch suggests incomplete technical adjustment or an interaction, while a residual trend with fitted expression suggests mean or variance misspecification.</li>
<li>One high-leverage patient may combine an age and treatment pattern scarcely represented elsewhere. Its influence reveals weak support for that conditional comparison; deletion cannot create the missing overlap.</li>
<li>If residual variance increases with mean expression, robust standard errors may protect coefficient inference asymptotically, but a count model or mean–variance model may better represent the measurement process.</li>
</ul>
<p>Statistically, diagnostics ask whether the coefficient and its uncertainty are stable under credible alternatives. Biologically, they do not establish that a gene-expression association is causal, functionally important, or transferable to another tissue or population.</p>
</section>
<section id="what-diagnostics-cannot-prove" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> What Diagnostics Cannot Prove</h1>
<p>Residual checks use observed variables and the fitted sample. They cannot prove:</p>
<ul>
<li>absence of unmeasured confounding or selection bias;</li>
<li>independence when the sampling hierarchy was discarded;</li>
<li>correct measurement of the response and predictors;</li>
<li>validity outside the observed predictor range or target population;</li>
<li>biological importance of a statistically precise coefficient.</li>
</ul>
<p>A satisfactory residual plot means only that the chosen diagnostic did not expose that kind of discrepancy at its available resolution. It is not a certificate that the model is true.</p>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/multiple-linear-regression.html">Multiple linear regression</a> defines the conditional-mean model and coefficient comparisons being diagnosed.</li>
<li><a href="../../../knowledge/statistics/regression-models/least-squares-and-regression-geometry.html">Least squares and the geometry of regression</a> derives projection, residual orthogonality, leverage, and rank.</li>
<li><a href="../../../knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html">Regression uncertainty and coefficient interpretation</a> separates coefficient, contrast, mean-response, and prediction uncertainty.</li>
<li><a href="../../../knowledge/statistics/regression-models/robust-standard-errors-and-robust-regression.html">Robust standard errors and robust regression</a> distinguishes covariance protection from resistance to influential outcomes.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/sensitivity-analysis-and-robustness.html">Sensitivity analysis and robustness</a> organizes conclusions across plausible assumptions and analysis choices.</li>
</ul>
<ol type="1">
<li>State the inferential goal before deciding which assumptions matter.</li>
<li>Residuals diagnose the fitted mean and error structure but cannot establish exogeneity, causality, or correct replication.</li>
<li>Heteroskedasticity, dependence, nonlinearity, and influence are different problems and require different responses.</li>
<li>Investigate influential observations transparently; never delete them solely because a generic threshold was crossed.</li>
<li>In bioinformatics, preserving the biological experimental unit is more important than the nominal number of technical measurements.</li>
</ol>
</section>
<section id="references" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> References</h1>
<ul>
<li>Belsley, D. A., Kuh, E., and Welsch, R. E. (1980). <em>Regression Diagnostics: Identifying Influential Data and Sources of Collinearity</em>. Wiley. <a href="https://doi.org/10.1002/0471725153" class="uri">https://doi.org/10.1002/0471725153</a></li>
<li>Cook, R. D. (1977). Detection of influential observations in linear regression. <em>Technometrics</em>, 19(1), 15–18. <a href="https://doi.org/10.1080/00401706.1977.10489493" class="uri">https://doi.org/10.1080/00401706.1977.10489493</a></li>
<li>Weisberg, S. (2014). <em>Applied Linear Regression</em> (4th ed.). Wiley.</li>
<li>Gelman, A., Hill, J., and Vehtari, A. (2020). <em>Regression and Other Stories</em>. Cambridge University Press. <a href="https://doi.org/10.1017/9781139161879" class="uri">https://doi.org/10.1017/9781139161879</a></li>
<li>R Core Team. <code>lm.influence</code>: regression diagnostics. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.influence.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.influence.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Linear Models</category>
  <category>Diagnostics</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/linear-model-assumptions-and-diagnostics.html</guid>
  <pubDate>Tue, 13 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Robust Standard Errors and Robust Regression</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/robust-standard-errors-and-robust-regression.html</link>
  <description><![CDATA[ 





<section id="robust-refers-to-different-targets" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> “Robust” Refers to Different Targets</h1>
<p>Two methods with similar names solve different problems:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Method</th>
<th>Point estimate</th>
<th>Main protection</th>
<th>Does not automatically fix</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Heteroskedasticity-robust standard errors</td>
<td>Ordinary least squares</td>
<td>Covariance inference when conditional variance changes across independent units</td>
<td>Wrong mean, dependence, confounding, influential point estimates</td>
</tr>
<tr class="even">
<td>Cluster-robust standard errors</td>
<td>Usually OLS</td>
<td>Covariance inference with within-cluster dependence and many independent clusters</td>
<td>Few-cluster bias, wrong clustering level, confounding</td>
</tr>
<tr class="odd">
<td>Robust regression</td>
<td>Changes the fitted coefficients</td>
<td>Sensitivity of the point estimate to large residuals or contamination</td>
<td>High leverage, dependence, omitted variables, causal bias</td>
</tr>
</tbody>
</table>
<p>A robust standard error leaves the fitted line unchanged. Robust regression changes the fitting criterion. Choosing between them begins with the failure mechanism, not with a preference for a reassuring word.</p>
</section>
<section id="heteroskedasticity-robust-covariance" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Heteroskedasticity-robust Covariance</h1>
<p>Consider</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbf%20Y=%5Cmathbf%20X%5Cboldsymbol%5Cbeta+%5Cboldsymbol%5Cvarepsilon,%0A%5Cqquad%0A%5Coperatorname%7BE%7D(%5Cboldsymbol%5Cvarepsilon%5Cmid%5Cmathbf%20X)=%5Cmathbf%200,%0A"></p>
<p>with independent errors but unequal conditional variances <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BVar%7D(%5Cvarepsilon_i%5Cmid%5Cmathbf%20X)=%5Csigma_i%5E2">. OLS remains</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cboldsymbol%5Cbeta%7D%0A=(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20Y.%0A"></p>
<p>Its conditional covariance is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BVar%7D(%5Chat%7B%5Cboldsymbol%5Cbeta%7D%5Cmid%5Cmathbf%20X)%0A=(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D%0A%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cboldsymbol%5COmega%5Cmathbf%20X%0A(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%5COmega=%5Coperatorname%7Bdiag%7D(%5Csigma_1%5E2,%5Cldots,%5Csigma_n%5E2)">. The heteroskedasticity-consistent estimator replaces unknown variances with functions of the fitted residuals:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%0A%5Cwidehat%7B%5Cmathbf%20V%7D_%7B%5Cmathrm%7BHC%7D%7D%0A=(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D%0A%5Cleft(%5Csum_%7Bi=1%7D%5E%7Bn%7D%5Comega_i%20e_i%5E2%0A%5Cmathbf%20x_i%5Cmathbf%20x_i%5E%5Cmathsf%7BT%7D%5Cright)%0A(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D%0A%7D.%0A"></p>
<p>The outer matrices are the <strong>bread</strong> and the residual cross-products are the <strong>meat</strong>, hence “sandwich covariance.” Under appropriate moment, independence, rank, and leverage conditions, it consistently estimates the sampling covariance without specifying a parametric variance function.</p>
<section id="hc0-through-hc3" class="level2" data-number="2.1">
<h2 data-number="2.1" class="anchored" data-anchor-id="hc0-through-hc3"><span class="header-section-number">2.1</span> HC0 through HC3</h2>
<p>The variants differ in finite-sample residual corrections:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 30%">
<col style="width: 40%">
<col style="width: 30%">
</colgroup>
<thead>
<tr class="header">
<th>Estimator</th>
<th style="text-align: right;">Residual multiplier <img src="https://latex.codecogs.com/png.latex?%5Comega_i"></th>
<th>Interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>HC0</td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?1"></td>
<td>White’s basic large-sample estimator</td>
</tr>
<tr class="even">
<td>HC1</td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?n/(n-k)"></td>
<td>Degrees-of-freedom inflation</td>
</tr>
<tr class="odd">
<td>HC2</td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?1/(1-h_%7Bii%7D)"></td>
<td>Corrects residual shrinkage using leverage</td>
</tr>
<tr class="even">
<td>HC3</td>
<td style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?1/(1-h_%7Bii%7D)%5E2"></td>
<td>Stronger leverage correction, related to leave-one-out ideas</td>
</tr>
</tbody>
</table>
<p>HC0 can be too optimistic in small samples because OLS residuals are shrunken, especially at high-leverage points. HC2 or HC3 is often preferable when the number of independent units is not large. None supplies exact finite-sample inference in general; the reference distribution and degrees of freedom still need justification.</p>
</section>
</section>
<section id="what-robust-standard-errors-assume" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> What Robust Standard Errors Assume</h1>
<p>Heteroskedasticity-consistent inference is not assumption-free. It still needs:</p>
<ul>
<li>an estimand defined by an adequate mean model or linear projection;</li>
<li>zero conditional mean for an unbiased conditional-mean interpretation;</li>
<li>independent observations for the usual HC estimator;</li>
<li>a nonsingular, sufficiently stable design with no asymptotically dominant unit;</li>
<li>enough independent units for the sandwich approximation and tail calibration.</li>
</ul>
<p>If errors are correlated within <img src="https://latex.codecogs.com/png.latex?G"> independent clusters, the cluster sandwich uses cluster score sums:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%7B%5Cmathbf%20V%7D_%7B%5Cmathrm%7BCL%7D%7D%0A=(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D%0A%5Cleft(%0A%5Csum_%7Bg=1%7D%5E%7BG%7D%0A%5Cmathbf%20X_g%5E%5Cmathsf%7BT%7D%5Cmathbf%20e_g%5Cmathbf%20e_g%5E%5Cmathsf%7BT%7D%5Cmathbf%20X_g%0A%5Cright)%0A(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D,%0A"></p>
<p>with a suitable small-sample correction. Precision is driven primarily by the number and balance of independent clusters, not the total number of nested records. With few clusters, ordinary cluster-robust tests may be unreliable; design-based methods, small-sample corrections, or a justified hierarchical model may be needed.</p>
</section>
<section id="robust-regression-changes-the-estimate" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Robust Regression Changes the Estimate</h1>
<p>Least squares minimizes a quadratic loss:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cboldsymbol%5Cbeta%7D_%7B%5Cmathrm%7BOLS%7D%7D%0A=%5Carg%5Cmin_%7B%5Cmathbf%20b%7D%5Csum_i%20r_i(%5Cmathbf%20b)%5E2,%0A%5Cqquad%0Ar_i(%5Cmathbf%20b)=Y_i-%5Cmathbf%20x_i%5E%5Cmathsf%7BT%7D%5Cmathbf%20b.%0A"></p>
<p>Because squared loss grows rapidly, one extreme response can dominate the fit. An M-estimator instead solves</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cboldsymbol%5Cbeta%7D_%7BM%7D%0A=%5Carg%5Cmin_%7B%5Cmathbf%20b%7D%0A%5Csum_i%20%5Crho%5C!%5Cleft(%5Cfrac%7Br_i(%5Cmathbf%20b)%7D%7Bs%7D%5Cright),%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?s"> is a robust residual scale. Huber’s loss is quadratic near zero and linear in the tails:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Crho_c(u)=%0A%5Cbegin%7Bcases%7D%0A%5Ctfrac12u%5E2,%20&amp;%20%7Cu%7C%5Cle%20c,%5C%5C%0Ac%7Cu%7C-%5Ctfrac12c%5E2,%20&amp;%20%7Cu%7C%3Ec.%0A%5Cend%7Bcases%7D%0A"></p>
<p>Its derivative, <img src="https://latex.codecogs.com/png.latex?%5Cpsi_c(u)=%5Cmin(c,%5Cmax(-c,u))">, bounds the contribution of a large standardized residual. The estimating equation is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Csum_i%0A%5Cpsi_c%5C!%5Cleft(%5Cfrac%7Br_i%7D%7Bs%7D%5Cright)%5Cmathbf%20x_i=%5Cmathbf%200.%0A"></p>
<p>Iteratively reweighted least squares expresses this as repeated weighted fits with</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Aw_i=%5Cfrac%7B%5Cpsi_c(u_i)%7D%7Bu_i%7D,%0A%5Cqquad%0Au_i=r_i/s,%0A"></p>
<p>using <img src="https://latex.codecogs.com/png.latex?w_i=1"> at <img src="https://latex.codecogs.com/png.latex?u_i=0">. Small residuals receive nearly full weight; large residuals receive less. The tuning constant trades Gaussian efficiency against tail resistance and should be reported.</p>
</section>
<section id="resistance-is-not-universal" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Resistance Is Not Universal</h1>
<p>Huber M-estimation limits the effect of large vertical residuals, but a point with extreme predictors can have high leverage and pull the fitted line toward itself, leaving a deceptively small residual. Robust regression therefore also needs design-space diagnostics. High-breakdown regression procedures jointly protect against more severe contamination, but can sacrifice efficiency, require tuning, and behave poorly when the uncontaminated design has weak support.</p>
<p>Downweighting is not evidence that an observation is erroneous. A discordant unit may reveal a real subgroup, a missing interaction, a batch effect, or a different data-generating regime. Report which units receive low weight, verify their provenance, and compare scientifically plausible models.</p>
</section>
<section id="a-small-example" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> A Small Example</h1>
<p>Suppose five specimens have</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AX=(0,1,2,3,4),%0A%5Cqquad%0AY=(1.0,2.1,2.9,4.2,12.0).%0A"></p>
<p>The last response is far above the trend of the first four. OLS gives <img src="https://latex.codecogs.com/png.latex?%5Chat%5Cbeta_0=-0.38"> and <img src="https://latex.codecogs.com/png.latex?%5Chat%5Cbeta_1=2.41">, so every fitted value is pulled by that unit. HC3 standard errors would acknowledge unstable OLS uncertainty but would leave those two coefficient estimates unchanged. Huber regression would downweight the large residual and estimate a line closer to the majority trend.</p>
<p>Neither response decides whether the last specimen is a recording error or a real biological subtype. The defensible analysis checks the record, examines its predictor leverage and batch, fits prespecified alternatives, and reports how the scientific contrast changes.</p>
</section>
<section id="choosing-a-response-to-model-tension" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Choosing a Response to Model Tension</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Observed problem</th>
<th>Suitable first response</th>
<th>Why a superficially similar response fails</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Mean is adequate; variance changes with fitted mean</td>
<td>HC2/HC3 covariance or explicit variance model</td>
<td>Robust regression needlessly changes the target fit</td>
</tr>
<tr class="even">
<td>Errors share patient, plate, family, time, or location</td>
<td>Cluster-, mixed-, time-, or spatially aware method</td>
<td>HC standard errors still assume independent units</td>
</tr>
<tr class="odd">
<td>A few large response residuals dominate OLS</td>
<td>Verify data; robust regression and deletion sensitivity</td>
<td>HC covariance does not reduce point-estimate influence</td>
</tr>
<tr class="even">
<td>Extreme predictor configurations dominate</td>
<td>Leverage diagnostics, design repair, high-leverage robust method</td>
<td>Residual-only M-estimation may not protect the fit</td>
</tr>
<tr class="odd">
<td>Conditional mean is curved or has missing interactions</td>
<td>Improve the mean model</td>
<td>Neither robust SEs nor robust loss repairs systematic bias</td>
</tr>
<tr class="even">
<td>Omitted confounding or selection</td>
<td>Redesign, justified adjustment, sensitivity analysis</td>
<td>No covariance estimator creates exchangeability</td>
</tr>
<tr class="odd">
<td>Counts, proportions, or survival outcomes have structural mean–variance relations</td>
<td>Use an appropriate outcome model and diagnostics</td>
<td>A linear model may predict impossible values and target the wrong scale</td>
</tr>
</tbody>
</table>
</section>
<section id="uncertainty-for-robust-regression" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Uncertainty for Robust Regression</h1>
<p>Robust-regression coefficients require their own sampling covariance calculation. A sandwich estimator can be built from the M-estimating equations, but it is not the same calculation as attaching HC standard errors to OLS. A bootstrap can be useful when it resamples independent experimental units and repeats every fitting and tuning step. Resampling individual cells or reads when inference concerns patients recreates pseudoreplication rather than uncertainty.</p>
<p>With small samples, heavy contamination, high leverage, or data-driven tuning, asymptotic normal intervals can be inaccurate. Simulation under scientifically plausible contamination, variance, and clustering patterns is a useful sensitivity check.</p>
</section>
<section id="bioinformatics-design-and-interpretation" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Bioinformatics Design and Interpretation</h1>
<p>Consider protein abundance measured in multiple technical runs for 40 patient specimens. Treatment is the predictor of interest, while age and batch are adjustment variables.</p>
<ul>
<li>If variability differs by batch but patients are independent, HC3 may improve uncertainty for the OLS treatment contrast.</li>
<li>If several observations come from each patient, uncertainty must recognize patient clustering; treating runs as independent makes either classical or HC standard errors too small.</li>
<li>If one patient has a large residual, robust regression measures whether the fitted treatment contrast is driven by that response. It does not justify silently removing the patient.</li>
<li>If treatment and batch barely overlap, neither method restores the missing comparison. The design—not the residual loss—is the limiting factor.</li>
</ul>
<p>The statistical conclusion concerns a treatment coefficient on the chosen abundance scale and under the specified design. Biological interpretation also depends on assay reliability, pathway context, effect magnitude, tissue and population transportability, and whether the association represents an intervention effect.</p>
</section>
<section id="reporting-checklist" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> Reporting Checklist</h1>
<p>Report enough detail to identify both the estimator and its uncertainty:</p>
<ol type="1">
<li>experimental unit, clustering level, and number of independent units or clusters;</li>
<li>mean model, coefficient estimand, and whether OLS or robust regression produced the point estimate;</li>
<li>HC variant or cluster correction, degrees of freedom, and reference distribution;</li>
<li>robust loss, scale estimator, tuning constant, and convergence information;</li>
<li>leverage, residual, and influence findings without automatic deletion;</li>
<li>sensitivity of effect estimates, intervals, and scientific conclusions to credible alternatives.</li>
</ol>
<p>Calling a result merely “robust” hides the most important information.</p>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/linear-model-assumptions-and-diagnostics.html">Linear-model assumptions and diagnostics</a> distinguishes mean, variance, dependence, rank, and distributional conditions.</li>
<li><a href="../../../knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html">Regression uncertainty and coefficient interpretation</a> defines coefficient covariance, contrasts, and prediction uncertainty.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/standard-errors.html">Standard errors</a> develops sandwich and cluster-aware uncertainty more generally.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/sensitivity-analysis-and-robustness.html">Sensitivity analysis and robustness</a> separates robust procedures from robustness of an entire scientific conclusion.</li>
<li><a href="../../../knowledge/statistics/asymptotic-thinking/when-asymptotic-approximations-fail.html">When asymptotic approximations fail</a> explains why a large nominal record count may provide little independent information.</li>
</ul>
<ol type="1">
<li>Robust standard errors change uncertainty, not OLS coefficients.</li>
<li>Robust regression changes the point estimate by limiting the influence of large residuals.</li>
<li>HC covariance requires independent units; clustered data require a dependence-aware covariance or model.</li>
<li>Neither method repairs a wrong mean, confounding, poor overlap, or a mistaken experimental unit.</li>
<li>Report the exact estimator, covariance variant, tuning choices, diagnostics, and sensitivity—not simply that the analysis was robust.</li>
</ol>
</section>
<section id="references" class="level1" data-number="12">
<h1 data-number="12"><span class="header-section-number">12</span> References</h1>
<ul>
<li>White, H. (1980). A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity. <em>Econometrica</em>, 48(4), 817–838. <a href="https://doi.org/10.2307/1912934" class="uri">https://doi.org/10.2307/1912934</a></li>
<li>MacKinnon, J. G., and White, H. (1985). Some heteroskedasticity-consistent covariance matrix estimators with improved finite sample properties. <em>Journal of Econometrics</em>, 29(3), 305–325. <a href="https://doi.org/10.1016/0304-4076(85)90158-7" class="uri">https://doi.org/10.1016/0304-4076(85)90158-7</a></li>
<li>Huber, P. J. (1964). Robust estimation of a location parameter. <em>The Annals of Mathematical Statistics</em>, 35(1), 73–101. <a href="https://doi.org/10.1214/aoms/1177703732" class="uri">https://doi.org/10.1214/aoms/1177703732</a></li>
<li>Hampel, F. R., Ronchetti, E. M., Rousseeuw, P. J., and Stahel, W. A. (1986). <em>Robust Statistics: The Approach Based on Influence Functions</em>. Wiley. <a href="https://doi.org/10.1002/9781118186435" class="uri">https://doi.org/10.1002/9781118186435</a></li>
<li>Zeileis, A. (2004). Econometric computing with HC and HAC covariance matrix estimators. <em>Journal of Statistical Software</em>, 11(10), 1–17. <a href="https://doi.org/10.18637/jss.v011.i10" class="uri">https://doi.org/10.18637/jss.v011.i10</a></li>
<li>Zeileis, A., Köll, S., and Graham, N. (2020). Various versatile variances: An object-oriented implementation of clustered covariances in R. <em>Journal of Statistical Software</em>, 95(1), 1–36. <a href="https://doi.org/10.18637/jss.v095.i01" class="uri">https://doi.org/10.18637/jss.v095.i01</a></li>
<li>R Core Team. <code>lm.influence</code>: regression diagnostics. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.influence.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.influence.html</a></li>
<li>Zeileis, A. <code>vcovHC</code>: heteroskedasticity-consistent covariance matrix estimation. <em>sandwich documentation</em>. <a href="https://sandwich.r-forge.r-project.org/reference/vcovHC.html" class="uri">https://sandwich.r-forge.r-project.org/reference/vcovHC.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Robust Statistics</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/robust-standard-errors-and-robust-regression.html</guid>
  <pubDate>Tue, 13 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Least Squares and the Geometry of Regression</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/least-squares-and-regression-geometry.html</link>
  <description><![CDATA[ 





<section id="the-optimization-problem" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> The optimization problem</h1>
<p>For <img src="https://latex.codecogs.com/png.latex?n"> experimental units, let <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20y%5Cin%5Cmathbb%20R%5En"> be the observed responses and let the <img src="https://latex.codecogs.com/png.latex?n%5Ctimes%20p"> design matrix <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X"> contain the predictors used by the model. The linear mean model is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbf%20y=%5Cmathbf%20X%5Cboldsymbol%5Cbeta+%5Cboldsymbol%5Cvarepsilon,%0A%5Cqquad%0A%5Coperatorname%7BE%7D(%5Cboldsymbol%5Cvarepsilon%5Cmid%5Cmathbf%20X)=%5Cmathbf%200.%0A"></p>
<p>Ordinary least squares (OLS) chooses the coefficient vector whose fitted values are closest to <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20y"> in squared Euclidean distance:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cboldsymbol%5Cbeta%7D%0A=%5Carg%5Cmin_%7B%5Cmathbf%20b%7D%5C%7C%5Cmathbf%20y-%5Cmathbf%20X%5Cmathbf%20b%5C%7C_2%5E2.%0A"></p>
<p>The model space is the column space <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%20C(%5Cmathbf%20X)">: every possible fitted vector <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X%5Cmathbf%20b"> lies in this subspace of <img src="https://latex.codecogs.com/png.latex?%5Cmathbb%20R%5En">. Least squares is therefore a projection problem, not just an algebraic recipe.</p>
<p>The rows of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X"> represent experimental units. In an RNA-expression study, those units might be independent patients; reads, cells from the same patient, or repeated technical measurements do not become independent rows merely because software can store them that way.</p>
</section>
<section id="normal-equations-and-orthogonal-projection" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Normal equations and orthogonal projection</h1>
<p>Write the residual vector as <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20e=%5Cmathbf%20y-%5Cmathbf%20X%5Cmathbf%20b">. Expanding the residual sum of squares and differentiating gives</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%5Cmathbf%20b%7D%0A(%5Cmathbf%20y-%5Cmathbf%20X%5Cmathbf%20b)%5E%5Cmathsf%20T%0A(%5Cmathbf%20y-%5Cmathbf%20X%5Cmathbf%20b)%0A=-2%5Cmathbf%20X%5E%5Cmathsf%20T(%5Cmathbf%20y-%5Cmathbf%20X%5Cmathbf%20b).%0A"></p>
<p>At a minimum,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X%5Chat%7B%5Cboldsymbol%5Cbeta%7D%0A=%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20y%7D,%0A%5Cqquad%0A%5Cboxed%7B%5Cmathbf%20X%5E%5Cmathsf%20T%5Chat%7B%5Cmathbf%20e%7D=%5Cmathbf%200%7D.%0A"></p>
<p>Thus the residual is orthogonal to every design column. If <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X"> has full column rank,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cboldsymbol%5Cbeta%7D%0A=(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20y.%0A"></p>
<p>The fitted vector is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cmathbf%20y%7D=%5Cmathbf%20H%5Cmathbf%20y,%0A%5Cqquad%0A%5Cmathbf%20H=%5Cmathbf%20X(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20X%5E%5Cmathsf%20T.%0A"></p>
<p>The hat matrix is symmetric and idempotent: <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20H%5E%5Cmathsf%20T=%5Cmathbf%20H"> and <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20H%5E2=%5Cmathbf%20H">. These are the defining algebraic properties of an orthogonal projector. The residual-maker <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20M=%5Cmathbf%20I-%5Cmathbf%20H"> is also symmetric and idempotent, with <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cmathbf%20e%7D=%5Cmathbf%20M%5Cmathbf%20y">.</p>
<p>Because the fitted and residual vectors are orthogonal,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5C%7C%5Cmathbf%20y%5C%7C_2%5E2%0A=%5C%7C%5Chat%7B%5Cmathbf%20y%7D%5C%7C_2%5E2+%5C%7C%5Chat%7B%5Cmathbf%20e%7D%5C%7C_2%5E2.%0A"></p>
<p>With an intercept, the same geometry applied after centering yields the familiar decomposition</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Csum_i(y_i-%5Cbar%20y)%5E2%0A=%5Csum_i(%5Chat%20y_i-%5Cbar%20y)%5E2+%5Csum_i(y_i-%5Chat%20y_i)%5E2.%0A"></p>
<p>This identity is exact in the fitted sample. It does not show that the mean function is correct, that the predictors are causal, or that the model will predict new observations well.</p>
</section>
<section id="what-full-rank-means" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> What full rank means</h1>
<p>Full column rank means that no design column is an exact linear combination of the others. It gives a unique coefficient vector. If rank is deficient, fitted values can still be unique while individual coefficients are not: several vectors <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20b"> produce the same point in <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%20C(%5Cmathbf%20X)">.</p>
<p>Common causes include an intercept plus indicators for every category, a batch indicator identical to treatment, or more fitted coefficients than independent units. Near-linear dependence does not destroy uniqueness, but it creates long, flat directions in the least-squares surface. Small changes in the data can then produce large coefficient changes.</p>
<p>The projection should not be computed by explicitly forming <img src="https://latex.codecogs.com/png.latex?(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D">. Forming the cross-product squares the condition number. QR factorization is the standard stable route for a full-rank problem; singular-value decomposition exposes rank and ill-conditioned directions directly.</p>
</section>
<section id="residualization-and-the-frischwaughlovell-result" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Residualization and the Frisch–Waugh–Lovell result</h1>
<p>Partition the design as <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X=%5B%5Cmathbf%20X_1%5C;%5Cmathbf%20x_2%5D">, and let</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbf%20M_1=%5Cmathbf%20I-%0A%5Cmathbf%20X_1(%5Cmathbf%20X_1%5E%5Cmathsf%20T%5Cmathbf%20X_1)%5E%7B-1%7D%5Cmathbf%20X_1%5E%5Cmathsf%20T.%0A"></p>
<p>The coefficient of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20x_2"> in the full regression is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%0A%5Chat%5Cbeta_2%0A=%5Cfrac%7B%5Cmathbf%20x_2%5E%5Cmathsf%20T%5Cmathbf%20M_1%5Cmathbf%20y%7D%0A%7B%5Cmathbf%20x_2%5E%5Cmathsf%20T%5Cmathbf%20M_1%5Cmathbf%20x_2%7D%0A%7D.%0A"></p>
<p>To see the result, minimize over <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%5Cbeta_1"> for any fixed <img src="https://latex.codecogs.com/png.latex?b_2">. The remaining residual is <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20M_1(%5Cmathbf%20y-%5Cmathbf%20x_2b_2)">; differentiating its squared length with respect to <img src="https://latex.codecogs.com/png.latex?b_2"> gives the displayed expression.</p>
<p>Geometrically, first remove from both <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20y"> and <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20x_2"> the components explained linearly by <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X_1">. The slope between those two residual vectors is the full-model coefficient. A coefficient therefore uses only predictor variation orthogonal to the other design columns. If almost no such variation remains, the denominator is small and the estimate is unstable.</p>
</section>
<section id="leverage-and-influence-in-the-projection" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Leverage and influence in the projection</h1>
<p>The diagonal element <img src="https://latex.codecogs.com/png.latex?h_%7Bii%7D"> of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20H"> is the leverage of unit <img src="https://latex.codecogs.com/png.latex?i">:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%20y_i=%5Csum_%7Bj=1%7D%5En%20h_%7Bij%7Dy_j,%0A%5Cqquad%0A0%5Cle%20h_%7Bii%7D%5Cle%201,%0A%5Cqquad%0A%5Csum_i%20h_%7Bii%7D=%5Coperatorname%7Btr%7D(%5Cmathbf%20H)=p.%0A"></p>
<p>High leverage means that a row of the design is unusual in predictor space. It does not by itself imply a large residual or an error. Influence combines leverage with outcome disagreement: a high-leverage unit whose response follows the fitted pattern may change the coefficients little, whereas a high-leverage unit with a large residual can dominate them.</p>
<p>Under homoskedastic errors,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BVar%7D(%5Chat%20e_i%5Cmid%5Cmathbf%20X)=%5Csigma%5E2(1-h_%7Bii%7D),%0A"></p>
<p>so raw residuals have different variances even when the original errors do not. Studentized residuals account for this geometric fact. Cook’s distance and DFBETAs then quantify how deleting a unit changes the fitted vector or a particular coefficient. Deletion diagnostics are sensitivity analyses, not automatic rules for discarding inconvenient observations.</p>
</section>
<section id="weighted-geometry" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Weighted geometry</h1>
<p>If the conditional error covariance is known up to scale as <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BVar%7D(%5Cboldsymbol%5Cvarepsilon%5Cmid%5Cmathbf%20X)=%5Csigma%5E2%5Cmathbf%20V">, generalized least squares minimizes</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A(%5Cmathbf%20y-%5Cmathbf%20X%5Cmathbf%20b)%5E%5Cmathsf%20T%0A%5Cmathbf%20V%5E%7B-1%7D(%5Cmathbf%20y-%5Cmathbf%20X%5Cmathbf%20b).%0A"></p>
<p>This is ordinary projection after whitening by a matrix <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20L"> satisfying <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20L%5E%5Cmathsf%20T%5Cmathbf%20L=%5Cmathbf%20V%5E%7B-1%7D">. Weighted least squares is the diagonal special case. The choice of weights changes the metric and therefore the projection; weights should encode a justified variance or sampling model, not merely shrink observations that fit poorly.</p>
</section>
<section id="a-small-worked-geometry" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> A small worked geometry</h1>
<p>Fit an intercept and a centered predictor <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20x=(-1,0,1)%5E%5Cmathsf%20T"> to <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20y=(1,2,6)%5E%5Cmathsf%20T">. Orthogonality of the intercept and centered predictor gives</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%5Cbeta_0=%5Cbar%20y=3,%0A%5Cqquad%0A%5Chat%5Cbeta_1=%5Cfrac%7B%5Cmathbf%20x%5E%5Cmathsf%20T%5Cmathbf%20y%7D%0A%7B%5Cmathbf%20x%5E%5Cmathsf%20T%5Cmathbf%20x%7D=%5Cfrac%7B5%7D%7B2%7D.%0A"></p>
<p>Hence <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cmathbf%20y%7D=(0.5,3,5.5)%5E%5Cmathsf%20T"> and <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cmathbf%20e%7D=(0.5,-1,0.5)%5E%5Cmathsf%20T">. Direct calculation confirms <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%201%5E%5Cmathsf%20T%5Chat%7B%5Cmathbf%20e%7D=0"> and <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20x%5E%5Cmathsf%20T%5Chat%7B%5Cmathbf%20e%7D=0">. The normal equations are visible as right angles.</p>
</section>
<section id="bioinformatics-design-example" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Bioinformatics design example</h1>
<p>Suppose 48 independent donor samples are assayed for a pathway score. The design contains an intercept, treatment, age, sex, and sequencing batch. Each column is a direction in donor-level observation space. The adjusted treatment coefficient uses only the treatment direction remaining after its projection on the other columns.</p>
<p>If all treated donors were processed in batch B and all controls in batch A, treatment and batch point in the same design direction. Their separate effects are not identified. More reads or repeated libraries cannot create the missing donor-level contrast. If treatment and batch are merely highly associated, the contrast exists but is short, so uncertainty is large and estimates are sensitive to a few donors.</p>
<p>The statistical statement is about an adjusted mean contrast on the pathway-score scale under the model. Biological interpretation additionally depends on donor selection, tissue composition, assay normalization, effect magnitude, and external replication.</p>
</section>
<section id="assumptions-and-sensitivity-checks" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Assumptions and sensitivity checks</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Issue</th>
<th>Geometric symptom</th>
<th>Consequence</th>
<th>Check or response</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Rank deficiency</td>
<td>Redundant design directions</td>
<td>Coefficients not unique</td>
<td>Inspect design rank and estimable contrasts; redesign or reparameterize</td>
</tr>
<tr class="even">
<td>Near collinearity</td>
<td>Very small singular values</td>
<td>Large coefficient variance</td>
<td>Inspect singular values and partial predictor spread; report sensitivity</td>
</tr>
<tr class="odd">
<td>Nonlinear mean</td>
<td>Residual pattern outside the chosen model space</td>
<td>Projection is a misleading summary</td>
<td>Residual and partial-residual plots; add justified transformations or splines</td>
</tr>
<tr class="even">
<td>Unequal variance</td>
<td>Error ellipsoid not spherical</td>
<td>Classical standard errors are wrong or inefficient</td>
<td>Plot residual spread; use justified variance modeling or robust covariance</td>
</tr>
<tr class="odd">
<td>Dependence</td>
<td>Off-diagonal error covariance</td>
<td>Ordinary uncertainty is too small or otherwise wrong</td>
<td>Respect sampling hierarchy; use cluster, mixed, or generalized least-squares methods</td>
</tr>
<tr class="even">
<td>Influential units</td>
<td>High leverage combined with large residual</td>
<td>Fit depends on few units</td>
<td>Verify records and report transparent deletion or robust-fit sensitivity</td>
</tr>
</tbody>
</table>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> Connections and take-home messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/simple-linear-regression.html">Simple linear regression</a> introduces the one-predictor model.</li>
<li><a href="../../../knowledge/statistics/regression-models/multiple-linear-regression.html">Multiple linear regression</a> develops adjusted coefficients and omitted-variable reasoning.</li>
<li><a href="../../../knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html">Regression uncertainty and coefficient interpretation</a> connects this geometry to standard errors, contrasts, and prediction.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/standard-errors.html">Standard errors</a> explains repeated-sampling uncertainty more generally.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/sensitivity-analysis-and-robustness.html">Sensitivity analysis and robustness</a> provides a broader framework for assumption checks.</li>
</ul>
<ol type="1">
<li>OLS projects the response onto the column space of the design matrix.</li>
<li>The normal equations say that the residual is orthogonal to every included design direction.</li>
<li>Full rank identifies coefficients; small singular values reveal unstable directions even when a unique solution exists.</li>
<li>Partial-regression geometry shows exactly which predictor variation estimates an adjusted coefficient.</li>
<li>The geometry is a sample identity. Scientific interpretation and valid uncertainty still require assumptions about design, errors, and experimental units.</li>
</ol>
</section>
<section id="references" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> References</h1>
<ul>
<li>Frisch, R., and Waugh, F. V. (1933). Partial time regressions as compared with individual trends. <em>Econometrica</em>, 1(4), 387–401. <a href="https://doi.org/10.2307/1907330" class="uri">https://doi.org/10.2307/1907330</a></li>
<li>Lovell, M. C. (1963). Seasonal adjustment of economic time series and multiple regression analysis. <em>Journal of the American Statistical Association</em>, 58(304), 993–1010. <a href="https://doi.org/10.1080/01621459.1963.10480682" class="uri">https://doi.org/10.1080/01621459.1963.10480682</a></li>
<li>Golub, G. H., and Van Loan, C. F. (2013). <em>Matrix Computations</em> (4th ed.). Johns Hopkins University Press.</li>
<li>Weisberg, S. (2014). <em>Applied Linear Regression</em> (4th ed.). Wiley.</li>
<li>R Core Team. <code>lm</code>: Fitting linear models. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Linear Models</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/least-squares-and-regression-geometry.html</guid>
  <pubDate>Sun, 11 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Regression Uncertainty and Coefficient Interpretation</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html</link>
  <description><![CDATA[ 





<section id="start-with-the-target" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Start with the target</h1>
<p>A regression output mixes several distinct objects unless the question is stated first:</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th>Object</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><strong>Target population</strong></td>
<td>Units to which the conclusion is meant to apply</td>
</tr>
<tr class="even">
<td><strong>Estimand</strong></td>
<td>Population quantity defined by the scientific question and model</td>
</tr>
<tr class="odd">
<td><strong>Estimator</strong></td>
<td>Random rule, such as OLS, used before observing the sample</td>
</tr>
<tr class="even">
<td><strong>Estimate</strong></td>
<td>Numerical value produced for the observed sample</td>
</tr>
<tr class="odd">
<td><strong>Standard error</strong></td>
<td>Estimated repeated-sampling standard deviation of the estimator</td>
</tr>
</tbody>
</table>
<p>For a linear conditional-mean model,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(Y_i%5Cmid%5Cmathbf%20x_i)%0A=%5Cmathbf%20x_i%5E%5Cmathsf%20T%5Cboldsymbol%5Cbeta,%0A"></p>
<p><img src="https://latex.codecogs.com/png.latex?%5Cbeta_j"> is the conditional mean difference per unit change in predictor <img src="https://latex.codecogs.com/png.latex?j">, holding the other modeled predictors fixed. For an indicator, it is the adjusted conditional mean contrast between its coded groups. The phrase “holding fixed” describes a model comparison; it does not by itself describe a feasible intervention or a causal effect.</p>
<p>If the conditional mean is not exactly linear, OLS can instead target the best linear projection for a specified predictor distribution:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboldsymbol%5Cbeta%5E*%0A=%5Carg%5Cmin_%7B%5Cmathbf%20b%7D%0A%5Coperatorname%7BE%7D%5C%7B(Y-%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20b)%5E2%5C%7D.%0A"></p>
<p>That projection can be useful, but its coefficients may change when the population distribution of predictors changes. The estimand is therefore not fully described by the coefficient name alone.</p>
</section>
<section id="sampling-uncertainty-under-the-classical-model" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Sampling uncertainty under the classical model</h1>
<p>For</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbf%20y=%5Cmathbf%20X%5Cboldsymbol%5Cbeta+%5Cboldsymbol%5Cvarepsilon,%0A%5Cqquad%0A%5Coperatorname%7BE%7D(%5Cboldsymbol%5Cvarepsilon%5Cmid%5Cmathbf%20X)=%5Cmathbf%200,%0A"></p>
<p>the OLS estimator is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%7B%5Cboldsymbol%5Cbeta%7D%0A=(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20y.%0A"></p>
<p>If, conditional on the observed design, <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BVar%7D(%5Cboldsymbol%5Cvarepsilon%5Cmid%5Cmathbf%20X)=%5Csigma%5E2%5Cmathbf%20I">, then</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BVar%7D(%5Chat%7B%5Cboldsymbol%5Cbeta%7D%5Cmid%5Cmathbf%20X)%0A=%5Csigma%5E2(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D.%0A"></p>
<p>Estimate <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E2"> by</p>
<p><img src="https://latex.codecogs.com/png.latex?%0As%5E2=%5Cfrac%7B%5C%7C%5Cmathbf%20y-%5Cmathbf%20X%5Chat%7B%5Cboldsymbol%5Cbeta%7D%5C%7C_2%5E2%7D%7Bn-p%7D,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?p"> is the rank of the design, including the intercept when present. The standard error for coefficient <img src="https://latex.codecogs.com/png.latex?j"> is the square root of diagonal element <img src="https://latex.codecogs.com/png.latex?j"> of <img src="https://latex.codecogs.com/png.latex?s%5E2(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D">.</p>
<p>With independent normal errors, the interval</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%5Cbeta_j%5C%20%5Cpm%5C%20t_%7Bn-p,1-%5Calpha/2%7D%0A%5Coperatorname%7BSE%7D(%5Chat%5Cbeta_j)%0A"></p>
<p>has exact conditional coverage <img src="https://latex.codecogs.com/png.latex?1-%5Calpha"> under the model. Without normality, similar intervals are generally asymptotic and need regularity conditions. A 95% confidence interval is a procedure with 95% long-run coverage under those conditions; it is not a 95% probability statement about a fixed frequentist coefficient after the interval is observed.</p>
</section>
<section id="contrasts-are-often-the-real-estimands" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Contrasts are often the real estimands</h1>
<p>Scientific questions commonly concern a linear contrast <img src="https://latex.codecogs.com/png.latex?%5Ctheta=%5Cmathbf%20c%5E%5Cmathsf%20T%5Cboldsymbol%5Cbeta">, not one raw coefficient. Its estimate and classical variance are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%5Ctheta=%5Cmathbf%20c%5E%5Cmathsf%20T%5Chat%7B%5Cboldsymbol%5Cbeta%7D,%0A%5Cqquad%0A%5Cwidehat%7B%5Coperatorname%7BVar%7D%7D(%5Chat%5Ctheta)%0A=s%5E2%5Cmathbf%20c%5E%5Cmathsf%20T%0A(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20c.%0A"></p>
<p>Examples include a difference between two factor levels, an average treatment contrast across prespecified covariate values, or the slope at a chosen modifier value in an interaction model. Estimability requires that the contrast be determined by the design; software cannot recover a treatment-versus-batch contrast when treatment and batch are perfectly confounded.</p>
<p>Simultaneously examining many coefficients or choosing a contrast after seeing the estimates changes the relevant error rate. Prespecified contrasts, simultaneous intervals, multiplicity adjustment, or honest exploratory labeling should match the analysis goal.</p>
</section>
<section id="coding-scaling-and-interactions" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Coding, scaling, and interactions</h1>
<p>Coefficient values depend on parameterization even when fitted values do not.</p>
<ul>
<li>Replacing age in years by age in decades multiplies its coefficient and standard error by 10 but leaves its <img src="https://latex.codecogs.com/png.latex?t"> statistic and fitted values unchanged.</li>
<li>Changing the reference level of a factor changes individual coefficients, not the modeled group means or appropriate contrasts.</li>
<li>Centering a predictor changes the intercept and, with interactions, changes which conditional slope is labeled a “main effect.”</li>
</ul>
<p>For</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(Y%5Cmid%20X,Z)%0A=%5Cbeta_0+%5Cbeta_1X+%5Cbeta_2Z+%5Cbeta_3XZ,%0A"></p>
<p>the slope of <img src="https://latex.codecogs.com/png.latex?X"> at <img src="https://latex.codecogs.com/png.latex?Z=z"> is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20x%7D%5Coperatorname%7BE%7D(Y%5Cmid%20X=x,Z=z)%0A=%5Cbeta_1+%5Cbeta_3z.%0A"></p>
<p>Thus <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> is the slope only at <img src="https://latex.codecogs.com/png.latex?Z=0">. Interpreting it as an overall effect is wrong unless zero is the intended reference value and a constant slope is the question. Report fitted contrasts across scientifically meaningful values when an interaction is present.</p>
</section>
<section id="robust-covariance-what-it-fixes-and-what-it-does-not" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Robust covariance: what it fixes and what it does not</h1>
<p>Under independent but heteroskedastic errors with covariance <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%5COmega">, the conditional covariance is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BVar%7D(%5Chat%7B%5Cboldsymbol%5Cbeta%7D%5Cmid%5Cmathbf%20X)%0A=(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D%0A%5Cmathbf%20X%5E%5Cmathsf%20T%5Cboldsymbol%5COmega%5Cmathbf%20X%0A(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D.%0A"></p>
<p>Heteroskedasticity-consistent estimators replace the unknown error variances by functions of squared residuals. HC2 and HC3 adjust for leverage and often behave better than the original HC0 estimator in modest samples. These methods change the estimated covariance, not the OLS coefficients.</p>
<p>Robust standard errors do <strong>not</strong> repair a wrong mean function, omitted-variable bias, dependence between units, measurement error, selection bias, or poor overlap. Cluster-robust covariance needs enough independent clusters and a scientifically correct clustering level. When there are few clusters, ordinary large-sample reference distributions can be unreliable.</p>
</section>
<section id="uncertainty-for-a-mean-and-for-a-new-observation" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Uncertainty for a mean and for a new observation</h1>
<p>At a predictor vector <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20x_0">, the fitted conditional mean is <img src="https://latex.codecogs.com/png.latex?%5Chat%5Cmu_0=%5Cmathbf%20x_0%5E%5Cmathsf%20T%5Chat%7B%5Cboldsymbol%5Cbeta%7D">. Under the classical model,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%7B%5Coperatorname%7BVar%7D%7D(%5Chat%5Cmu_0)%0A=s%5E2%5Cmathbf%20x_0%5E%5Cmathsf%20T%0A(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20x_0.%0A"></p>
<p>A confidence interval for the mean response uses this variance. A prediction interval for one future response must also include irreducible outcome variation:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%7B%5Coperatorname%7BVar%7D%7D(Y_%7B%5Cmathrm%7Bnew%7D%7D-%5Chat%5Cmu_0)%0A=s%5E2%5Cleft%5B1+%0A%5Cmathbf%20x_0%5E%5Cmathsf%20T(%5Cmathbf%20X%5E%5Cmathsf%20T%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20x_0%5Cright%5D.%0A"></p>
<p>The prediction interval is therefore wider. Both formulas are model-based and refer to predictor values supported by the design. Extrapolation can produce numerical intervals while requiring untestable assumptions far beyond the data. Prediction for a new donor also differs from predicting another technical measurement from an already observed donor because the sources of variation are different.</p>
</section>
<section id="association-prediction-and-causation" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Association, prediction, and causation</h1>
<p>The same fitted coefficient can serve different goals:</p>
<ul>
<li><strong>Description:</strong> summarize conditional associations in the observed or target population.</li>
<li><strong>Prediction:</strong> combine predictors to forecast outcomes for new units.</li>
<li><strong>Causal estimation:</strong> estimate a contrast under hypothetical interventions.</li>
</ul>
<p>Causal interpretation requires design and identification assumptions beyond the regression equation: consistency, exchangeability after justified adjustment, positivity, and a well-defined intervention are typical requirements. Adding every available covariate is not a substitute. Adjustment for a confounder can reduce bias; adjustment for a mediator changes the target; adjustment for a collider can create bias.</p>
<p>For prediction, unbiased causal interpretation may be irrelevant, but out-of-sample validation, calibration, and transport to the deployment population become central. For description, the target population and scale must still be specified.</p>
</section>
<section id="worked-bioinformatics-interpretation" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Worked bioinformatics interpretation</h1>
<p>Suppose 80 independent patient biopsies are assigned to treatment or control and processed in four balanced sequencing batches. For log-expression <img src="https://latex.codecogs.com/png.latex?Y_i">, fit</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_i=%5Cbeta_0+%5Cbeta_1%5Coperatorname%7BTreatment%7D_i%0A+%5Cbeta_2%5Coperatorname%7BAge%7D_i%0A+%5Cbeta_3%5Coperatorname%7BBatch2%7D_i%0A+%5Cbeta_4%5Coperatorname%7BBatch3%7D_i%0A+%5Cbeta_5%5Coperatorname%7BBatch4%7D_i+%5Cvarepsilon_i.%0A"></p>
<p>If <img src="https://latex.codecogs.com/png.latex?%5Chat%5Cbeta_1=0.40"> with a 95% confidence interval <img src="https://latex.codecogs.com/png.latex?(0.12,0.68)">, the statistical interpretation is an estimated adjusted mean difference of 0.40 on the chosen log-expression scale, with an interval produced by a procedure whose coverage depends on the model and design assumptions. On a natural-log scale, <img src="https://latex.codecogs.com/png.latex?%5Cexp(0.40)%5Capprox1.49"> is a ratio of geometric means under the log-linear interpretation; it is not automatically a 49% change for every patient.</p>
<p>The experimental units are the 80 patients. Technical libraries or millions of reads improve measurement but do not increase the treatment replication to more than 80. Statistical evidence does not establish biological importance: pathway context, absolute expression, tissue heterogeneity, a prespecified meaningful effect, and replication in new patients remain relevant.</p>
</section>
<section id="diagnostics-and-sensitivity" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Diagnostics and sensitivity</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Threat</th>
<th>What happens to interpretation or uncertainty</th>
<th>Assessment</th>
<th>Response</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Wrong mean structure</td>
<td>Coefficient averages an unmodeled pattern</td>
<td>Residual and partial-residual plots; subject knowledge</td>
<td>Add prespecified nonlinearities or interactions; compare target contrasts</td>
</tr>
<tr class="even">
<td>Heteroskedasticity</td>
<td>Classical covariance is wrong</td>
<td>Residual spread against fits and groups</td>
<td>HC2/HC3 covariance or a justified variance model</td>
</tr>
<tr class="odd">
<td>Correlated units</td>
<td>Effective information is overstated</td>
<td>Inspect sampling hierarchy and time/order</td>
<td>Cluster-aware, mixed, or generalized least-squares analysis</td>
</tr>
<tr class="even">
<td>Weak overlap or collinearity</td>
<td>Conditional comparison depends on little data</td>
<td>Predictor distributions, leverage, singular values</td>
<td>Restrict the target, redesign, or report instability</td>
</tr>
<tr class="odd">
<td>Influential observations</td>
<td>Estimate and interval depend on few units</td>
<td>Cook’s distance, DFBETAs, leave-one-unit-out checks</td>
<td>Verify data and report sensitivity; do not delete mechanically</td>
</tr>
<tr class="even">
<td>Model or contrast selected after inspection</td>
<td>Ordinary interval ignores selection</td>
<td>Audit the analysis path</td>
<td>Separate exploration and confirmation; validate; use simultaneous or selective methods when appropriate</td>
</tr>
<tr class="odd">
<td>Measurement error</td>
<td>Coefficients may be attenuated or distorted</td>
<td>Validation samples and replicate assays</td>
<td>Calibration or an explicit measurement-error model</td>
</tr>
</tbody>
</table>
<p>Uncertainty statements should be paired with effect estimates on meaningful scales, the number of independent units, the fitting and covariance method, and the exact contrast. A p-value alone leaves the target and magnitude unclear.</p>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> Connections and take-home messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/least-squares-and-regression-geometry.html">Least squares and the geometry of regression</a> explains projection, partial regression, and leverage.</li>
<li><a href="../../../knowledge/statistics/regression-models/multiple-linear-regression.html">Multiple linear regression</a> introduces adjusted coefficients and omitted-variable bias.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/confidence-intervals.html">Confidence intervals</a> and <a href="../../../knowledge/statistics/statistical-inference/standard-errors.html">standard errors</a> develop the general inferential concepts.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/effect-sizes.html">Effect sizes</a> separates magnitude from evidence strength.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-versus-practical-significance.html">Statistical versus practical significance</a> connects intervals to scientifically meaningful thresholds.</li>
</ul>
<ol type="1">
<li>Define the target population and estimand before interpreting a coefficient.</li>
<li>A coefficient is a conditional comparison determined by coding, scale, other predictors, and any interactions.</li>
<li>Standard errors quantify estimator variability under assumptions; they do not measure confounding, external validity, or biological importance.</li>
<li>Confidence intervals for mean responses and prediction intervals for new observations answer different questions.</li>
<li>Robust covariance addresses some variance misspecification, not a flawed data-generating model or nonindependent experimental units.</li>
</ol>
</section>
<section id="references" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> References</h1>
<ul>
<li>White, H. (1980). A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity. <em>Econometrica</em>, 48(4), 817–838. <a href="https://doi.org/10.2307/1912934" class="uri">https://doi.org/10.2307/1912934</a></li>
<li>MacKinnon, J. G., and White, H. (1985). Some heteroskedasticity-consistent covariance matrix estimators with improved finite sample properties. <em>Journal of Econometrics</em>, 29(3), 305–325. <a href="https://doi.org/10.1016/0304-4076(85)90158-7" class="uri">https://doi.org/10.1016/0304-4076(85)90158-7</a></li>
<li>Freedman, D. A. (2006). On the so-called “Huber sandwich estimator” and “robust standard errors.” <em>The American Statistician</em>, 60(4), 299–302. <a href="https://doi.org/10.1198/000313006X152207" class="uri">https://doi.org/10.1198/000313006X152207</a></li>
<li>Gelman, A., Hill, J., and Vehtari, A. (2020). <em>Regression and Other Stories</em>. Cambridge University Press. <a href="https://doi.org/10.1017/9781139161879" class="uri">https://doi.org/10.1017/9781139161879</a></li>
<li>Weisberg, S. (2014). <em>Applied Linear Regression</em> (4th ed.). Wiley.</li>
<li>R Core Team. <code>predict.lm</code>: Predict method for linear model fits. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/predict.lm.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/predict.lm.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Statistical Inference</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/regression-uncertainty-and-coefficient-interpretation.html</guid>
  <pubDate>Sun, 11 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Multiple Linear Regression</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/multiple-linear-regression.html</link>
  <description><![CDATA[ 





<section id="from-one-predictor-to-many" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> From One Predictor to Many</h1>
<p>For independent units <img src="https://latex.codecogs.com/png.latex?i=1,%5Cldots,n">, multiple linear regression models the conditional mean of a continuous response using <img src="https://latex.codecogs.com/png.latex?p"> predictors:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_i=%5Cbeta_0+%5Cbeta_1X_%7Bi1%7D+%5Ccdots+%5Cbeta_pX_%7Bip%7D+%5Cvarepsilon_i,%0A%5Cqquad%0A%5Coperatorname%7BE%7D(%5Cvarepsilon_i%5Cmid%20X_i)=0.%0A"></p>
<p>The model is <strong>linear in the unknown coefficients</strong>. Predictors themselves may be transformed, represented by indicators, or combined through prespecified interactions while the model remains linear in <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%5Cbeta">.</p>
<p>In matrix form,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbf%20Y=%5Cmathbf%20X%5Cboldsymbol%5Cbeta+%5Cboldsymbol%5Cvarepsilon,%0A"></p>
<p>where the first column of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X"> is usually all ones. The target <img src="https://latex.codecogs.com/png.latex?%5Cboldsymbol%5Cbeta"> is a population parameter under a specified model; <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cboldsymbol%5Cbeta%7D"> is an estimator before observing data and a numerical estimate afterward.</p>
</section>
<section id="what-a-coefficient-means" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> What a Coefficient Means</h1>
<p>Holding the other modeled predictors fixed,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbeta_j=%0A%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20x_j%7D%0A%5Coperatorname%7BE%7D(Y%5Cmid%20X_1=x_1,%5Cldots,X_p=x_p)%0A"></p>
<p>when the mean is linear and <img src="https://latex.codecogs.com/png.latex?X_j"> is continuous. Thus <img src="https://latex.codecogs.com/png.latex?%5Cbeta_j"> is the difference in conditional mean per one-unit change in <img src="https://latex.codecogs.com/png.latex?X_j">, at common values of the other predictors. For a binary indicator, it is the adjusted mean contrast between the two encoded groups.</p>
<p>“Holding fixed” is a mathematical comparison, not necessarily a feasible intervention. If two covariates cannot vary independently in the target population, the coefficient may depend heavily on extrapolation. If a predictor is a confounder, adjustment may reduce bias; if it is a mediator or collider, adjustment may instead change or bias the target. Predictor selection must follow the scientific question and data-generating process, not an automated p-value search.</p>
<p>Without interaction terms, the model asserts that the slope for <img src="https://latex.codecogs.com/png.latex?X_j"> is the same at every modeled value of the other predictors. With an interaction <img src="https://latex.codecogs.com/png.latex?%5Cbeta_%7B12%7DX_1X_2">,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20x_1%7D%5Coperatorname%7BE%7D(Y%5Cmid%20X)%0A=%5Cbeta_1+%5Cbeta_%7B12%7Dx_2,%0A"></p>
<p>so the main-effect coefficient <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> is the slope when <img src="https://latex.codecogs.com/png.latex?X_2=0">. Centering can make that reference value scientifically meaningful without changing fitted values.</p>
</section>
<section id="least-squares-and-projection" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Least Squares and Projection</h1>
<p>OLS minimizes</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BRSS%7D(%5Cmathbf%20b)%0A=(%5Cmathbf%20Y-%5Cmathbf%20X%5Cmathbf%20b)%5E%5Cmathsf%7BT%7D%0A(%5Cmathbf%20Y-%5Cmathbf%20X%5Cmathbf%20b).%0A"></p>
<p>Differentiation gives the normal equations</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X%5Chat%7B%5Cboldsymbol%5Cbeta%7D%0A=%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20Y.%0A"></p>
<p>If <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X"> has full column rank,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%0A%5Chat%7B%5Cboldsymbol%5Cbeta%7D%0A=(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20Y%0A%7D.%0A"></p>
<p>Geometrically, the fitted vector <img src="https://latex.codecogs.com/png.latex?%5Chat%7B%5Cmathbf%20Y%7D=%5Cmathbf%20H%5Cmathbf%20Y"> is the orthogonal projection of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20Y"> onto the column space of <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X">, where</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmathbf%20H=%5Cmathbf%20X(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D%5Cmathbf%20X%5E%5Cmathsf%7BT%7D.%0A"></p>
<p>The residual vector is orthogonal to every included design column: <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20e=%5Cmathbf%200">. These sample identities do not prove that omitted causes are unrelated to included predictors.</p>
<p>The Frisch–Waugh–Lovell result gives an especially useful interpretation. Regress <img src="https://latex.codecogs.com/png.latex?X_j"> on the other predictors and retain its residuals; regress <img src="https://latex.codecogs.com/png.latex?Y"> on those same predictors and retain its residuals. The slope between the two sets of residuals equals <img src="https://latex.codecogs.com/png.latex?%5Chat%5Cbeta_j">. A coefficient therefore uses only the variation in <img src="https://latex.codecogs.com/png.latex?X_j"> that is not linearly explained by the other design columns.</p>
</section>
<section id="identification-and-sampling-uncertainty" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Identification and Sampling Uncertainty</h1>
<p>Full column rank is an identification condition. Exact linear dependence—for example, an intercept plus indicators for every category—means that multiple coefficient vectors produce the same fitted values. Near dependence makes coefficients estimable but unstable.</p>
<p>Conditional on <img src="https://latex.codecogs.com/png.latex?%5Cmathbf%20X">, if</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(%5Cboldsymbol%5Cvarepsilon%5Cmid%5Cmathbf%20X)=%5Cmathbf%200,%0A%5Cqquad%0A%5Coperatorname%7BVar%7D(%5Cboldsymbol%5Cvarepsilon%5Cmid%5Cmathbf%20X)=%5Csigma%5E2%5Cmathbf%20I,%0A"></p>
<p>then</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(%5Chat%7B%5Cboldsymbol%5Cbeta%7D%5Cmid%5Cmathbf%20X)%0A=%5Cboldsymbol%5Cbeta,%0A%5Cqquad%0A%5Coperatorname%7BVar%7D(%5Chat%7B%5Cboldsymbol%5Cbeta%7D%5Cmid%5Cmathbf%20X)%0A=%5Csigma%5E2(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D.%0A"></p>
<p>Estimate <img src="https://latex.codecogs.com/png.latex?%5Csigma%5E2"> by</p>
<p><img src="https://latex.codecogs.com/png.latex?%0As%5E2=%5Cfrac%7B%5Coperatorname%7BRSS%7D%7D%7Bn-p-1%7D.%0A"></p>
<p>The standard error of coefficient <img src="https://latex.codecogs.com/png.latex?j"> is the square root of the corresponding diagonal element of <img src="https://latex.codecogs.com/png.latex?s%5E2(%5Cmathbf%20X%5E%5Cmathsf%7BT%7D%5Cmathbf%20X)%5E%7B-1%7D">. Conditional normal errors give exact small-sample <img src="https://latex.codecogs.com/png.latex?t"> and <img src="https://latex.codecogs.com/png.latex?F"> reference distributions. Heteroskedasticity-consistent standard errors relax constant variance but do not repair a wrong mean function, dependence, confounding, or poor overlap.</p>
</section>
<section id="omitted-variables-and-changing-coefficients" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Omitted Variables and Changing Coefficients</h1>
<p>Suppose the true mean includes <img src="https://latex.codecogs.com/png.latex?Z">,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY=%5Cbeta_0+%5Cbeta_1X+%5Cgamma%20Z+%5Cvarepsilon,%0A"></p>
<p>but <img src="https://latex.codecogs.com/png.latex?Z"> is omitted. In a population linear projection, the short-regression slope is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ctilde%5Cbeta_1%0A=%5Cbeta_1+%5Cgamma%5Cfrac%7B%5Coperatorname%7BCov%7D(X,Z)%7D%7B%5Coperatorname%7BVar%7D(X)%7D.%0A"></p>
<p>Omitted-variable bias therefore needs both an association between <img src="https://latex.codecogs.com/png.latex?Z"> and the outcome conditional on <img src="https://latex.codecogs.com/png.latex?X"> and an association between <img src="https://latex.codecogs.com/png.latex?Z"> and <img src="https://latex.codecogs.com/png.latex?X">. Adding a variable can legitimately change a coefficient because it changes the conditional comparison, not merely because the original model was “incorrect.”</p>
<p>In causal work, the right adjustment set is determined by the causal structure. In prediction, a variable may be useful without having a causal interpretation. In descriptive work, both adjusted and unadjusted associations may answer useful but different questions.</p>
</section>
<section id="worked-bioinformatics-design" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Worked Bioinformatics Design</h1>
<p>Consider an RNA-expression summary <img src="https://latex.codecogs.com/png.latex?Y_i"> for each of 60 independent patient specimens. A prespecified model is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_i=%5Cbeta_0+%5Cbeta_1%5Coperatorname%7BTreatment%7D_i%0A+%5Cbeta_2%5Coperatorname%7BAge%7D_i%0A+%5Cbeta_3%5Coperatorname%7BBatchB%7D_i+%5Cvarepsilon_i.%0A"></p>
<ul>
<li><img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> compares adjusted mean expression between treatment groups at the same age and batch under the model.</li>
<li><img src="https://latex.codecogs.com/png.latex?%5Cbeta_2"> is the adjusted mean difference per year of age.</li>
<li><img src="https://latex.codecogs.com/png.latex?%5Cbeta_3"> describes a batch contrast; it is not a biological effect.</li>
</ul>
<p>The experimental units are the 60 patients. Multiple lanes, reads, or technical replicates improve measurement or help estimate technical variation but do not turn the study into a larger patient sample. If treatment is completely confounded with batch, the design matrix cannot distinguish <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> from <img src="https://latex.codecogs.com/png.latex?%5Cbeta_3">; no regression algorithm can recover information absent from the design.</p>
<p>Statistically, an estimated treatment coefficient and interval summarize an adjusted contrast on the chosen expression scale. Biologically, interpretation also requires the gene’s function, effect magnitude, normalization, tissue composition, and whether the specimens represent the target population.</p>
</section>
<section id="assumptions-diagnostics-and-sensitivity" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Assumptions, Diagnostics, and Sensitivity</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Assumption or issue</th>
<th>Consequence</th>
<th>Assessment</th>
<th>Sensitivity or remedy</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Correct conditional mean</td>
<td>Misspecification makes coefficients misleading averages</td>
<td>Residual plots, partial-residual plots, domain knowledge</td>
<td>Transformations, splines, interactions, alternative model</td>
</tr>
<tr class="even">
<td>Independent units</td>
<td>Correlated errors invalidate ordinary SEs</td>
<td>Sampling hierarchy and time/order metadata</td>
<td>Cluster-robust inference, mixed model, generalized least squares</td>
</tr>
<tr class="odd">
<td>Zero conditional error mean</td>
<td>Omitted causes and selection can bias coefficients</td>
<td>Design reasoning, causal diagram, negative controls</td>
<td>Better design, justified adjustment, quantitative sensitivity analysis</td>
</tr>
<tr class="even">
<td>Constant variance</td>
<td>Classical SEs may be wrong and OLS inefficient</td>
<td>Residual spread by fitted values and groups</td>
<td>Robust SEs or explicit variance model</td>
</tr>
<tr class="odd">
<td>Full rank and adequate overlap</td>
<td>Coefficients may be unidentified or unstable</td>
<td>Rank, condition indices, predictor distributions</td>
<td>Redesign, combine parameters, regularize for prediction, narrow target</td>
</tr>
<tr class="even">
<td>No dominant observations</td>
<td>A few units can control estimates</td>
<td>Leverage, studentized residuals, Cook’s distance, DFBETAs</td>
<td>Verify records and report deletion diagnostics transparently</td>
</tr>
<tr class="odd">
<td>Accurate variables</td>
<td>Measurement error can bias several coefficients</td>
<td>Validation data, reliability studies</td>
<td>Measurement-error model; calibration; replicate assays</td>
</tr>
</tbody>
</table>
<p>A useful diagnostic sequence is: verify design and units; inspect missingness and overlap; visualize residuals; examine leverage and influence; compare conventional and robust uncertainty; test scientifically plausible nonlinearities and interactions; and report how conclusions change. Diagnostics should be tied to a failure mechanism, not used as a ritual pass/fail checklist.</p>
<p>Variable selection after looking at the same outcome changes the sampling behavior of coefficients and p-values. If selection is unavoidable, separate exploration from confirmation, validate out of sample, and acknowledge post-selection uncertainty.</p>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/regression-models/simple-linear-regression.html">Simple linear regression</a> develops the one-predictor case and basic prediction intervals.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/likelihood-and-log-likelihood.html">Likelihood and log-likelihood</a> connects Gaussian regression to likelihood-based estimation.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/sensitivity-analysis-and-robustness.html">Sensitivity analysis and robustness</a> provides a framework for checking dependence on assumptions.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/selection-bias-and-winners-curse.html">Selection bias and winner’s curse</a> explains why data-dependent reporting can inflate coefficients.</li>
</ul>
<ol type="1">
<li>A multiple-regression coefficient is a conditional comparison given the other modeled predictors.</li>
<li>Least squares projects the response onto the design space; full column rank is required for unique coefficients.</li>
<li>Adjustment changes the estimand and can reduce, create, or leave bias depending on the data-generating structure.</li>
<li>Robust standard errors address variance misspecification, not confounding, dependence, lack of overlap, or an incorrect mean model.</li>
<li>In bioinformatics, independent biological specimens determine inferential replication; technical observations do not substitute for them.</li>
</ol>
</section>
<section id="references" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> References</h1>
<ul>
<li>Frisch, R., and Waugh, F. V. (1933). Partial time regressions as compared with individual trends. <em>Econometrica</em>, 1(4), 387–401. <a href="https://doi.org/10.2307/1907330" class="uri">https://doi.org/10.2307/1907330</a></li>
<li>Lovell, M. C. (1963). Seasonal adjustment of economic time series and multiple regression analysis. <em>Journal of the American Statistical Association</em>, 58(304), 993–1010. <a href="https://doi.org/10.1080/01621459.1963.10480682" class="uri">https://doi.org/10.1080/01621459.1963.10480682</a></li>
<li>White, H. (1980). A heteroskedasticity-consistent covariance matrix estimator and a direct test for heteroskedasticity. <em>Econometrica</em>, 48(4), 817–838. <a href="https://doi.org/10.2307/1912934" class="uri">https://doi.org/10.2307/1912934</a></li>
<li>Weisberg, S. (2014). <em>Applied Linear Regression</em> (4th ed.). Wiley.</li>
<li>Gelman, A., Hill, J., and Vehtari, A. (2020). <em>Regression and Other Stories</em>. Cambridge University Press. <a href="https://doi.org/10.1017/9781139161879" class="uri">https://doi.org/10.1017/9781139161879</a></li>
<li>R Core Team. <code>lm</code>: Fitting linear models. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Linear Models</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/multiple-linear-regression.html</guid>
  <pubDate>Fri, 09 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Simple Linear Regression</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/regression-models/simple-linear-regression.html</link>
  <description><![CDATA[ 





<section id="the-question-and-the-model" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> The Question and the Model</h1>
<p>Suppose each independent experimental unit contributes a predictor <img src="https://latex.codecogs.com/png.latex?X_i"> and a continuous response <img src="https://latex.codecogs.com/png.latex?Y_i">. Simple linear regression describes how the <strong>conditional mean</strong> of the response changes with the predictor:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AY_i=%5Cbeta_0+%5Cbeta_1X_i+%5Cvarepsilon_i,%0A%5Cqquad%0A%5Coperatorname%7BE%7D(%5Cvarepsilon_i%5Cmid%20X_i)=0.%0A"></p>
<p>Equivalently,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(Y_i%5Cmid%20X_i=x)=%5Cbeta_0+%5Cbeta_1x.%0A"></p>
<p>The model is about the mean of <img src="https://latex.codecogs.com/png.latex?Y"> at each value of <img src="https://latex.codecogs.com/png.latex?X">, not a claim that every observation lies on a line. Biological heterogeneity, measurement error, and unmodeled causes appear in the residual variation around that mean.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 50%">
<col style="width: 50%">
</colgroup>
<thead>
<tr class="header">
<th>Quantity</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><img src="https://latex.codecogs.com/png.latex?%5Cbeta_0"></td>
<td>Mean response when <img src="https://latex.codecogs.com/png.latex?X=0"></td>
</tr>
<tr class="even">
<td><img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"></td>
<td>Change in mean response for a one-unit increase in <img src="https://latex.codecogs.com/png.latex?X"></td>
</tr>
<tr class="odd">
<td><img src="https://latex.codecogs.com/png.latex?%5Cvarepsilon_i"></td>
<td>Unit-specific deviation from the conditional mean</td>
</tr>
<tr class="even">
<td><img src="https://latex.codecogs.com/png.latex?%5Csigma%5E2"></td>
<td>Conditional residual variance, if assumed constant</td>
</tr>
<tr class="odd">
<td><img src="https://latex.codecogs.com/png.latex?%5Chat%5Cbeta_0,%5Chat%5Cbeta_1"></td>
<td>Estimators before data are observed; estimates afterward</td>
</tr>
</tbody>
</table>
<p>The scientific estimand must be stated before fitting. It may be a descriptive conditional association, a predictive relationship, or—under substantially stronger design and causal assumptions—an average causal effect. A regression slope alone does not decide which interpretation is justified.</p>
</section>
<section id="least-squares" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Least Squares</h1>
<p>Ordinary least squares (OLS) chooses the line that minimizes the residual sum of squares</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BRSS%7D(b_0,b_1)%0A=%5Csum_%7Bi=1%7D%5E%7Bn%7D(Y_i-b_0-b_1X_i)%5E2.%0A"></p>
<p>Write <img src="https://latex.codecogs.com/png.latex?%5Cbar%20X=n%5E%7B-1%7D%5Csum_iX_i"> and <img src="https://latex.codecogs.com/png.latex?%5Cbar%20Y=n%5E%7B-1%7D%5Csum_iY_i">. Differentiating RSS with respect to <img src="https://latex.codecogs.com/png.latex?b_0"> and <img src="https://latex.codecogs.com/png.latex?b_1"> gives the normal equations. Their solution is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%0A%5Chat%5Cbeta_1=%0A%5Cfrac%7B%5Csum_i(X_i-%5Cbar%20X)(Y_i-%5Cbar%20Y)%7D%0A%20%20%20%20%20%7B%5Csum_i(X_i-%5Cbar%20X)%5E2%7D%0A%7D,%0A%5Cqquad%0A%5Cboxed%7B%5Chat%5Cbeta_0=%5Cbar%20Y-%5Chat%5Cbeta_1%5Cbar%20X%7D.%0A"></p>
<p>Thus the fitted line passes through <img src="https://latex.codecogs.com/png.latex?(%5Cbar%20X,%5Cbar%20Y)">. The slope is sample covariation divided by variation in <img src="https://latex.codecogs.com/png.latex?X">; it is undefined if every <img src="https://latex.codecogs.com/png.latex?X_i"> is the same. This connects regression directly to <a href="../../../knowledge/statistics/probability-randomness/covariance-and-correlation.html">covariance and correlation</a>.</p>
<p>The fitted value and residual for unit <img src="https://latex.codecogs.com/png.latex?i"> are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%20Y_i=%5Chat%5Cbeta_0+%5Chat%5Cbeta_1X_i,%0A%5Cqquad%0Ae_i=Y_i-%5Chat%20Y_i.%0A"></p>
<p>With an intercept, <img src="https://latex.codecogs.com/png.latex?%5Csum_i%20e_i=0"> and <img src="https://latex.codecogs.com/png.latex?%5Csum_iX_ie_i=0">. These are algebraic properties of the fitted sample, not proof that the population errors have mean zero or are unrelated to <img src="https://latex.codecogs.com/png.latex?X">.</p>
</section>
<section id="sampling-behavior-and-uncertainty" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Sampling Behavior and Uncertainty</h1>
<p>Condition on the observed predictor values. If errors are independent with <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BE%7D(%5Cvarepsilon_i%5Cmid%20X)=0"> and <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BVar%7D(%5Cvarepsilon_i%5Cmid%20X)=%5Csigma%5E2">, then</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BE%7D(%5Chat%5Cbeta_1%5Cmid%20X)=%5Cbeta_1,%0A%5Cqquad%0A%5Coperatorname%7BVar%7D(%5Chat%5Cbeta_1%5Cmid%20X)%0A=%5Cfrac%7B%5Csigma%5E2%7D%7BS_%7Bxx%7D%7D,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?S_%7Bxx%7D=%5Csum_i(X_i-%5Cbar%20X)%5E2">. More independent units, less noise, and a wider informative spread of predictor values make the slope more precise.</p>
<p>Estimate the residual variance with</p>
<p><img src="https://latex.codecogs.com/png.latex?%0As%5E2=%5Cfrac%7B%5Coperatorname%7BRSS%7D%7D%7Bn-2%7D,%0A%5Cqquad%0A%5Coperatorname%7BSE%7D(%5Chat%5Cbeta_1)=%5Cfrac%7Bs%7D%7B%5Csqrt%7BS_%7Bxx%7D%7D%7D.%0A"></p>
<p>If the errors are conditionally normal, the exact pivot</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7B%5Chat%5Cbeta_1-%5Cbeta_1%7D%7B%5Coperatorname%7BSE%7D(%5Chat%5Cbeta_1)%7D%0A%5Csim%20t_%7Bn-2%7D%0A"></p>
<p>produces a confidence interval and a test of a prespecified slope. Without normality, OLS can still be unbiased under the mean model, while <img src="https://latex.codecogs.com/png.latex?t"> inference is generally approximate. Robust standard errors, bootstrap procedures, or a model for changing variance may be more appropriate.</p>
<p>Distinguish three uncertainty targets:</p>
<ul>
<li>a confidence interval for the unknown mean slope <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1">;</li>
<li>a confidence interval for the mean response at a chosen <img src="https://latex.codecogs.com/png.latex?x_0">;</li>
<li>a prediction interval for a new response at <img src="https://latex.codecogs.com/png.latex?x_0">, which is wider because it includes new unit-level variation.</li>
</ul>
<p>At <img src="https://latex.codecogs.com/png.latex?x_0">, their estimated standard-error components are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BSE%7D%5C%7B%5Cwidehat%7B%5Coperatorname%7BE%7D(Y%5Cmid%20x_0)%7D%5C%7D%0A=s%5Csqrt%7B%5Cfrac1n+%5Cfrac%7B(x_0-%5Cbar%20X)%5E2%7D%7BS_%7Bxx%7D%7D%7D,%0A"></p>
<p>and</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BSE%7D(Y_%7B%5Cmathrm%7Bnew%7D%7D-%5Chat%20Y_0)%0A=s%5Csqrt%7B1+%5Cfrac1n+%5Cfrac%7B(x_0-%5Cbar%20X)%5E2%7D%7BS_%7Bxx%7D%7D%7D.%0A"></p>
<p>Both grow away from the center of the observed predictor range.</p>
</section>
<section id="worked-example" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Worked Example</h1>
<p>For five independent specimens, suppose standardized exposure is <img src="https://latex.codecogs.com/png.latex?X=(-2,-1,0,1,2)"> and normalized expression is <img src="https://latex.codecogs.com/png.latex?Y=(4,5,7,8,11)">. Here <img src="https://latex.codecogs.com/png.latex?%5Cbar%20X=0">, <img src="https://latex.codecogs.com/png.latex?%5Cbar%20Y=7">, <img src="https://latex.codecogs.com/png.latex?S_%7Bxx%7D=10">, and</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Csum_i(X_i-%5Cbar%20X)(Y_i-%5Cbar%20Y)=17.%0A"></p>
<p>Therefore <img src="https://latex.codecogs.com/png.latex?%5Chat%5Cbeta_1=1.7"> and <img src="https://latex.codecogs.com/png.latex?%5Chat%5Cbeta_0=7">. The fitted mean expression increases by 1.7 normalized units per one-unit increase in exposure. This is an estimate of association among specimens. It is not automatically an effect of intervening on exposure, and its biological meaning depends on the normalization scale.</p>
<p>The residuals are <img src="https://latex.codecogs.com/png.latex?(0.4,-0.3,0,-0.7,0.6)">, so RSS is <img src="https://latex.codecogs.com/png.latex?1.10"> and <img src="https://latex.codecogs.com/png.latex?s%5E2=1.10/3">. The calculation makes clear that the sample size for inference is five specimens—not the number of reads or repeated technical measurements used to construct each specimen-level expression value.</p>
</section>
<section id="assumptions-diagnostics-and-sensitivity" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Assumptions, Diagnostics, and Sensitivity</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Assumption or goal</th>
<th>Why it matters</th>
<th>Diagnostic evidence</th>
<th>Response</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Linear conditional mean</td>
<td>Otherwise one slope averages a changing relationship</td>
<td>Residual-versus-fitted plot; smooth trend; domain knowledge</td>
<td>Transform variables, add curvature, or restrict the range</td>
</tr>
<tr class="even">
<td>Independent experimental units</td>
<td>Dependence makes ordinary SEs too small</td>
<td>Study design, clusters, time order</td>
<td>Model clusters/repeated measures or aggregate at the correct unit</td>
</tr>
<tr class="odd">
<td>Zero conditional mean</td>
<td>Confounding or systematic error biases the slope</td>
<td>Design knowledge; negative controls; sensitivity analysis</td>
<td>Randomize, adjust measured causes, redesign; diagnostics alone cannot prove it</td>
</tr>
<tr class="even">
<td>Constant conditional variance</td>
<td>Classical SEs and efficiency rely on it</td>
<td>Residual spread across fitted values</td>
<td>Robust SEs, variance modeling, transformation</td>
</tr>
<tr class="odd">
<td>No dominant observations</td>
<td>One point can determine the line</td>
<td>Leverage, studentized residuals, Cook’s distance</td>
<td>Verify data; report leave-one-out sensitivity; do not delete automatically</td>
</tr>
<tr class="even">
<td>Relevant predictor range</td>
<td>Extrapolation is unsupported by observed data</td>
<td>Compare requested <img src="https://latex.codecogs.com/png.latex?x_0"> with observed range</td>
<td>Avoid or justify extrapolation mechanistically</td>
</tr>
</tbody>
</table>
<p>Normal residuals are needed for exact small-sample <img src="https://latex.codecogs.com/png.latex?t"> and <img src="https://latex.codecogs.com/png.latex?F"> inference, not for the definition of OLS. A histogram or quantile–quantile plot can reveal severe skewness and outliers, but small samples make normality hard to assess.</p>
<p>Measurement error in <img src="https://latex.codecogs.com/png.latex?Y"> usually increases residual variation. Classical random measurement error in <img src="https://latex.codecogs.com/png.latex?X"> is more dangerous: it commonly attenuates the estimated slope toward zero. Replicating the assay technically can characterize measurement error, but it does not create additional biological replication.</p>
</section>
<section id="association-prediction-and-causation" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Association, Prediction, and Causation</h1>
<p>The same fitted line can serve different aims:</p>
<ul>
<li><strong>Description:</strong> summarize the observed specimen-level association.</li>
<li><strong>Prediction:</strong> predict outcomes for future units drawn under the same data process; evaluate out-of-sample error.</li>
<li><strong>Causal estimation:</strong> interpret <img src="https://latex.codecogs.com/png.latex?%5Cbeta_1"> as an intervention effect only with a credible design and assumptions about confounding, selection, interference, measurement, and model form.</li>
</ul>
<p>Randomization can justify a causal comparison, but a linear functional form may still be a poor summary. Conversely, an excellent predictive fit does not remove confounding.</p>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/statistical-inference/populations-samples-parameters-and-estimands.html">Populations, samples, parameters, and estimands</a> clarifies the target before the slope is estimated.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/standard-errors.html">Standard errors</a> and <a href="../../../knowledge/statistics/statistical-inference/confidence-intervals.html">confidence intervals</a> develop repeated-sampling uncertainty.</li>
<li><a href="../../../knowledge/statistics/regression-models/multiple-linear-regression.html">Multiple linear regression</a> replaces the single predictor with a vector and changes coefficient interpretation to a conditional comparison.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-versus-practical-significance.html">Statistical versus practical significance</a> explains why a small p-value does not establish biological importance.</li>
</ul>
<ol type="1">
<li>Simple regression models a conditional mean; observations need not lie on a line.</li>
<li>The OLS slope is sample covariation divided by predictor variation.</li>
<li>Uncertainty depends on independent experimental units, residual variation, and the informative spread of <img src="https://latex.codecogs.com/png.latex?X">.</li>
<li>Residual diagnostics can expose model tension but cannot prove absence of confounding or selection bias.</li>
<li>Biological, technical, predictive, and causal interpretations must be stated separately.</li>
</ol>
</section>
<section id="references" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> References</h1>
<ul>
<li>Fisher, R. A. (1922). The goodness of fit of regression formulae, and the distribution of regression coefficients. <em>Journal of the Royal Statistical Society</em>, 85(4), 597–612. <a href="https://doi.org/10.2307/2341124" class="uri">https://doi.org/10.2307/2341124</a></li>
<li>Gauss, C. F. (1823). Theoria combinationis observationum erroribus minimis obnoxiae. <em>Commentationes Societatis Regiae Scientiarum Gottingensis Recentiores</em>, 5.</li>
<li>Weisberg, S. (2014). <em>Applied Linear Regression</em> (4th ed.). Wiley.</li>
<li>Gelman, A., Hill, J., and Vehtari, A. (2020). <em>Regression and Other Stories</em>. Cambridge University Press. <a href="https://doi.org/10.1017/9781139161879" class="uri">https://doi.org/10.1017/9781139161879</a></li>
<li>R Core Team. <code>lm</code>: Fitting linear models. <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html" class="uri">https://stat.ethz.ch/R-manual/R-devel/library/stats/html/lm.html</a></li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Regression</category>
  <category>Linear Models</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/regression-models/simple-linear-regression.html</guid>
  <pubDate>Fri, 09 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Reproducibility and Effect-size Inflation</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/statistical-inference/reproducibility-and-effect-size-inflation.html</link>
  <description><![CDATA[ 





<section id="reproducible-is-not-a-single-statistical-property" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Reproducible Is Not a Single Statistical Property</h1>
<p>Several questions are often collapsed into “Does it reproduce?”</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Property</th>
<th>What is repeated?</th>
<th>Main target</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Computational reproducibility</td>
<td>Same data and analysis</td>
<td>Same numerical result</td>
</tr>
<tr class="even">
<td>Analytic reproducibility</td>
<td>Same data, independently implemented workflow</td>
<td>Agreement after resolving implementation choices</td>
</tr>
<tr class="odd">
<td>Direct replication</td>
<td>New experimental units under closely matched conditions</td>
<td>Same prespecified estimand or claim</td>
</tr>
<tr class="even">
<td>Conceptual replication</td>
<td>New operationalization of a proposed mechanism</td>
<td>Generality of the scientific explanation</td>
</tr>
<tr class="odd">
<td>Robustness</td>
<td>Plausible alternative assumptions or analyses</td>
<td>Stability of the conclusion</td>
</tr>
<tr class="even">
<td>Generalizability</td>
<td>New populations, laboratories, times, or protocols</td>
<td>Transport of the effect</td>
</tr>
</tbody>
</table>
<p>A perfectly reproducible script can reproduce a biased estimate. A valid replication can differ because of sampling error. A genuine effect can vary across biological contexts. Reproducibility therefore requires a defined estimand, a transparent workflow, an uncertainty model, and a criterion for what agreement would mean.</p>
</section>
<section id="effect-size-inflation" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Effect-size Inflation</h1>
<p>Let <img src="https://latex.codecogs.com/png.latex?%5Ctheta"> be a population effect and</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%5Ctheta%5Csim%20N(%5Ctheta,s%5E2).%0A"></p>
<p>Without selection, <img src="https://latex.codecogs.com/png.latex?%5Chat%5Ctheta"> is unbiased in this model. If results are highlighted only when <img src="https://latex.codecogs.com/png.latex?%7C%5Chat%5Ctheta%7C/s%3Ec">, the reported distribution is truncated. Estimates that cross the threshold tend to have unusually large magnitudes.</p>
<p>For a positive true effect, Gelman and Carlin’s <strong>Type M</strong> exaggeration ratio is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AM=%5Cfrac%7B%5Coperatorname%20E%5Cleft(%7C%5Chat%5Ctheta%7C%5Cmid%20%7C%5Chat%5Ctheta%7C/s%3Ec%5Cright)%7D%7B%7C%5Ctheta%7C%7D.%0A"></p>
<p>A <strong>Type S</strong> error is the conditional probability of estimating the wrong sign,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AS=P%5Cleft(%5Coperatorname%7Bsign%7D(%5Chat%5Ctheta)%5Cne%0A%5Coperatorname%7Bsign%7D(%5Ctheta)%5Cmid%20%7C%5Chat%5Ctheta%7C/s%3Ec%5Cright).%0A"></p>
<p>When the signal-to-noise ratio <img src="https://latex.codecogs.com/png.latex?%7C%5Ctheta%7C/s"> is small, power is low, Type M exaggeration can be large, and a selected result can even have the wrong sign. Statistical significance does not protect the magnitude or direction.</p>
</section>
<section id="why-low-power-inflates-selected-effects" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Why Low Power Inflates Selected Effects</h1>
<p>Suppose <img src="https://latex.codecogs.com/png.latex?%5Ctheta=0.20">, <img src="https://latex.codecogs.com/png.latex?s=0.20">, and a two-sided <img src="https://latex.codecogs.com/png.latex?5%5C%25"> test uses <img src="https://latex.codecogs.com/png.latex?c=1.96">. Discovery requires <img src="https://latex.codecogs.com/png.latex?%7C%5Chat%5Ctheta%7C%3E0.392">. The true effect is smaller than this threshold, so most estimates near the truth are not selected. Published discoveries must usually contain a positive noise excursion; a smaller negative tail can also cross in the wrong direction.</p>
<p>This mechanism is sometimes called the significance filter, winner’s curse, or regression-to-the-mean setup. Its severity is driven by the signal-to-noise ratio and selection rule, not merely by whether the true effect is nonzero. Larger studies reduce <img src="https://latex.codecogs.com/png.latex?s">, increasing power and reducing conditional exaggeration for a fixed effect.</p>
<p>Inflation can accumulate beyond a single test:</p>
<pre class="text"><code>Noisy data
  → many outcomes, subgroups, transformations, or models
  → select favorable analyses
  → select favorable studies for publication
  → promote the most striking narrative</code></pre>
<p>Ordinary confidence intervals condition on the chosen analysis as though it had been fixed in advance. They usually do not include uncertainty from searching across analyses, studies, or interpretations.</p>
</section>
<section id="replication-is-an-estimation-problem" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Replication Is an Estimation Problem</h1>
<p>For independent original and replication estimates,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%5Ctheta_O%5Csim%20N(%5Ctheta_O,s_O%5E2),%0A%5Cqquad%0A%5Chat%5Ctheta_R%5Csim%20N(%5Ctheta_R,s_R%5E2).%0A"></p>
<p>Exact equality is neither expected nor generally the scientific hypothesis. Even if <img src="https://latex.codecogs.com/png.latex?%5Ctheta_O=%5Ctheta_R=%5Ctheta">, their difference has standard error</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BSE%7D(%5Chat%5Ctheta_R-%5Chat%5Ctheta_O)%0A=%5Csqrt%7Bs_R%5E2+s_O%5E2%7D.%0A"></p>
<p>If the original estimate was selected, its conditional center is not <img src="https://latex.codecogs.com/png.latex?%5Ctheta">. Comparing whether two p-values fall on the same side of <img src="https://latex.codecogs.com/png.latex?0.05"> discards magnitude and uncertainty: identical effects can yield different significance decisions, and different effects can both be significant.</p>
<p>A replication should specify before data collection:</p>
<ul>
<li>the population, intervention or exposure, outcome, time point, and effect scale;</li>
<li>the experimental unit and randomization or sampling design;</li>
<li>the primary estimand and analysis;</li>
<li>a scientifically meaningful agreement, equivalence, or prediction criterion;</li>
<li>sample size based on a defensible effect, not the selected original estimate;</li>
<li>how protocol departures and heterogeneity will be handled.</li>
</ul>
<p>Useful analyses report both effect estimates and intervals, the difference between them, and—when scientifically justified—an equivalence interval or prediction interval. A replication p-value alone does not estimate reproducibility.</p>
</section>
<section id="sampling-variation-bias-and-heterogeneity" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Sampling Variation, Bias, and Heterogeneity</h1>
<p>A smaller replication effect has several possible explanations.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Mechanism</th>
<th>Expected pattern</th>
<th>What helps distinguish it</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Sampling variation</td>
<td>Differences compatible with joint uncertainty</td>
<td>Intervals, repeated studies, hierarchical synthesis</td>
</tr>
<tr class="even">
<td>Original selection</td>
<td>Original is unusually extreme; replication regresses toward the mean</td>
<td>Full selection rule, independent estimation, shrinkage</td>
</tr>
<tr class="odd">
<td>Population or protocol heterogeneity</td>
<td>Effects vary systematically across contexts</td>
<td>Moderator data, harmonized outcomes, multisite design</td>
</tr>
<tr class="even">
<td>Measurement or implementation differences</td>
<td>Operationalizations target different quantities</td>
<td>Protocol audit, validation and reliability studies</td>
</tr>
<tr class="odd">
<td>Bias or model failure</td>
<td>Difference follows confounding, attrition, batch, or misspecification</td>
<td>Design review, diagnostics, negative controls, sensitivity analysis</td>
</tr>
<tr class="even">
<td>False-positive original</td>
<td>Replications center near the null</td>
<td>Adequately powered independent evidence and cumulative synthesis</td>
</tr>
</tbody>
</table>
<p>Heterogeneity should not become an unfalsifiable explanation. Proposed moderators need biological justification and enough independent studies or sites to estimate. Post hoc subgroup stories are another selection process and need new validation.</p>
</section>
<section id="reproducible-workflows-reduce-hidden-selection" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Reproducible Workflows Reduce Hidden Selection</h1>
<p>Computational practice cannot guarantee statistical validity, but it makes the analysis auditable.</p>
<ol type="1">
<li>Preserve raw data and create processed data with scripted, versioned steps.</li>
<li>Record inclusion, exclusion, filtering, normalization, and quality-control decisions.</li>
<li>Fix random seeds and report stochastic algorithms, simulation error, and software versions.</li>
<li>Use dependency-locked environments and machine-readable parameters.</li>
<li>Separate exploratory analyses from prespecified confirmatory analyses.</li>
<li>Nest preprocessing and variable selection inside resampling or cross-validation folds.</li>
<li>Publish code, metadata, and provenance when consent and privacy permit; otherwise provide controlled-access instructions and synthetic tests.</li>
<li>Test the pipeline on data with known answers and rerun it from a clean environment.</li>
</ol>
<p>Preregistration and registered reports reduce undisclosed flexibility, but a poor prespecified design remains poor. Sharing code exposes what was run, not why the assumptions identify the target. Reproducible workflows complement design, diagnostics, sensitivity analysis, and replication.</p>
</section>
<section id="planning-with-type-m-and-type-s-errors" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Planning with Type M and Type S Errors</h1>
<p>Traditional power asks how often a rule rejects the null under an assumed effect. A more informative design analysis also simulates or calculates:</p>
<ul>
<li>the distribution of estimates and interval widths;</li>
<li>Type S probability among selected results;</li>
<li>Type M exaggeration among selected results;</li>
<li>probability of estimating an effect above a practical threshold;</li>
<li>interval coverage after the complete selection pipeline;</li>
<li>predictive performance in a genuinely external sample.</li>
</ul>
<p>The assumed true-effect range should come from prior studies corrected for selection, a meta-analysis that addresses heterogeneity and reporting bias, mechanistic constraints, or the smallest effect worth detecting. Using the original selected estimate as truth understates required sample size.</p>
<p>Shrinkage and hierarchical models can improve estimation by combining noisy effects with an estimated effect distribution. Their gains depend on exchangeability and an adequate prior or population model. They do not transform technical replicates into biological information, and shrinkage toward a poorly estimated center can itself mislead.</p>
</section>
<section id="evidence-synthesis-and-publication-selection" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Evidence Synthesis and Publication Selection</h1>
<p>If study inclusion depends on significance, direction, or novelty, the published literature is selected. Small studies require larger observed effects to cross a fixed threshold, creating a small-study-effect pattern. Funnel-plot asymmetry and regression tests can detect some patterns but are low-powered with few studies and are not specific to publication bias; genuine heterogeneity can produce the same shape.</p>
<p>Meta-analysis of biased inputs can yield a precise biased summary. Sensible practice includes prospective study registration, comprehensive searches, inclusion of null results, risk-of-bias assessment, sensitivity to selection models, and prediction intervals when effects vary. No single trim-and-fill or bias-correction method should be treated as proof that publication selection has been removed.</p>
<p>Cumulative evidence is better evaluated by the distribution of compatible effects, heterogeneity, design quality, and prospective predictions than by counting successful replications. Meta-analytic pooling also requires commensurate estimands; combining differently defined outcomes does not manufacture a common target.</p>
</section>
<section id="bioinformatics-design-and-interpretation" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Bioinformatics Design and Interpretation</h1>
<p>Consider differential expression measured in thousands of genes from six treated and six control donors. Donors are the experimental units. Reads, technical library replicates, and cells improve measurement or characterize within-donor variation but do not raise the condition-level biological sample size to thousands.</p>
<p>Effect-size inflation arises when only genes with small adjusted p-values are plotted and their same-data log fold changes are interpreted literally. Shrinkage can stabilize estimates, but discovery estimates should still be distinguished from effects in independent donors. Pathways selected because they summarize the same top genes require validation in a new cohort or a selection-aware procedure.</p>
<p>Reproducibility requires the count matrix or a traceable route from raw reads, sample metadata, reference genome and annotation versions, filtering and normalization rules, the design matrix, contrast, software versions, and all quality-control exclusions. Batch correction must be learned without leaking validation outcomes. In single-cell experiments, donor-aware pseudobulk or mixed models preserve replication; repeating cells from the same donor does not demonstrate cross-donor reproducibility.</p>
<p>Statistical replication asks whether a prespecified effect is compatible across independent samples. Biological replication asks whether the conclusion persists across relevant organisms, tissues, environments, protocols, and laboratories. A stable p-value is neither definition.</p>
</section>
<section id="a-decision-framework" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> A Decision Framework</h1>
<p>Before calling a result reproducible, ask:</p>
<ol type="1">
<li><strong>Same target?</strong> Are the estimand, population, outcome, and scale aligned?</li>
<li><strong>Independent information?</strong> Are the replication units independent of discovery and analyzed at the correct level?</li>
<li><strong>Visible selection?</strong> Were hypotheses, analyses, exclusions, and reporting rules disclosed?</li>
<li><strong>Adequate precision?</strong> Can the new study distinguish absence, meaningful similarity, and meaningful difference?</li>
<li><strong>Magnitude and uncertainty?</strong> Are estimates and intervals reported rather than only threshold decisions?</li>
<li><strong>Heterogeneity modeled?</strong> Are contextual differences planned rather than invented after results?</li>
<li><strong>Workflow auditable?</strong> Can another analyst regenerate processing and analysis from documented inputs?</li>
<li><strong>Claims calibrated?</strong> Does the conclusion stay within the observed populations and design assumptions?</li>
</ol>
</section>
<section id="common-failure-modes" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> Common Failure Modes</h1>
<ul>
<li><strong>Same code equals replication:</strong> it establishes computational reproducibility only.</li>
<li><strong>Both studies must be significant:</strong> dichotomized p-values are compared instead of effects and uncertainty.</li>
<li><strong>The original estimate powers the replication:</strong> selection makes the design effect too large.</li>
<li><strong>More technical measurements imply more power:</strong> the biological experimental unit is ignored.</li>
<li><strong>A correction is treated as ground truth:</strong> selection models and shrinkage assumptions are not checked.</li>
<li><strong>Unexpected differences are automatically heterogeneity:</strong> sampling error, selection, and bias are not quantified first.</li>
<li><strong>Only successful pipelines are disclosed:</strong> analyst-level selection remains invisible despite shared final code.</li>
<li><strong>A non-significant replication proves no effect:</strong> an imprecise study can be compatible with both important and negligible effects.</li>
</ul>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="12">
<h1 data-number="12"><span class="header-section-number">12</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/statistical-inference/effect-sizes.html">Effect sizes</a> defines magnitude on interpretable scales.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-versus-practical-significance.html">Statistical versus practical significance</a> supplies meaningful agreement and decision thresholds.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/selection-bias-and-winners-curse.html">Selection bias and winner’s curse</a> derives the conditioning that inflates discoveries.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-power-and-sample-size-calculation.html">Statistical power and sample-size calculation</a> supports prospective replication design.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/confidence-intervals.html">Confidence intervals</a> and <a href="../../../knowledge/statistics/statistical-inference/one-sided-two-sided-and-equivalence-tests.html">equivalence tests</a> replace significance matching with explicit compatibility questions.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/sensitivity-analysis-and-robustness.html">Sensitivity analysis and robustness</a> examines dependence on unverifiable assumptions and workflow choices.</li>
</ul>
<p>Reproducibility has computational, statistical, and biological dimensions. Effect-size inflation is expected when noisy, low-powered estimates are filtered for significance or extremeness. Replication should be designed around a prespecified estimand and defensible effect range, then interpreted through magnitude, uncertainty, selection, and heterogeneity—not matching p-value labels.</p>
</section>
<section id="references" class="level1" data-number="13">
<h1 data-number="13"><span class="header-section-number">13</span> References</h1>
<ul>
<li>Gelman, A. and Carlin, J. “Beyond Power Calculations: Assessing Type S (Sign) and Type M (Magnitude) Errors.” <em>Perspectives on Psychological Science</em> 9 (2014): 641–651. <a href="https://doi.org/10.1177/1745691614551642">Article</a>.</li>
<li>Ioannidis, J. P. A. “Why Most Discovered True Associations Are Inflated.” <em>Epidemiology</em> 19 (2008): 640–648. <a href="https://doi.org/10.1097/EDE.0b013e31818131e7">Article</a>.</li>
<li>Open Science Collaboration. “Estimating the Reproducibility of Psychological Science.” <em>Science</em> 349 (2015): aac4716. <a href="https://doi.org/10.1126/science.aac4716">Article</a>.</li>
<li>Button, K. S. et al.&nbsp;“Power Failure: Why Small Sample Size Undermines the Reliability of Neuroscience.” <em>Nature Reviews Neuroscience</em> 14 (2013): 365–376. <a href="https://doi.org/10.1038/nrn3475">Article</a>.</li>
<li>Munafò, M. R. et al.&nbsp;“A Manifesto for Reproducible Science.” <em>Nature Human Behaviour</em> 1 (2017): 0021. <a href="https://doi.org/10.1038/s41562-016-0021">Article</a>.</li>
<li>Patil, P., Peng, R. D., and Leek, J. T. “A Statistical Definition for Reproducibility and Replicability.” <em>Proceedings of the National Academy of Sciences</em> 113 (2016): 14648–14653. <a href="https://doi.org/10.1073/pnas.1600793113">Article</a>.</li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Inference</category>
  <category>Reproducibility</category>
  <category>Effect Size</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/statistical-inference/reproducibility-and-effect-size-inflation.html</guid>
  <pubDate>Thu, 08 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Selection Bias and Winner’s Curse</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/statistical-inference/selection-bias-and-winners-curse.html</link>
  <description><![CDATA[ 





<section id="selection-changes-the-distribution-being-analyzed" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Selection Changes the Distribution Being Analyzed</h1>
<p>Selection bias occurs when entry into the analyzed data, or entry into the reported set of results, depends on variables that also determine the association or estimate of interest. Let <img src="https://latex.codecogs.com/png.latex?S=1"> mean that an experimental unit or result is retained. The analyzed distribution is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap(x,y%5Cmid%20S=1)=%5Cfrac%7BP(S=1%5Cmid%20x,y)p(x,y)%7D%7BP(S=1)%7D,%0A"></p>
<p>which equals the target distribution <img src="https://latex.codecogs.com/png.latex?p(x,y)"> only under restrictive conditions. A large selected sample can therefore estimate the wrong target very precisely.</p>
<p>The <strong>winner’s curse</strong> is a post-selection form of effect-size inflation. Among noisy estimates, investigators preferentially follow the most extreme, best-ranked, or statistically significant ones. Conditional on winning that competition, the same favorable noise that caused selection remains inside the reported estimate.</p>
<p>Selection bias is broader than the winner’s curse. It includes biased recruitment, loss to follow-up, complete-case analysis, case-control sampling used with an inappropriate estimand, conditioning on a collider, and selective reporting. The winner’s curse specifically concerns estimates selected because of their observed strength.</p>
</section>
<section id="start-with-the-target-and-selection-rule" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Start with the Target and Selection Rule</h1>
<p>Suppose the target-population estimand is an association or effect <img src="https://latex.codecogs.com/png.latex?%5Ctheta">. An estimator <img src="https://latex.codecogs.com/png.latex?%5Chat%5Ctheta"> may be unbiased before selection,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%20E(%5Chat%5Ctheta)=%5Ctheta,%0A"></p>
<p>but the relevant property after a discovery rule <img src="https://latex.codecogs.com/png.latex?A"> is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%20E(%5Chat%5Ctheta%5Cmid%20A)-%5Ctheta.%0A"></p>
<p>These are different operating characteristics. A realized estimate answers the intended question only if the sampling, missingness, inclusion, and reporting mechanisms preserve identification of the estimand or are correctly handled.</p>
<p>Three selections should be distinguished:</p>
<ol type="1">
<li><strong>Units:</strong> which people, specimens, cells, records, or measurements enter the analysis?</li>
<li><strong>Variables and models:</strong> which outcomes, predictors, transformations, and specifications are retained?</li>
<li><strong>Results:</strong> which estimates cross a threshold and are reported, interpreted, or sent to replication?</li>
</ol>
<p>The selection indicator and the information used to construct it belong in the analysis description. Saying that data were “quality controlled” is insufficient if the quality rule depends on exposure, outcome, batch, or a downstream consequence of both.</p>
</section>
<section id="structural-selection-bias" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Structural Selection Bias</h1>
<p>A causal diagram makes one important mechanism visible. If exposure <img src="https://latex.codecogs.com/png.latex?X"> and outcome <img src="https://latex.codecogs.com/png.latex?Y"> both influence selection,</p>
<pre class="text"><code>X  →  S  ←  Y</code></pre>
<p>then <img src="https://latex.codecogs.com/png.latex?S"> is a collider. Even if <img src="https://latex.codecogs.com/png.latex?X"> and <img src="https://latex.codecogs.com/png.latex?Y"> are independent in the target population, conditioning on <img src="https://latex.codecogs.com/png.latex?S=1"> can associate them. More generally, selection opens an otherwise blocked path when it conditions on a collider or its descendant.</p>
<p>For example, suppose either a strong biomarker <img src="https://latex.codecogs.com/png.latex?X"> or severe disease <img src="https://latex.codecogs.com/png.latex?Y"> makes referral to a specialty clinic more likely. Within referred patients, low biomarker values may occur disproportionately among severe cases admitted for other reasons. A clinic-only association can differ in magnitude or direction from the population association.</p>
<p>Not all conditioning is harmful and not all selection produces bias for every target. Case-control sampling can consistently estimate an exposure odds ratio under its design, although the sampled outcome prevalence is not a population prevalence. The effect depends on the estimand, graph, sampling fractions, and model—not on the word “selection” alone.</p>
</section>
<section id="deriving-the-winners-curse" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Deriving the Winner’s Curse</h1>
<p>Consider an approximately normal estimate</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%5Ctheta%5Csim%20N(%5Ctheta,s%5E2)%0A"></p>
<p>with known standard error <img src="https://latex.codecogs.com/png.latex?s">. A one-sided discovery is declared when <img src="https://latex.codecogs.com/png.latex?%5Chat%5Ctheta/s%3Ec">, equivalently <img src="https://latex.codecogs.com/png.latex?%5Chat%5Ctheta%3Ea=cs">. For a truncated normal distribution,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%20E(%5Chat%5Ctheta%5Cmid%5Chat%5Ctheta%3Ea)%0A=%5Ctheta+s%5Cfrac%7B%5Cphi(%5Calpha)%7D%7B1-%5CPhi(%5Calpha)%7D,%0A%5Cqquad%0A%5Calpha=%5Cfrac%7Ba-%5Ctheta%7D%7Bs%7D,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?%5Cphi"> and <img src="https://latex.codecogs.com/png.latex?%5CPhi"> are the standard-normal density and distribution functions. The second term is positive. Selection above a threshold inflates the signed estimate even though <img src="https://latex.codecogs.com/png.latex?%5Chat%5Ctheta"> was unbiased without selection.</p>
<p>For a two-sided rule <img src="https://latex.codecogs.com/png.latex?%7C%5Chat%5Ctheta%7C/s%3Ec">, effects reported in their observed direction are exaggerated in magnitude, especially when <img src="https://latex.codecogs.com/png.latex?%7C%5Ctheta%7C/s"> is small. Under the null, selected estimates are false positives rather than inflated estimates of a nonzero effect. When many non-null candidates compete, the top-ranked estimate combines the underlying effect with unusually favorable noise; heterogeneous true effects do not remove this conditioning problem.</p>
<section id="a-numerical-example" class="level2" data-number="4.1">
<h2 data-number="4.1" class="anchored" data-anchor-id="a-numerical-example"><span class="header-section-number">4.1</span> A numerical example</h2>
<p>Let the true effect be <img src="https://latex.codecogs.com/png.latex?%5Ctheta=0.20">, <img src="https://latex.codecogs.com/png.latex?s=0.20">, and use a one-sided threshold <img src="https://latex.codecogs.com/png.latex?c=1.645">. Then <img src="https://latex.codecogs.com/png.latex?a=0.329"> and <img src="https://latex.codecogs.com/png.latex?%5Calpha=0.645">. Because <img src="https://latex.codecogs.com/png.latex?%5Cphi(0.645)/%5C%7B1-%5CPhi(0.645)%5C%7D%5Capprox1.25">,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%20E(%5Chat%5Ctheta%5Cmid%5Ctext%7Bdiscovery%7D)%0A%5Capprox0.20+0.20(1.25)=0.45.%0A"></p>
<p>The discovery estimate is expected to exceed twice the true effect. Its unconditional standard error has not changed; what changed is the distribution conditional on being selected.</p>
</section>
</section>
<section id="regression-to-the-mean-is-not-biological-reversal" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Regression to the Mean Is Not Biological Reversal</h1>
<p>An independent replication estimate does not contain the discovery study’s favorable noise. Consequently, it often lies closer to the underlying effect. This <strong>regression to the mean</strong> is expected after selecting extremes and does not by itself show misconduct, biological reversal, or a failed replication.</p>
<p>Nevertheless, several other mechanisms can produce discovery–replication differences:</p>
<ul>
<li>population, ancestry, tissue, protocol, or endpoint heterogeneity;</li>
<li>biased discovery or replication sampling;</li>
<li>measurement and batch differences;</li>
<li>model misspecification or different estimands;</li>
<li>false-positive discovery;</li>
<li>sampling variation in both studies.</li>
</ul>
<p>A replication probability computed from the naive discovery estimate is usually too optimistic. It treats a selected overestimate as though it were the design effect and can leave the replication underpowered.</p>
</section>
<section id="prevention-and-post-selection-inference" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Prevention and Post-selection Inference</h1>
<p>Design is usually stronger than correction after the fact.</p>
<ul>
<li>Separate discovery, estimation, and validation samples. Use discovery data to select and independent data to estimate or confirm.</li>
<li>Prespecify eligibility, quality control, outcomes, models, contrasts, and the hypothesis family.</li>
<li>Increase the number of independent experimental units; higher information reduces the noise that selection can exploit.</li>
<li>Report the full search process, including null and unfavorable results.</li>
<li>Reserve external cohorts and laboratories for transportability and replication, not repeated tuning.</li>
</ul>
<p>When the same data must be used, methods include conditional or truncated likelihoods, selective confidence intervals, shrinkage or hierarchical models, empirical Bayes estimation, data splitting, and bootstrap bias correction. They answer different conditional or marginal questions and depend on correctly specifying the selection rule and model. A correction can reduce mean squared error yet overcorrect strong signals; there is no universal multiplier.</p>
<p>Inverse-probability selection weighting can identify a target-population estimand when selection probabilities are estimable, all relevant causes of selection and outcome are measured, positivity holds, and the outcome model or weighting strategy is appropriate. Weight instability signals weak support. Neither weighting nor imputation repairs an entirely unmeasured determinant without additional assumptions.</p>
</section>
<section id="diagnostics-and-sensitivity-analysis" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Diagnostics and Sensitivity Analysis</h1>
<p>Selection bias is often not empirically testable from selected data alone. Useful checks expose mechanisms rather than certify their absence.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Threat</th>
<th>Evidence to examine</th>
<th>Useful response</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Differential participation or attrition</td>
<td>Inclusion rates and covariate balance by exposure and outcome proxies</td>
<td>Selection models, weighting, bounds, follow-up of nonparticipants</td>
</tr>
<tr class="even">
<td>Thresholded discovery</td>
<td>Effect magnitude versus standard error and distance from threshold</td>
<td>Conditional estimation, shrinkage, independent estimation</td>
</tr>
<tr class="odd">
<td>Flexible analysis selection</td>
<td>Full specification set and analysis provenance</td>
<td>Prespecification, multiverse display, selective-inference methods</td>
</tr>
<tr class="even">
<td>Missingness-related selection</td>
<td>Missingness patterns and auxiliary variables</td>
<td>Explicit missingness model and MNAR sensitivity analysis</td>
</tr>
<tr class="odd">
<td>Top-hit replication</td>
<td>Winner-corrected effect and prospective power</td>
<td>Plan from a defensible external effect or conservative range</td>
</tr>
</tbody>
</table>
<p>Compare target-population and selected-sample covariates when external data exist. Vary plausible selection odds or bias parameters and find the tipping point at which the scientific conclusion changes. A funnel plot or discovery–replication contrast can reveal patterns compatible with selection, but neither uniquely identifies its cause.</p>
</section>
<section id="bioinformatics-design-and-interpretation" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Bioinformatics Design and Interpretation</h1>
<p>In a genome-wide association study, people are the experimental units and genotypes are predictors measured on those people. Millions of variants are hypotheses, not replicates. Selecting variants with <img src="https://latex.codecogs.com/png.latex?p%3C5%5Ctimes10%5E%7B-8%7D"> and quoting their discovery odds ratios without adjustment invites winner’s-curse inflation. Replication planning should use corrected, external, or conservatively specified effects and should preserve the ancestry and phenotype definitions relevant to the target population.</p>
<p>In single-cell analysis, donors or independently randomized biological samples—not cells, droplets, reads, or genes—are normally the experimental units for condition-level inference. Filtering cells using a variable affected by both biological condition and cell state can change cell composition and induce selection. Differential-expression screening followed by pathway estimation in the same data also makes pathway summaries conditional on selection.</p>
<p>Statistically, a selected estimate describes the selected-data mechanism unless assumptions transport it to a wider population. Biologically, replication also asks whether the mechanism generalizes across cohorts, tissues, protocols, and laboratories. Correcting sampling bias does not guarantee biological transportability.</p>
</section>
<section id="common-misinterpretations" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Common Misinterpretations</h1>
<ul>
<li><strong>“A representative-looking sample cannot be selected.”</strong> Balance on observed variables does not rule out selection through unobserved variables or their joint effects.</li>
<li><strong>“Only the p-value is selected; the effect estimate remains unbiased.”</strong> The p-value and effect are functions of the same noisy data.</li>
<li><strong>“A smaller replication estimate disproves the original mechanism.”</strong> Regression to the mean is expected, although heterogeneity and bias must also be assessed.</li>
<li><strong>“More cells solve selection bias.”</strong> Technical observations cannot replace independent biological sampling.</li>
<li><strong>“Cross-validation removes winner’s curse.”</strong> Cross-validation can estimate predictive performance if all selection is nested within folds; it does not automatically debias a reported scientific coefficient.</li>
<li><strong>“One adjustment fixes all selection.”</strong> Weighting, imputation, shrinkage, and selective likelihood target different mechanisms and require different assumptions.</li>
</ul>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/statistical-inference/populations-samples-parameters-and-estimands.html">Populations, samples, parameters, and estimands</a> defines the population to which a selected sample is meant to refer.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/point-estimators-bias-variance-and-mean-squared-error.html">Point estimators: bias, variance, and mean squared error</a> provides the unconditional and conditional bias language.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-power-and-sample-size-calculation.html">Statistical power and sample-size calculation</a> explains why low-information discoveries have severe exaggeration and why naive effects underpower replication.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/benjamini-hochberg-and-storey-q-values.html">Multiple-testing procedures</a> control error rates for selected hypotheses but do not automatically provide unbiased effect estimates.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/sensitivity-analysis-and-robustness.html">Sensitivity analysis and robustness</a> supplies a framework for uncertain selection mechanisms.</li>
</ul>
<p>Selection changes the distribution under analysis. The winner’s curse follows when noisy estimates are retained because they are extreme, making unbiased unselected estimators biased after discovery. State the estimand and every material selection rule, preserve the experimental unit, separate discovery from estimation when possible, and treat post-selection correction as assumption-dependent rather than automatic.</p>
</section>
<section id="references" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> References</h1>
<ul>
<li>Hernán, M. A., Hernández-Díaz, S., and Robins, J. M. “A Structural Approach to Selection Bias.” <em>Epidemiology</em> 15 (2004): 615–625. <a href="https://doi.org/10.1097/01.ede.0000135174.63482.43">Article</a>.</li>
<li>Ioannidis, J. P. A. “Why Most Discovered True Associations Are Inflated.” <em>Epidemiology</em> 19 (2008): 640–648. <a href="https://doi.org/10.1097/EDE.0b013e31818131e7">Article</a>.</li>
<li>Xiao, R. and Boehnke, M. “Quantifying and Correcting for the Winner’s Curse in Genetic Association Studies.” <em>Genetic Epidemiology</em> 33 (2009): 453–462. <a href="https://doi.org/10.1002/gepi.20398">Article</a>.</li>
<li>Ferguson, J. P., Cho, J. H., Yang, C., and Zhao, H. “Empirical Bayes Correction for the Winner’s Curse in Genetic Association Studies.” <em>Genetic Epidemiology</em> 37 (2013): 60–68. <a href="https://doi.org/10.1002/gepi.21683">Article</a>.</li>
<li>Taylor, J. and Tibshirani, R. J. “Statistical Learning and Selective Inference.” <em>Proceedings of the National Academy of Sciences</em> 112 (2015): 7629–7634. <a href="https://doi.org/10.1073/pnas.1507583112">Article</a>.</li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Inference</category>
  <category>Selection Bias</category>
  <category>Winner&#39;s Curse</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/statistical-inference/selection-bias-and-winners-curse.html</guid>
  <pubDate>Thu, 08 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Monte Carlo Estimation and Uncertainty</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/statistical-inference/monte-carlo-estimation-and-uncertainty.html</link>
  <description><![CDATA[ 





<section id="simulation-turns-expectations-into-averages" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Simulation Turns Expectations into Averages</h1>
<p>Many statistical targets can be written as an expectation</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmu=%5Coperatorname%20E_p%5C%7Bh(X)%5C%7D=%5Cint%20h(x)p(x)%5C,dx,%0A"></p>
<p>even when the integral is analytically unavailable. If <img src="https://latex.codecogs.com/png.latex?X_1,%5Cldots,X_M"> are independent draws from <img src="https://latex.codecogs.com/png.latex?p">, the basic Monte Carlo estimator is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%5Chat%5Cmu_M=%5Cfrac1M%5Csum_%7Bm=1%7D%5EM%20h(X_m).%7D%0A"></p>
<p>Provided <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%20E_p%7Ch(X)%7C%3C%5Cinfty">, the law of large numbers gives <img src="https://latex.codecogs.com/png.latex?%5Chat%5Cmu_M%5Cto%5Cmu"> almost surely. If <img src="https://latex.codecogs.com/png.latex?%5Csigma_h%5E2=%5Coperatorname%7BVar%7D_p%5C%7Bh(X)%5C%7D%3C%5Cinfty">, then</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Csqrt%20M(%5Chat%5Cmu_M-%5Cmu)%5Cxrightarrow%7Bd%7DN(0,%5Csigma_h%5E2),%0A%5Cqquad%0A%5Coperatorname%7BSE%7D_%7B%5Cmathrm%7BMC%7D%7D(%5Chat%5Cmu_M)%5Capprox%5Cfrac%7Bs_h%7D%7B%5Csqrt%20M%7D,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?s_h%5E2"> is the sample variance of the simulated <img src="https://latex.codecogs.com/png.latex?h(X_m)"> values. The <img src="https://latex.codecogs.com/png.latex?M%5E%7B-1/2%7D"> rate is universal for ordinary independent Monte Carlo: gaining one extra decimal digit usually costs about 100 times as many draws.</p>
<p>The quantity <img src="https://latex.codecogs.com/png.latex?%5Cmu"> is the <strong>computational estimand</strong>, <img src="https://latex.codecogs.com/png.latex?%5Chat%5Cmu_M"> is the estimator, its realized value is the estimate, and <img src="https://latex.codecogs.com/png.latex?%5Coperatorname%7BSE%7D_%7B%5Cmathrm%7BMC%7D%7D"> measures uncertainty caused only by finite simulation. It is not the standard error arising from finite biological sampling.</p>
</section>
<section id="a-bernoulli-example" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> A Bernoulli Example</h1>
<p>Suppose a fitted model implies that an event <img src="https://latex.codecogs.com/png.latex?A"> has probability <img src="https://latex.codecogs.com/png.latex?p=P(A)">. Set <img src="https://latex.codecogs.com/png.latex?h(X)=%5Cmathbf%201%5C%7BX%5Cin%20A%5C%7D">. Then</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%20p_M=%5Cfrac1M%5Csum_%7Bm=1%7D%5EM%5Cmathbf%201%5C%7BX_m%5Cin%20A%5C%7D,%0A%5Cqquad%0A%5Coperatorname%7BSE%7D_%7B%5Cmathrm%7BMC%7D%7D(%5Chat%20p_M)%0A%5Capprox%5Csqrt%7B%5Cfrac%7B%5Chat%20p_M(1-%5Chat%20p_M)%7D%7BM%7D%7D.%0A"></p>
<p>If 2,438 of <img src="https://latex.codecogs.com/png.latex?M=10%7B,%7D000"> simulated datasets meet the event, <img src="https://latex.codecogs.com/png.latex?%5Chat%20p=0.2438"> and the estimated Monte Carlo standard error is about <img src="https://latex.codecogs.com/png.latex?0.00429">. A simulation-only 95% interval is approximately <img src="https://latex.codecogs.com/png.latex?0.2438%5Cpm1.96(0.00429)">, or <img src="https://latex.codecogs.com/png.latex?(0.2354,0.2522)">. This interval describes numerical uncertainty in estimating the model-implied probability. It does not account for whether the fitted model or its estimated parameters are correct.</p>
<p>For a rare probability, observing zero events does not prove the probability is zero and makes the plug-in standard error zero. Exact binomial limits, importance sampling, or a much larger targeted simulation are preferable.</p>
</section>
<section id="three-layers-of-uncertainty" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Three Layers of Uncertainty</h1>
<p>Monte Carlo appears inside bootstrap, permutation, posterior, power, and missing-data procedures. The layers must be kept distinct.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Layer</th>
<th>Repeated object</th>
<th>Example uncertainty</th>
<th>Reduced by</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Scientific sampling</td>
<td>New independent experimental units from the target population or design</td>
<td>Standard error of a treatment effect</td>
<td>More informative biological units or a better design</td>
</tr>
<tr class="even">
<td>Model or assumption</td>
<td>Alternative plausible data-generating mechanisms</td>
<td>Bias from unmeasured confounding or model misspecification</td>
<td>Better measurement, design, and sensitivity analysis</td>
</tr>
<tr class="odd">
<td>Monte Carlo</td>
<td>New random-number streams under the same fitted procedure</td>
<td>Variation of a simulated p-value or posterior mean</td>
<td>More efficient or more numerous valid draws</td>
</tr>
</tbody>
</table>
<p>Increasing <img src="https://latex.codecogs.com/png.latex?M"> attacks only the third layer. Ten million simulations from the wrong model estimate the wrong target very precisely.</p>
<p>For nested procedures, conditional and unconditional targets also differ. A parametric-bootstrap Monte Carlo error conditional on the fitted parameters is not the sampling uncertainty of the original estimator. Repeating multiple imputation more times reduces finite-imputation noise but cannot make an implausible missingness model credible.</p>
</section>
<section id="dependent-draws-and-effective-sample-size" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Dependent Draws and Effective Sample Size</h1>
<p>Markov chain Monte Carlo draws are dependent. For a stationary chain with autocorrelations <img src="https://latex.codecogs.com/png.latex?%5Crho_k"> for <img src="https://latex.codecogs.com/png.latex?h(X_m)">, the asymptotic variance of the mean is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BVar%7D(%5Chat%5Cmu_M)%0A%5Capprox%0A%5Cfrac%7B%5Csigma_h%5E2%7D%7BM%7D%0A%5Cleft(1+2%5Csum_%7Bk=1%7D%5E%7B%5Cinfty%7D%5Crho_k%5Cright)%0A=%5Cfrac%7B%5Csigma_h%5E2%5Ctau%7D%7BM%7D.%0A"></p>
<p>The integrated autocorrelation time <img src="https://latex.codecogs.com/png.latex?%5Ctau"> motivates</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AM_%7B%5Cmathrm%7Beff%7D%7D=%5Cfrac%7BM%7D%7B%5Ctau%7D,%0A%5Cqquad%0A%5Coperatorname%7BSE%7D_%7B%5Cmathrm%7BMC%7D%7D(%5Chat%5Cmu_M)%0A%5Capprox%5Cfrac%7B%5Csigma_h%7D%7B%5Csqrt%7BM_%7B%5Cmathrm%7Beff%7D%7D%7D%7D.%0A"></p>
<p>Treating correlated draws as independent usually understates error. Batch-means and spectral-variance estimators estimate the long-run variance rather than the ordinary marginal variance. Effective sample size is function-specific: a chain can estimate one posterior mean well while poorly exploring a tail probability. Convergence diagnostics assess evidence of failure; they do not certify that all important modes have been visited.</p>
</section>
<section id="precision-planning-and-stopping" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Precision Planning and Stopping</h1>
<p>Simulation effort should be chosen from the required numerical precision. For independent draws, a target Monte Carlo standard error <img src="https://latex.codecogs.com/png.latex?%5Cepsilon"> suggests</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AM%5Cgtrsim%5Cfrac%7B%5Csigma_h%5E2%7D%7B%5Cepsilon%5E2%7D.%0A"></p>
<p>Because <img src="https://latex.codecogs.com/png.latex?%5Csigma_h"> is unknown, run a pilot, estimate it, calculate the additional effort, and re-estimate precision. A sequential rule should be specified before looking for a favorable answer. Examples include stopping when a valid confidence-sequence width is below a tolerance or when an estimated Monte Carlo standard error is small relative to the reported scientific standard error.</p>
<p>Threshold decisions require special care. If a Monte Carlo p-value is near <img src="https://latex.codecogs.com/png.latex?0.05">, it is not enough to print more digits. Increase <img src="https://latex.codecogs.com/png.latex?M"> until simulation uncertainty is negligible for the scientific decision, or report that the finite simulation does not resolve the threshold. For <img src="https://latex.codecogs.com/png.latex?B"> randomly sampled null transformations, the valid correction</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%20p=%5Cfrac%7B1+K%7D%7BB+1%7D%0A"></p>
<p>prevents zero p-values, where <img src="https://latex.codecogs.com/png.latex?K"> simulated statistics are at least as extreme as the observed statistic.</p>
</section>
<section id="variance-reduction" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Variance Reduction</h1>
<p>More computation is not the only route to precision.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Method</th>
<th>Central idea</th>
<th>Main requirement</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Antithetic variables</td>
<td>Pair negatively associated draws</td>
<td>A construction that preserves the target distribution</td>
</tr>
<tr class="even">
<td>Control variates</td>
<td>Subtract a correlated quantity with known expectation</td>
<td>Correct known expectation and stable coefficient estimation</td>
</tr>
<tr class="odd">
<td>Importance sampling</td>
<td>Draw from <img src="https://latex.codecogs.com/png.latex?q"> and weight by <img src="https://latex.codecogs.com/png.latex?p/q"></td>
<td><img src="https://latex.codecogs.com/png.latex?q%3E0"> wherever the target contribution is nonzero; manageable weights</td>
</tr>
<tr class="even">
<td>Stratification</td>
<td>Allocate draws across important regions</td>
<td>Known stratum probabilities and appropriate allocation</td>
</tr>
<tr class="odd">
<td>Common random numbers</td>
<td>Reuse random streams when comparing procedures</td>
<td>Interest in a difference, with induced positive correlation</td>
</tr>
<tr class="even">
<td>Quasi-Monte Carlo</td>
<td>Use low-discrepancy deterministic point sets</td>
<td>A suitable transformation and uncertainty assessment by randomization</td>
</tr>
</tbody>
</table>
<p>For importance sampling,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cmu=%5Coperatorname%20E_q%5Cleft%5Bh(X)%5Cfrac%7Bp(X)%7D%7Bq(X)%7D%5Cright%5D.%0A"></p>
<p>The identity is exact, but a few enormous weights can produce an unstable finite estimate or even infinite variance. Weight distributions, repeated runs, and effective sample size are diagnostics—not substitutes for checking support and moment conditions.</p>
</section>
<section id="reproducible-implementation" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Reproducible Implementation</h1>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20261007</span>)</span>
<span id="cb1-2">M <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">100000</span>L</span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Estimate P(Z &gt; 2) for Z ~ N(0, 1)</span></span>
<span id="cb1-5">hit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rnorm</span>(M) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span></span>
<span id="cb1-6">p_hat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(hit)</span>
<span id="cb1-7">mcse <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sqrt</span>(p_hat <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> p_hat) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> M)</span>
<span id="cb1-8"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">estimate =</span> p_hat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mcse =</span> mcse)</span></code></pre></div></div>
<p>A reproducible analysis records the pseudo-random-number generator, seed or stream-management scheme, software versions, number of draws, discarded draws if any, estimator, variance estimator, and stopping rule. Parallel simulations need independent, non-overlapping streams; calling the same seed separately on every worker can duplicate output. Reproducibility means another analyst can regenerate the calculation, not that one lucky seed should be preserved without checking Monte Carlo error.</p>
</section>
<section id="bioinformatics-applications" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Bioinformatics Applications</h1>
<p>Monte Carlo computation is common in gene-set tests, permutation calibration, sequencing-depth simulations, posterior summaries, power studies, and parametric bootstrap checks. In a differential-expression power simulation, the biological specimen remains the experimental unit. Simulating thousands of reads or cells within each of three specimens does not create thousands of independent biological replicates.</p>
<p>A useful study separates two axes:</p>
<ol type="1">
<li>vary the scientific data-generating conditions, such as effect size, dispersion, batch imbalance, dropout, and number of biological replicates;</li>
<li>within each condition, use enough Monte Carlo replicates to estimate power, false-positive rate, or interval coverage to a stated numerical precision.</li>
</ol>
<p>Statistically, simulation can estimate operating characteristics under a specified mechanism. Biologically, it cannot show that the mechanism resembles a new organism, tissue, protocol, or laboratory. Calibrate inputs from defensible data, explore plausible alternatives, and interpret conclusions conditional on those scenarios.</p>
</section>
<section id="failure-modes-and-checks" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Failure Modes and Checks</h1>
<ul>
<li><strong>No Monte Carlo error reported:</strong> another seed could materially change the last digits or even a threshold decision.</li>
<li><strong>Ordinary standard error for dependent draws:</strong> autocorrelation is ignored; use a long-run variance estimator.</li>
<li><strong>Too few tail events:</strong> naive Monte Carlo cannot resolve an extreme probability.</li>
<li><strong>Numerical precision confused with scientific precision:</strong> larger <img src="https://latex.codecogs.com/png.latex?M"> does not add experimental units or remove model bias.</li>
<li><strong>Adaptive stopping for significance:</strong> repeatedly simulate until a p-value crosses a threshold without valid sequential calibration.</li>
<li><strong>Invalid simulation mechanism:</strong> omitted dependence, selection, batch structure, or parameter uncertainty makes the computational target scientifically irrelevant.</li>
<li><strong>Single performance number:</strong> average power or error hides sensitivity to effect heterogeneity and nuisance parameters.</li>
</ul>
<p>Independent repeated runs, trace and autocorrelation plots for chains, batch estimates, weight diagnostics, and comparison with analytically solvable special cases help reveal computational problems. Simulation-based calibration can check an inferential algorithm under draws from its own assumed model, but success is conditional on that model.</p>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/probability-randomness/expectation-variance-and-moments.html">Expectation, variance, and moments</a> supplies the expectation and variance identities behind Monte Carlo averages.</li>
<li><a href="../../../knowledge/statistics/asymptotic-thinking/law-of-large-numbers.html">Law of large numbers</a> explains consistency, while the <a href="../../../knowledge/statistics/asymptotic-thinking/central-limit-theorem.html">central limit theorem</a> supports standard errors.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/standard-errors.html">Standard errors</a> distinguishes estimator variability from a realized error.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/parametric-bootstrap.html">Parametric bootstrap</a>, <a href="../../../knowledge/statistics/statistical-inference/nonparametric-bootstrap.html">nonparametric bootstrap</a>, and <a href="../../../knowledge/statistics/statistical-inference/permutation-and-randomization-tests.html">permutation and randomization tests</a> use simulation for different reference distributions.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-power-and-sample-size-calculation.html">Statistical power and sample-size calculation</a> uses Monte Carlo when analytic operating characteristics are unavailable.</li>
</ul>
<p>Monte Carlo estimation converts an expectation into an average, and its error must be estimated like any other sampling error. Dependence, heavy tails, rare events, and unstable weights can invalidate the familiar <img src="https://latex.codecogs.com/png.latex?s/%5Csqrt%20M"> calculation. Report simulation precision separately from scientific uncertainty, plan <img src="https://latex.codecogs.com/png.latex?M"> around a meaningful tolerance, and use sensitivity analysis to examine the assumptions that extra simulation cannot repair.</p>
</section>
<section id="references" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> References</h1>
<ul>
<li>Robert, C. P. and Casella, G. <em>Monte Carlo Statistical Methods</em>, 2nd ed.&nbsp;Springer, 2004. <a href="https://doi.org/10.1007/978-1-4757-4145-2">Publisher page</a>.</li>
<li>Owen, A. B. <em>Monte Carlo Theory, Methods and Examples</em>. 2013. <a href="https://artowen.su.domains/mc/">Online book</a>.</li>
<li>Flegal, J. M. and Jones, G. L. “Batch Means and Spectral Variance Estimators in Markov Chain Monte Carlo.” <em>The Annals of Statistics</em> 38 (2010): 1034–1070. <a href="https://doi.org/10.1214/09-AOS735">Article</a>.</li>
<li>Phipson, B. and Smyth, G. K. “Permutation P-values Should Never Be Zero: Calculating Exact P-values When Permutations Are Randomly Drawn.” <em>Statistical Applications in Genetics and Molecular Biology</em> 9 (2010), Article 39. <a href="https://doi.org/10.2202/1544-6115.1585">Article</a>.</li>
<li>R Core Team. “Random Number Generation.” <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/base/html/Random.html">Documentation</a>.</li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Inference</category>
  <category>Monte Carlo</category>
  <category>Simulation</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/statistical-inference/monte-carlo-estimation-and-uncertainty.html</guid>
  <pubDate>Wed, 07 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Sensitivity Analysis and Robustness</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/statistical-inference/sensitivity-analysis-and-robustness.html</link>
  <description><![CDATA[ 





<section id="robust-conclusions-survive-relevant-perturbations" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Robust Conclusions Survive Relevant Perturbations</h1>
<p>Every analysis combines data with choices and assumptions: the experimental unit, inclusion rule, outcome definition, adjustment set, missing-data model, likelihood, prior, transformation, and decision threshold. A sensitivity analysis changes one or more uncertain inputs and recomputes the inferential target.</p>
<p>Let <img src="https://latex.codecogs.com/png.latex?%5Chat%5Ctheta(a)"> be an estimate under analysis specification <img src="https://latex.codecogs.com/png.latex?a%5Cin%5Cmathcal%20A">. The useful object is not merely a list of estimates but a <strong>sensitivity map</strong></p>
<p><img src="https://latex.codecogs.com/png.latex?%0Aa%5Clongmapsto%0A%5Cleft%5C%7B%5Chat%5Ctheta(a),%5C%20%5Coperatorname%7BSE%7D_a,%5C%20I_a,%5C%20D_a%5Cright%5C%7D,%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?I_a"> is an interval and <img src="https://latex.codecogs.com/png.latex?D_a"> is a decision or scientific conclusion. A conclusion is robust over <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%20A"> if the scientifically relevant interpretation remains stable for defensible specifications. It is sensitive when plausible alternatives materially change the effect magnitude, direction, interval, prediction, or decision.</p>
<p>Robustness is always relative to a perturbation set and a target. “The result is robust” is incomplete unless it says robust to what, over what range, and by what criterion.</p>
</section>
<section id="robust-estimation-is-not-sensitivity-analysis" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Robust Estimation Is Not Sensitivity Analysis</h1>
<p>The terms overlap but answer different questions.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Concept</th>
<th>Question</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Robust estimator</td>
<td>Does an estimator retain acceptable behavior under a neighborhood of data distributions?</td>
<td>Median versus mean under contamination</td>
</tr>
<tr class="even">
<td>Diagnostic</td>
<td>Does the observed dataset reveal tension with an assumption?</td>
<td>Residual plot or influence measure</td>
</tr>
<tr class="odd">
<td>Sensitivity analysis</td>
<td>How would the result change under explicit alternative assumptions or bias parameters?</td>
<td>Vary an unmeasured-confounding strength</td>
</tr>
<tr class="even">
<td>Specification curve or multiverse</td>
<td>How do defensible analytical choices affect results?</td>
<td>Alternative inclusion rules and covariate sets</td>
</tr>
<tr class="odd">
<td>Stability analysis</td>
<td>Would small perturbations of data or fitting change the output?</td>
<td>Refit after leaving out influential specimens</td>
</tr>
</tbody>
</table>
<p>A robust standard error changes the estimated variance under heteroskedasticity; it does not make a biased causal estimand unbiased. A robust regression estimator can limit the influence of extreme observations; it does not repair confounding or selection. Conversely, a sensitivity analysis may deliberately use a conventional estimator while varying assumptions that the data cannot test.</p>
</section>
<section id="start-with-the-estimand-and-the-threat" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Start with the Estimand and the Threat</h1>
<p>Before changing code, state the scientific estimand. For example,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ctheta=%5Coperatorname%20E%5C%7BY(1)-Y(0)%5C%7D%0A"></p>
<p>is a population average causal effect, whereas a sample mean difference is only an estimator under a design and identification assumptions. Sensitivity should target the assumption that links the observed data to <img src="https://latex.codecogs.com/png.latex?%5Ctheta">, not arbitrary cosmetic choices.</p>
<p>A disciplined workflow is:</p>
<ol type="1">
<li><strong>Name the estimand and decision.</strong> Specify the effect scale and the smallest scientifically important difference.</li>
<li><strong>Draw the data-generating process.</strong> Identify sampling, treatment assignment, measurement, missingness, dependence, and selection.</li>
<li><strong>List nonidentified assumptions.</strong> Prioritize assumptions that the observed data cannot verify.</li>
<li><strong>Parameterize deviations.</strong> Use interpretable bias parameters or bounded alternative models.</li>
<li><strong>Choose plausible ranges before seeing favorable results.</strong> Justify them with design knowledge, validation data, negative controls, or external studies.</li>
<li><strong>Recompute estimates and uncertainty.</strong> Preserve dependence and repeat the complete analysis pipeline.</li>
<li><strong>Find tipping points.</strong> Report how strong a departure must be to change a scientific conclusion.</li>
</ol>
<p>This process distinguishes <strong>uncertainty analysis</strong>, which propagates a probability model for uncertain inputs, from <strong>sensitivity analysis</strong>, which maps outcomes over specified alternatives. Assigning a probability distribution to an unidentified bias parameter is an additional assumption, not an automatic fact.</p>
</section>
<section id="local-and-global-sensitivity" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Local and Global Sensitivity</h1>
<p>Suppose an analysis result is <img src="https://latex.codecogs.com/png.latex?T(%5Ceta)">, where <img src="https://latex.codecogs.com/png.latex?%5Ceta"> is a nuisance or bias parameter. A local sensitivity measure is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AS_j(%5Ceta_0)=%0A%5Cleft.%5Cfrac%7B%5Cpartial%20T(%5Ceta)%7D%7B%5Cpartial%5Ceta_j%7D%5Cright%7C_%7B%5Ceta=%5Ceta_0%7D.%0A"></p>
<p>It describes an infinitesimal change near the baseline <img src="https://latex.codecogs.com/png.latex?%5Ceta_0"> and can be computationally efficient. It may miss nonlinearities, thresholds, interactions, or distant but plausible alternatives.</p>
<p>Global sensitivity evaluates <img src="https://latex.codecogs.com/png.latex?T(%5Ceta)"> over a region <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%20H">. One-at-a-time changes are easy to explain but cannot expose interacting assumptions. A grid, factorial design, or carefully sampled parameter region can show joint departures. The region must remain scientifically coherent: not every mathematical combination corresponds to a possible study.</p>
<p>Useful summaries include:</p>
<ul>
<li>the range of point estimates and interval endpoints;</li>
<li>the fraction of prespecified specifications supporting each conclusion;</li>
<li>the boundary at which effect direction, practical importance, or interval compatibility changes;</li>
<li>worst-case bounds under explicit constraints;</li>
<li>a graph retaining the full relationship rather than only the most favorable analysis.</li>
</ul>
</section>
<section id="quantitative-bias-analysis" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Quantitative Bias Analysis</h1>
<p>Standard intervals usually condition on measured data and a statistical model; they do not automatically include bias from unmeasured confounding, selection, or misclassification. Quantitative bias analysis introduces parameters for those mechanisms.</p>
<p>For a binary exposure and outcome, a simple confounding bias factor can be written</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AB=%0A%5Cfrac%7BRR_%7BUY%7DRR_%7BEU%7D%7D%0A%7BRR_%7BUY%7D+RR_%7BEU%7D-1%7D,%0A"></p>
<p>under a particular bounding setup, where <img src="https://latex.codecogs.com/png.latex?RR_%7BUY%7D"> bounds the confounder–outcome risk-ratio association and <img src="https://latex.codecogs.com/png.latex?RR_%7BEU%7D"> bounds the exposure–confounder association. A corrected observed risk ratio can be explored as <img src="https://latex.codecogs.com/png.latex?RR_%7B%5Cmathrm%7Bobs%7D%7D/B">. The formula is useful only when its definitions and structural conditions fit the problem.</p>
<p>For linear regression, omitted-variable sensitivity can be expressed through partial <img src="https://latex.codecogs.com/png.latex?R%5E2"> values describing the association of an unobserved confounder with treatment and outcome after measured covariates. Benchmarking these strengths against observed covariates makes a tipping point interpretable, but an observed covariate is not automatically an upper bound for an unobserved one.</p>
<p>The E-value is another bound for risk-ratio effects: for <img src="https://latex.codecogs.com/png.latex?RR%5Cgeq1">,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AE%5Ctext%7B-value%7D=RR+%5Csqrt%7BRR(RR-1)%7D.%0A"></p>
<p>It describes a minimum joint association strength that an unmeasured confounder would need, on the risk-ratio scale under stated conditions, to explain away an association. It does not address selection bias, measurement error, multiple biases acting together, or the plausibility of such a confounder. A single scalar should not replace a mechanism-specific analysis.</p>
</section>
<section id="a-tipping-point-example" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> A Tipping-point Example</h1>
<p>Suppose the primary estimate is a log fold change of <img src="https://latex.codecogs.com/png.latex?0.60">, and domain experts regard <img src="https://latex.codecogs.com/png.latex?0.20"> as the smallest biologically important magnitude. Let <img src="https://latex.codecogs.com/png.latex?b"> denote additive bias on the log scale, so the bias-adjusted effect is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ctheta(b)=0.60-b.%0A"></p>
<p>The sign changes at <img src="https://latex.codecogs.com/png.latex?b=0.60">, while practical importance is lost at <img src="https://latex.codecogs.com/png.latex?b=0.40">. Reporting both thresholds is more informative than saying that several alternative models remained “significant.” A defensible analysis then asks whether batch imbalance, selection, normalization, or measurement error could plausibly produce bias of those sizes.</p>
<p>Uncertainty should also be updated when the bias correction is estimated rather than fixed. Treating an uncertain correction as known can move the point estimate while leaving intervals implausibly narrow.</p>
</section>
<section id="model-data-and-workflow-perturbations" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Model, Data, and Workflow Perturbations</h1>
<p>Sensitivity domains should follow the actual failure mechanisms.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Domain</th>
<th>Examples of planned perturbations</th>
<th>What stability would support</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Sampling and inclusion</td>
<td>Eligibility windows, influential units, selection weights</td>
<td>Results not driven by a narrow inclusion decision</td>
</tr>
<tr class="even">
<td>Measurement</td>
<td>Misclassification rates, detection limits, alternative outcome definitions</td>
<td>Conclusions tolerate plausible measurement error</td>
</tr>
<tr class="odd">
<td>Missing data</td>
<td>Complete case, multiple models under MAR, delta adjustments under MNAR</td>
<td>Dependence on unverifiable missingness assumptions is visible</td>
</tr>
<tr class="even">
<td>Functional form</td>
<td>Transformations, splines, interactions, link functions</td>
<td>Effect not created by a restrictive shape</td>
</tr>
<tr class="odd">
<td>Dependence</td>
<td>Cluster level, correlation structure, block definition</td>
<td>Uncertainty respects the experimental unit</td>
</tr>
<tr class="even">
<td>Causal adjustment</td>
<td>Alternative defensible adjustment sets, unmeasured-confounding parameters</td>
<td>Identification claim is transparent</td>
</tr>
<tr class="odd">
<td>Bayesian specification</td>
<td>Prior scales, likelihood tails, hierarchical structure</td>
<td>Posterior conclusion is not an artifact of one prior/model</td>
</tr>
<tr class="even">
<td>Multiplicity and selection</td>
<td>Full hypothesis family, filtering rules, selective-analysis scenarios</td>
<td>Error claims match the actual search process</td>
</tr>
</tbody>
</table>
<p>Perturbations should be <strong>defensible alternatives</strong>, not every possible model and not a search for the desired answer. If several pipelines answer different estimands, their disagreement is not mere instability; the targets must first be separated.</p>
</section>
<section id="specification-curves-without-vote-counting" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Specification Curves Without Vote Counting</h1>
<p>A multiverse analysis runs many reasonable specifications. Its value is transparency about analyst choices, but naive summaries can mislead. Specifications are dependent, may encode contradictory estimands, and are rarely sampled uniformly from a well-defined population of analyses. Counting how many p-values fall below <img src="https://latex.codecogs.com/png.latex?0.05"> is therefore not a calibrated probability that a claim is true.</p>
<p>Organize specifications by the assumptions they represent, display effect estimates and intervals, and mark the prespecified primary analysis. If an analytical choice is influenced by the observed results, ordinary intervals and p-values do not account for that selection. Sensitivity displays reveal dependence on choices; they do not automatically solve selective inference.</p>
</section>
<section id="bioinformatics-design-and-interpretation" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Bioinformatics Design and Interpretation</h1>
<p>Consider an RNA-seq comparison with six donors per group, two sequencing lanes, and thousands of genes. Donors are biological experimental units; lanes and reads are technical observations. Useful sensitivity analyses might vary:</p>
<ul>
<li>whether lane or extraction batch is included in the design;</li>
<li>defensible filtering thresholds fixed without using treatment labels;</li>
<li>normalization strategy when composition bias is plausible;</li>
<li>dispersion or prior-shrinkage settings;</li>
<li>donor-level quality exclusions using prespecified criteria;</li>
<li>hidden-factor adjustment while guarding against removal of biological signal;</li>
<li>effect-size thresholds and false-discovery procedures.</li>
</ul>
<p>Refitting after dropping individual cells or reads is not a meaningful independence check. A leave-one-donor-out analysis can reveal influence, but with a small sample it may also change balance and the estimand. Batch correction performed before cross-validation can leak information, and an alternative correction may change both signal and uncertainty.</p>
<p>Statistical robustness means that a result is stable over justified analysis and bias scenarios. Biological robustness additionally asks whether the magnitude, pathway interpretation, and generalization persist across tissues, cohorts, protocols, and laboratories. Neither is established by repeatedly analyzing the same specimens until a preferred method agrees.</p>
</section>
<section id="reporting-a-sensitivity-analysis" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> Reporting a Sensitivity Analysis</h1>
<p>A useful report states:</p>
<ul>
<li>the primary estimand, analysis, and scientific decision criterion;</li>
<li>each threatened assumption and why the observed data cannot settle it;</li>
<li>the alternative models or bias parameters and the rationale for their ranges;</li>
<li>which elements were prespecified;</li>
<li>estimates and compatible intervals on a scientifically interpretable scale;</li>
<li>tipping points and whether they are plausible;</li>
<li>cases where the analysis changes the target population or estimand;</li>
<li>code and data provenance sufficient to reproduce every scenario.</li>
</ul>
<p>Do not hide sensitivity results in a supplement when they materially alter the main claim. A fragile result can still be valuable if its dependence on assumptions is stated clearly; a stable result can still be biased if the explored perturbation set missed the dominant threat.</p>
</section>
<section id="common-failure-modes" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> Common Failure Modes</h1>
<ul>
<li><strong>Changing everything at once:</strong> disagreement cannot be traced to an assumption; use structured single and joint perturbations.</li>
<li><strong>Data-driven plausible ranges:</strong> ranges are chosen after seeing which values preserve the claim.</li>
<li><strong>Only alternative p-values reported:</strong> magnitude, interval, and practical threshold are omitted.</li>
<li><strong>Robust standard errors called robust inference:</strong> variance adjustment is confused with protection from bias.</li>
<li><strong>One-at-a-time comfort:</strong> interacting departures are ignored.</li>
<li><strong>Implausible worst cases:</strong> mathematically extreme scenarios are presented without domain calibration.</li>
<li><strong>Researcher degrees of freedom ignored:</strong> a multiverse is shown as if the final specification had been chosen independently of the data.</li>
<li><strong>Pseudoreplication preserved:</strong> many technical observations make every pipeline look precise while the number of biological units stays small.</li>
</ul>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="12">
<h1 data-number="12"><span class="header-section-number">12</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/statistical-inference/populations-samples-parameters-and-estimands.html">Populations, samples, parameters, and estimands</a> anchors every perturbation to a target.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-versus-practical-significance.html">Statistical versus practical significance</a> supplies the scientific threshold for a tipping-point analysis.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/effect-sizes.html">Effect sizes</a> helps distinguish stability of magnitude from stability of a threshold decision.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/monte-carlo-estimation-and-uncertainty.html">Monte Carlo estimation and uncertainty</a> quantifies numerical error when a sensitivity grid is simulated.</li>
<li><a href="../../../knowledge/statistics/asymptotic-thinking/when-asymptotic-approximations-fail.html">When asymptotic approximations fail</a> motivates finite-sample and alternative-model checks.</li>
</ul>
<p>Sensitivity analysis asks how conclusions change when uncertain assumptions change. It should begin with the estimand and a concrete failure mechanism, use scientifically defensible ranges, propagate uncertainty, and report tipping points rather than a binary robustness label. Robustness to a narrow menu is not proof of validity; it is evidence conditional on the perturbations actually examined.</p>
</section>
<section id="references" class="level1" data-number="13">
<h1 data-number="13"><span class="header-section-number">13</span> References</h1>
<ul>
<li>Huber, P. J. <em>Robust Statistics</em>. Wiley, 1981. <a href="https://doi.org/10.1002/0471725250">Publisher page</a>.</li>
<li>Greenland, S. “Basic Methods for Sensitivity Analysis of Biases.” <em>International Journal of Epidemiology</em> 25 (1996): 1107–1116. <a href="https://doi.org/10.1093/ije/25.6.1107-a">Article</a>.</li>
<li>Rosenbaum, P. R. <em>Observational Studies</em>, 2nd ed.&nbsp;Springer, 2002. <a href="https://doi.org/10.1007/978-1-4757-3692-2">Publisher page</a>.</li>
<li>VanderWeele, T. J. and Ding, P. “Sensitivity Analysis in Observational Research: Introducing the E-value.” <em>Annals of Internal Medicine</em> 167 (2017): 268–274. <a href="https://doi.org/10.7326/M16-2607">Article</a>.</li>
<li>Cinelli, C. and Hazlett, C. “Making Sense of Sensitivity: Extending Omitted Variable Bias.” <em>Journal of the Royal Statistical Society: Series B</em> 82 (2020): 39–67. <a href="https://doi.org/10.1111/rssb.12348">Article</a>.</li>
<li>Steegen, S., Tuerlinckx, F., Gelman, A., and Vanpaemel, W. “Increasing Transparency Through a Multiverse Analysis.” <em>Perspectives on Psychological Science</em> 11 (2016): 702–712. <a href="https://doi.org/10.1177/1745691616658637">Article</a>.</li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Inference</category>
  <category>Sensitivity Analysis</category>
  <category>Robustness</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/statistical-inference/sensitivity-analysis-and-robustness.html</guid>
  <pubDate>Wed, 07 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Benjamini–Hochberg and Storey q-values</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/statistical-inference/benjamini-hochberg-and-storey-q-values.html</link>
  <description><![CDATA[ 





<section id="from-any-false-positive-to-a-false-fraction" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> From Any False Positive to a False Fraction</h1>
<p>Among <img src="https://latex.codecogs.com/png.latex?m"> tested hypotheses, let <img src="https://latex.codecogs.com/png.latex?R"> be the total number rejected and <img src="https://latex.codecogs.com/png.latex?V"> the number of rejected true null hypotheses. Define the false discovery proportion (FDP) by</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BFDP%7D=%5Cfrac%7BV%7D%7B%5Cmax(R,1)%7D%0A"></p>
<p>and the <a href="../../../knowledge/statistics/statistical-inference/false-discovery-rate.html">false discovery rate</a> by</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BFDR%7D=%5Coperatorname%7BE%7D(%5Coperatorname%7BFDP%7D).%0A"></p>
<p>The Benjamini–Hochberg (BH) procedure controls this expectation through an ordered rejection rule. Storey’s framework estimates the proportion of true null hypotheses and defines a q-value for each test. These are related ideas, but a BH-adjusted p-value and a Storey q-value are not automatically interchangeable.</p>
</section>
<section id="the-benjaminihochberg-procedure" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> The Benjamini–Hochberg Procedure</h1>
<p>Let <img src="https://latex.codecogs.com/png.latex?p_%7B(1)%7D%5Cle%5Ccdots%5Cle%20p_%7B(m)%7D"> be valid ordered p-values. For a target FDR level <img src="https://latex.codecogs.com/png.latex?q">, BH finds</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ak=%5Cmax%5Cleft%5C%7Bi:p_%7B(i)%7D%5Cle%5Cfrac%7Bi%7D%7Bm%7Dq%5Cright%5C%7D%0A"></p>
<p>and rejects <img src="https://latex.codecogs.com/png.latex?H_%7B(1)%7D,%5Cldots,H_%7B(k)%7D">. If the set is empty, it rejects none. It is a step-up procedure: one crossing at rank <img src="https://latex.codecogs.com/png.latex?k"> makes every smaller p-value a discovery, even if an earlier point lies above its own line.</p>
<p>The ordered BH-adjusted p-values are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidetilde%20p_%7B(i)%7D%5E%7B%5Cmathrm%7BBH%7D%7D%0A=%5Cmin%5Cleft%5C%7B1,%5Cmin_%7Bj%5Cge%20i%7D%5Cfrac%7Bm%7D%7Bj%7Dp_%7B(j)%7D%5Cright%5C%7D.%0A"></p>
<p>The backward cumulative minimum makes the values monotone in rank. Rejecting tests with <img src="https://latex.codecogs.com/png.latex?%5Cwidetilde%20p_i%5E%7B%5Cmathrm%7BBH%7D%7D%5Cle%20q"> reproduces the step-up rule.</p>
<p>If <img src="https://latex.codecogs.com/png.latex?m_0"> of the <img src="https://latex.codecogs.com/png.latex?m"> null hypotheses are true and their p-values are independent, classical BH satisfies</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BFDR%7D=%5Cfrac%7Bm_0%7D%7Bm%7Dq%5Cle%20q.%0A"></p>
<p>The guarantee also extends to specific positive dependence conditions. It does not hold for every possible dependence structure. The Benjamini–Yekutieli modification replaces <img src="https://latex.codecogs.com/png.latex?q"> by <img src="https://latex.codecogs.com/png.latex?q/c_m">, where</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ac_m=%5Csum_%7Bi=1%7D%5E%7Bm%7D%5Cfrac%7B1%7D%7Bi%7D,%0A"></p>
<p>to obtain FDR control under arbitrary dependence, usually at a substantial power cost.</p>
</section>
<section id="storeys-estimate-of-the-null-proportion" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Storey’s Estimate of the Null Proportion</h1>
<p>Write <img src="https://latex.codecogs.com/png.latex?%5Cpi_0=m_0/m"> for the unknown proportion of true null hypotheses. Under a continuous, correctly calibrated null, null p-values are uniform, while sufficiently large p-values are unlikely to come from strong alternatives. For a tuning value <img src="https://latex.codecogs.com/png.latex?0%3C%5Clambda%3C1">, Storey’s basic estimator is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%5Cpi_0(%5Clambda)%0A=%5Cmin%5Cleft%5C%7B1,%0A%5Cfrac%7B%5C#%5C%7Bp_i%3E%5Clambda%5C%7D%7D%7Bm(1-%5Clambda)%7D%0A%5Cright%5C%7D.%0A"></p>
<p>Using <img src="https://latex.codecogs.com/png.latex?%5Cwidehat%5Cpi_0%3C1"> can increase power because the method estimates that some tested hypotheses are non-null. In practice, relying on one arbitrary <img src="https://latex.codecogs.com/png.latex?%5Clambda"> is unstable. The <code>qvalue</code> software can estimate a smooth relationship over several <img src="https://latex.codecogs.com/png.latex?%5Clambda"> values or use a bootstrap choice, and the result should be checked for sensitivity.</p>
<p>For a p-value threshold <img src="https://latex.codecogs.com/png.latex?t">, let <img src="https://latex.codecogs.com/png.latex?R(t)=%5C#%5C%7Bp_i%5Cle%20t%5C%7D">. A plug-in estimate of the FDR at that threshold is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%7B%5Coperatorname%7BFDR%7D%7D(t)%0A=%5Cfrac%7B%5Cwidehat%5Cpi_0%20mt%7D%7B%5Cmax%5C%7BR(t),1%5C%7D%7D.%0A"></p>
<p>For ordered p-values, the corresponding monotone q-value estimate is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%20q_%7B(i)%7D%0A=%5Cmin%5Cleft%5C%7B1,%0A%5Cmin_%7Bj%5Cge%20i%7D%5Cfrac%7B%5Cwidehat%5Cpi_0%20m%20p_%7B(j)%7D%7D%7Bj%7D%0A%5Cright%5C%7D.%0A"></p>
<p>Conceptually, a Storey q-value is the smallest estimated positive false discovery rate attainable when calling that test significant through a p-value threshold. It is a property of the entire family and the estimation procedure, not a posterior probability that this particular null is true. The local false discovery rate is a different quantity.</p>
</section>
<section id="worked-example" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Worked Example</h1>
<p>Suppose eight pre-specified tests yield</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A(0.001,%5C%200.006,%5C%200.012,%5C%200.028,%5C%200.300,%5C%200.550,%5C%200.700,%5C%200.900).%0A"></p>
<p>At <img src="https://latex.codecogs.com/png.latex?q=0.05">, the first four BH boundaries are <img src="https://latex.codecogs.com/png.latex?0.00625">, <img src="https://latex.codecogs.com/png.latex?0.0125">, <img src="https://latex.codecogs.com/png.latex?0.01875">, and <img src="https://latex.codecogs.com/png.latex?0.025">. The largest crossing is rank 3 because <img src="https://latex.codecogs.com/png.latex?0.012%5Cle0.01875"> but <img src="https://latex.codecogs.com/png.latex?0.028%3E0.025"> and no later p-value crosses. BH therefore rejects the first three hypotheses.</p>
<p>With <img src="https://latex.codecogs.com/png.latex?%5Clambda=0.5">, three p-values exceed <img src="https://latex.codecogs.com/png.latex?0.5">, giving the illustrative estimate</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidehat%5Cpi_0=%5Cfrac%7B3%7D%7B8(1-0.5)%7D=0.75.%0A"></p>
<p>The first four plug-in q-values are <img src="https://latex.codecogs.com/png.latex?0.006">, <img src="https://latex.codecogs.com/png.latex?0.018">, <img src="https://latex.codecogs.com/png.latex?0.024">, and <img src="https://latex.codecogs.com/png.latex?0.042">, so the adaptive calculation would include the fourth test at 0.05. This extra discovery depends on estimating <img src="https://latex.codecogs.com/png.latex?%5Cpi_0"> well. Eight tests are far too few for a stable tail-based estimate; the calculation illustrates the mechanism, not a recommended analysis.</p>
</section>
<section id="reproducible-implementation" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Reproducible Implementation</h1>
<p>Base R computes BH- and BY-adjusted p-values. The Bioconductor <code>qvalue</code> package estimates <img src="https://latex.codecogs.com/png.latex?%5Cpi_0">, q-values, and local FDR values.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">p <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.001</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.006</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.012</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.028</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.300</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.550</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.700</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.900</span>)</span>
<span id="cb1-2"></span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">p.adjust</span>(p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BH"</span>)</span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">p.adjust</span>(p, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">method =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"BY"</span>)</span>
<span id="cb1-5"></span>
<span id="cb1-6"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># BiocManager::install("qvalue")</span></span>
<span id="cb1-7">fit <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> qvalue<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">qvalue</span>(p)</span>
<span id="cb1-8">fit<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>pi0</span>
<span id="cb1-9">fit<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>qvalues</span></code></pre></div></div>
<p>Keep the full, unrounded p-values for computation and record the package version, tuning method, and number of hypotheses. Software output does not determine which hypotheses belong in the family.</p>
</section>
<section id="assumptions-and-diagnostics" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Assumptions and Diagnostics</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Issue</th>
<th>Why it matters</th>
<th>Useful check or response</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Invalid null p-values</td>
<td>Neither BH nor q-values can repair anti-conservative tests</td>
<td>Use diagnostics, permutation, simulation, or negative controls to assess null calibration</td>
</tr>
<tr class="even">
<td>Dependence</td>
<td>Classical BH is not guaranteed under arbitrary dependence</td>
<td>Justify positive-dependence conditions, compare BY or suitable dependence-aware methods, and perform sensitivity analysis</td>
</tr>
<tr class="odd">
<td>Estimation of <img src="https://latex.codecogs.com/png.latex?%5Cpi_0"></td>
<td>Storey q-values can be unstable or anti-conservative when the p-value tail is poorly estimated</td>
<td>Plot the p-value histogram and <img src="https://latex.codecogs.com/png.latex?%5Cwidehat%5Cpi_0(%5Clambda)">; compare tuning choices and BH results</td>
</tr>
<tr class="even">
<td>Discrete p-values</td>
<td>A uniform null approximation and tail estimator may be conservative or irregular</td>
<td>Use exact/discrete-aware methods or simulation appropriate to the test</td>
</tr>
<tr class="odd">
<td>Data-dependent filtering</td>
<td>Filtering may change null p-value behavior and the effective family</td>
<td>Establish independence under the null or incorporate selection into the analysis</td>
</tr>
<tr class="even">
<td>Hidden structure</td>
<td>Batch effects, confounding, or model misspecification can create an excess of small p-values</td>
<td>Correct the design/model first; inspect genomic inflation and control features</td>
</tr>
</tbody>
</table>
<p>A flat p-value histogram is not universally expected: alternatives concentrate values near zero, discrete tests produce spikes, and correlated hypotheses create visible sampling variation. Diagnostics must be interpreted relative to the data-generating process.</p>
</section>
<section id="bioinformatics-study-design" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Bioinformatics Study Design</h1>
<p>In differential-expression or association studies, genes, peaks, taxa, or variants are the hypotheses; donors, organisms, or independently randomized samples are usually the experimental units. Cells, reads, technical wells, and sequencing lanes nested within a sample are not independent biological replicates. Pseudoreplication can make the input p-values anti-conservative, after which an FDR procedure merely adjusts invalid evidence.</p>
<p>Before testing, specify the contrast, eligible feature universe, independent-filtering rule, and analysis family. Filtering low-information features can improve power when the filter is independent of the null test statistic, but filtering on observed effects or p-values invalidates the usual interpretation. Report effect sizes and uncertainty alongside q-values: an FDR threshold ranks statistical evidence within a family and does not establish biological importance, mechanism, or reproducibility.</p>
</section>
<section id="interpretation-and-common-pitfalls" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Interpretation and Common Pitfalls</h1>
<ul>
<li><strong>FDR is an expectation over repeated studies</strong>, not a guarantee that exactly 5% of one realized discovery list is false.</li>
<li><strong>A q-value is not <img src="https://latex.codecogs.com/png.latex?%5CPr(H_i%5Ctext%7B%20is%20null%7D%5Cmid%5Ctext%7Bdata%7D)"></strong>. That individual posterior-type quantity is closer to a model-based local FDR.</li>
<li><strong>BH-adjusted p-values are often labeled q-values in software</strong>, but Storey’s q-values additionally estimate <img src="https://latex.codecogs.com/png.latex?%5Cpi_0">; state the method rather than relying on the column name.</li>
<li><strong>The largest crossing determines BH rejections</strong>. Do not stop at the first ordered p-value that misses its own boundary.</li>
<li><strong>Choosing the family after seeing results defeats prospective error control</strong>. Document all tested features and contrasts, including those not reported.</li>
<li><strong>Discovery control is not selection-bias correction</strong>. Effect estimates among selected features can still be exaggerated by winner’s curse.</li>
</ul>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/statistical-inference/null-distributions-and-p-values.html">Null distributions and p-values</a> explains the calibration required of every input p-value.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/family-wise-error-rate.html">Family-wise error rate</a> and <a href="../../../knowledge/statistics/statistical-inference/bonferroni-holm-and-hochberg-procedures.html">Bonferroni, Holm, and Hochberg procedures</a> address the stricter event of any false rejection.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/false-discovery-rate.html">False discovery rate</a> distinguishes FDP, FDR, positive FDR, and local false discovery rates.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/effect-sizes.html">Effect sizes</a> and <a href="../../../knowledge/statistics/statistical-inference/statistical-versus-practical-significance.html">statistical versus practical significance</a> keep scientific magnitude separate from a discovery threshold.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-power-and-sample-size-calculation.html">Statistical power and sample-size calculation</a> shows why the number of tests and expected signal fraction belong in study planning.</li>
</ul>
<p>BH provides a transparent step-up rule with well-defined guarantees under independence and suitable positive dependence. Storey’s method can gain power by estimating <img src="https://latex.codecogs.com/png.latex?%5Cpi_0">, but that gain makes null calibration, tuning, and sensitivity analysis more important. Neither method compensates for the wrong experimental unit or a misspecified model.</p>
</section>
<section id="references" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> References</h1>
<ul>
<li>Benjamini, Y., &amp; Hochberg, Y. (1995). Controlling the false discovery rate: A practical and powerful approach to multiple testing. <em>Journal of the Royal Statistical Society: Series B</em>, 57(1), 289–300. <a href="https://doi.org/10.1111/j.2517-6161.1995.tb02031.x">doi:10.1111/j.2517-6161.1995.tb02031.x</a>.</li>
<li>Benjamini, Y., &amp; Yekutieli, D. (2001). The control of the false discovery rate in multiple testing under dependency. <em>The Annals of Statistics</em>, 29(4), 1165–1188. <a href="https://doi.org/10.1214/aos/1013699998">doi:10.1214/aos/1013699998</a>.</li>
<li>Storey, J. D. (2002). A direct approach to false discovery rates. <em>Journal of the Royal Statistical Society: Series B</em>, 64(3), 479–498. <a href="https://doi.org/10.1111/1467-9868.00346">doi:10.1111/1467-9868.00346</a>.</li>
<li>Storey, J. D., &amp; Tibshirani, R. (2003). Statistical significance for genomewide studies. <em>Proceedings of the National Academy of Sciences</em>, 100(16), 9440–9445. <a href="https://doi.org/10.1073/pnas.1530509100">doi:10.1073/pnas.1530509100</a>.</li>
<li>Storey, J. D., Taylor, J. E., &amp; Siegmund, D. (2004). Strong control, conservative point estimation and simultaneous conservative consistency of false discovery rates: A unified approach. <em>Journal of the Royal Statistical Society: Series B</em>, 66(1), 187–205. <a href="https://doi.org/10.1111/j.1467-9868.2004.00439.x">doi:10.1111/j.1467-9868.2004.00439.x</a>.</li>
<li>R Core Team. <code>p.adjust</code>: Adjust p-values for multiple comparisons. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/p.adjust.html">R documentation</a>.</li>
<li>Storey, J. D., Bass, A. J., Dabney, A., &amp; Robinson, D. <code>qvalue</code>: Q-value estimation for false discovery rate control. <a href="https://bioconductor.org/packages/release/bioc/html/qvalue.html">Bioconductor documentation</a>.</li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Inference</category>
  <category>Multiple Testing</category>
  <category>Bioinformatics</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/statistical-inference/benjamini-hochberg-and-storey-q-values.html</guid>
  <pubDate>Tue, 06 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Bonferroni, Holm, and Hochberg Procedures</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/statistical-inference/bonferroni-holm-and-hochberg-procedures.html</link>
  <description><![CDATA[ 





<section id="one-family-three-procedures" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> One Family, Three Procedures</h1>
<p>Suppose a study tests hypotheses <img src="https://latex.codecogs.com/png.latex?H_1,%5Cldots,H_m"> with valid marginal p-values <img src="https://latex.codecogs.com/png.latex?p_1,%5Cldots,p_m">. If all <img src="https://latex.codecogs.com/png.latex?m"> tests are run at level <img src="https://latex.codecogs.com/png.latex?%5Calpha">, the chance of at least one false rejection can be much larger than <img src="https://latex.codecogs.com/png.latex?%5Calpha">. The <a href="../../../knowledge/statistics/statistical-inference/family-wise-error-rate.html">family-wise error rate</a> (FWER) is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Coperatorname%7BFWER%7D=%5CPr(V%5Cge%201),%0A"></p>
<p>where <img src="https://latex.codecogs.com/png.latex?V"> is the number of rejected true null hypotheses. Bonferroni, Holm, and Hochberg all target FWER, but they use the ordered p-values differently.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Procedure</th>
<th>Direction</th>
<th>Strong FWER guarantee</th>
<th>Relative behavior</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Bonferroni</td>
<td>Single step</td>
<td>Arbitrary dependence</td>
<td>Simple, but uniformly dominated by Holm</td>
</tr>
<tr class="even">
<td>Holm</td>
<td>Step down</td>
<td>Arbitrary dependence</td>
<td>Never rejects fewer hypotheses than Bonferroni</td>
</tr>
<tr class="odd">
<td>Hochberg</td>
<td>Step up</td>
<td>Independence or suitable positive dependence</td>
<td>Can reject more than Holm under its stronger assumptions</td>
</tr>
</tbody>
</table>
<p>The family of hypotheses and the target level <img src="https://latex.codecogs.com/png.latex?%5Calpha"> should be defined from the scientific question, not reconstructed after seeing which results look promising.</p>
</section>
<section id="bonferroni-from-the-union-bound" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Bonferroni from the Union Bound</h1>
<p>For every true null <img src="https://latex.codecogs.com/png.latex?H_i">, validity means <img src="https://latex.codecogs.com/png.latex?%5CPr(p_i%5Cle%20u)%5Cle%20u"> for <img src="https://latex.codecogs.com/png.latex?0%5Cle%20u%5Cle1">. If <img src="https://latex.codecogs.com/png.latex?I_0"> indexes the <img src="https://latex.codecogs.com/png.latex?m_0"> true nulls, the union bound gives</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cbegin%7Baligned%7D%0A%5CPr(V%5Cge1)%0A&amp;=%5CPr%5Cleft(%5Cbigcup_%7Bi%5Cin%20I_0%7D%5Cleft%5C%7Bp_i%5Cle%5Cfrac%7B%5Calpha%7D%7Bm%7D%5Cright%5C%7D%5Cright)%5C%5C%0A&amp;%5Cle%20%5Csum_%7Bi%5Cin%20I_0%7D%5CPr%5Cleft(p_i%5Cle%5Cfrac%7B%5Calpha%7D%7Bm%7D%5Cright)%5C%5C%0A&amp;%5Cle%20m_0%5Cfrac%7B%5Calpha%7D%7Bm%7D%5Cle%5Calpha.%0A%5Cend%7Baligned%7D%0A"></p>
<p>Therefore Bonferroni rejects <img src="https://latex.codecogs.com/png.latex?H_i"> when</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap_i%5Cle%5Cfrac%7B%5Calpha%7D%7Bm%7D.%0A"></p>
<p>Equivalently, its adjusted p-value is <img src="https://latex.codecogs.com/png.latex?%5Cwidetilde%20p_i=%5Cmin(1,mp_i)">. The proof makes no assumption about dependence among tests. It can nevertheless be conservative because it protects against a worst-case union of false-rejection events and uses <img src="https://latex.codecogs.com/png.latex?m">, although only <img src="https://latex.codecogs.com/png.latex?m_0"> hypotheses are truly null.</p>
</section>
<section id="holms-step-down-procedure" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Holm’s Step-down Procedure</h1>
<p>Let</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap_%7B(1)%7D%5Cle%20p_%7B(2)%7D%5Cle%5Ccdots%5Cle%20p_%7B(m)%7D%0A"></p>
<p>be the ordered p-values, with <img src="https://latex.codecogs.com/png.latex?H_%7B(i)%7D"> their corresponding hypotheses. Holm’s algorithm starts with the smallest p-value:</p>
<ol type="1">
<li>Compare <img src="https://latex.codecogs.com/png.latex?p_%7B(1)%7D"> with <img src="https://latex.codecogs.com/png.latex?%5Calpha/m">.</li>
<li>If it passes, compare <img src="https://latex.codecogs.com/png.latex?p_%7B(2)%7D"> with <img src="https://latex.codecogs.com/png.latex?%5Calpha/(m-1)">, then continue with <img src="https://latex.codecogs.com/png.latex?p_%7B(i)%7D%5Cle%5Calpha/(m-i+1)">.</li>
<li>At the first failure, stop and retain that hypothesis and every hypothesis with a larger p-value.</li>
</ol>
<p>The ordered Holm-adjusted p-values are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidetilde%20p_%7B(i)%7D%5E%7B%5Ctext%7BHolm%7D%7D%0A=%5Cmin%5Cleft%5C%7B1,%5Cmax_%7B1%5Cle%20j%5Cle%20i%7D(m-j+1)p_%7B(j)%7D%5Cright%5C%7D.%0A"></p>
<p>The running maximum preserves monotonicity: a larger raw p-value cannot receive a smaller adjusted value. Holm can be derived as a closed-testing procedure with Bonferroni local tests, which explains its strong FWER control under every configuration of true and false nulls and under arbitrary dependence. Because its first cutoff equals Bonferroni’s and later cutoffs become less stringent, Holm never rejects fewer hypotheses than Bonferroni.</p>
</section>
<section id="hochbergs-step-up-procedure" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Hochberg’s Step-up Procedure</h1>
<p>Hochberg uses the same critical values but searches from the largest p-value downward:</p>
<ol type="1">
<li><p>Find the largest index <img src="https://latex.codecogs.com/png.latex?k"> satisfying</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap_%7B(k)%7D%5Cle%5Cfrac%7B%5Calpha%7D%7Bm-k+1%7D.%0A"></p></li>
<li><p>Reject <img src="https://latex.codecogs.com/png.latex?H_%7B(1)%7D,%5Cldots,H_%7B(k)%7D">. If no such <img src="https://latex.codecogs.com/png.latex?k"> exists, reject none.</p></li>
</ol>
<p>Its ordered adjusted p-values are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cwidetilde%20p_%7B(i)%7D%5E%7B%5Ctext%7BHochberg%7D%7D%0A=%5Cmin%5Cleft%5C%7B1,%5Cmin_%7Bi%5Cle%20j%5Cle%20m%7D(m-j+1)p_%7B(j)%7D%5Cright%5C%7D.%0A"></p>
<p>Hochberg may reject several hypotheses because one later ordered p-value crosses its boundary. This gain is not free: the classical guarantee relies on independent p-values or forms of non-negative dependence that make the underlying Simes test valid. Under arbitrary or poorly understood dependence, Holm is the safer default of these three methods.</p>
</section>
<section id="worked-example" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Worked Example</h1>
<p>Consider four pre-specified hypotheses with ordered p-values</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A(0.010,%5C%200.020,%5C%200.024,%5C%200.500)%0A"></p>
<p>and <img src="https://latex.codecogs.com/png.latex?%5Calpha=0.05">.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
<col style="width: 16%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">Rank <img src="https://latex.codecogs.com/png.latex?i"></th>
<th style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?p_%7B(i)%7D"></th>
<th style="text-align: right;"><img src="https://latex.codecogs.com/png.latex?%5Calpha/(m-i+1)"></th>
<th style="text-align: right;">Bonferroni adjusted</th>
<th style="text-align: right;">Holm adjusted</th>
<th style="text-align: right;">Hochberg adjusted</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">0.010</td>
<td style="text-align: right;">0.0125</td>
<td style="text-align: right;">0.040</td>
<td style="text-align: right;">0.040</td>
<td style="text-align: right;">0.040</td>
</tr>
<tr class="even">
<td style="text-align: right;">2</td>
<td style="text-align: right;">0.020</td>
<td style="text-align: right;">0.0167</td>
<td style="text-align: right;">0.080</td>
<td style="text-align: right;">0.060</td>
<td style="text-align: right;">0.048</td>
</tr>
<tr class="odd">
<td style="text-align: right;">3</td>
<td style="text-align: right;">0.024</td>
<td style="text-align: right;">0.0250</td>
<td style="text-align: right;">0.096</td>
<td style="text-align: right;">0.060</td>
<td style="text-align: right;">0.048</td>
</tr>
<tr class="even">
<td style="text-align: right;">4</td>
<td style="text-align: right;">0.500</td>
<td style="text-align: right;">0.0500</td>
<td style="text-align: right;">1.000</td>
<td style="text-align: right;">0.500</td>
<td style="text-align: right;">0.500</td>
</tr>
</tbody>
</table>
<p>Bonferroni rejects only <img src="https://latex.codecogs.com/png.latex?H_%7B(1)%7D">. Holm also rejects only <img src="https://latex.codecogs.com/png.latex?H_%7B(1)%7D"> because its step-down sequence stops at rank 2. Hochberg finds that <img src="https://latex.codecogs.com/png.latex?p_%7B(3)%7D=0.024%5Cle0.025"> and rejects the first three hypotheses, provided its dependence assumptions are defensible.</p>
<p>An adjusted p-value here is the smallest family-wise level at which that procedure would reject the hypothesis. It is not the probability that the null is true and not an estimate of the fraction of reported findings that are false.</p>
</section>
<section id="choosing-and-defining-the-family" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Choosing and Defining the Family</h1>
<p>Multiplicity is attached to a set of claims. A confirmatory experiment might define one family as all primary contrasts needed to support a single conclusion. Separate scientific questions can sometimes form separate families, but splitting must follow the design and logical structure rather than the observed p-values.</p>
<table class="caption-top table">
<thead>
<tr class="header">
<th>Situation</th>
<th>Reasonable starting point</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Any false positive would undermine a confirmatory claim</td>
<td>Holm</td>
</tr>
<tr class="even">
<td>A transparent one-line bound or unequal pre-specified weights are needed</td>
<td>Bonferroni or weighted Bonferroni</td>
</tr>
<tr class="odd">
<td>FWER is required and independence or suitable positive dependence is justified</td>
<td>Hochberg</td>
</tr>
<tr class="even">
<td>Thousands of exploratory discoveries are expected</td>
<td>Consider <a href="../../../knowledge/statistics/statistical-inference/false-discovery-rate.html">false discovery rate</a> control instead</td>
</tr>
</tbody>
</table>
<p>These adjustments correct a valid collection of p-values; they do not repair biased sampling, model misspecification, selective reporting, or an invalid null distribution.</p>
</section>
<section id="bioinformatics-design-and-interpretation" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Bioinformatics Design and Interpretation</h1>
<p>For a targeted validation panel, genes or contrasts may be the hypotheses, but biological samples remain the experimental units. Repeated sequencing lanes, technical wells, or multiple cells from the same donor do not create independent biological replication. The model must first account for pairing, blocking, repeated measures, or clustering; multiplicity adjustment comes after valid per-hypothesis inference.</p>
<p>Genome-wide assays also produce strongly dependent tests because genes share pathways, samples, and latent factors. Holm retains its guarantee without modeling that dependence, although it may have low power. Hochberg should not be selected merely because it yields more rejections. Report the family definition, number of tests, adjustment method, effect estimates, and uncertainty intervals so that statistical control is separated from biological importance.</p>
</section>
<section id="common-pitfalls" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Common Pitfalls</h1>
<ul>
<li><strong>Using <img src="https://latex.codecogs.com/png.latex?0.05/m"> after filtering on the observed p-values:</strong> data-dependent filtering changes the tested family unless the filter is demonstrably independent of the null p-values.</li>
<li><strong>Treating Holm as <img src="https://latex.codecogs.com/png.latex?m"> unrelated thresholds:</strong> it is a sequential rule; after the first failure, later hypotheses are not rejected.</li>
<li><strong>Applying Hochberg under arbitrary dependence without justification:</strong> its classical advantage relies on stronger assumptions than Holm’s.</li>
<li><strong>Calling an adjusted p-value a posterior error probability:</strong> it calibrates a repeated-sampling decision rule, not belief in an individual hypothesis.</li>
<li><strong>Reporting only rejections:</strong> multiplicity control says nothing about effect magnitude, direction, or practical importance.</li>
</ul>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/statistical-inference/hypothesis-tests-and-test-statistics.html">Hypothesis tests and test statistics</a> explains what each underlying test must establish.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/null-distributions-and-p-values.html">Null distributions and p-values</a> develops p-value validity and calibration.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/family-wise-error-rate.html">Family-wise error rate</a> distinguishes weak and strong error control.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/false-discovery-rate.html">False discovery rate</a> targets the expected false fraction rather than the chance of any false rejection.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/statistical-power-and-sample-size-calculation.html">Statistical power and sample-size calculation</a> shows why multiplicity belongs in prospective design.</li>
</ul>
<p>The central practical rule is simple: use Holm rather than unmodified Bonferroni when strong FWER control under arbitrary dependence is wanted; use Hochberg only when its dependence conditions are credible. In every case, define the family before inspecting results and interpret adjusted evidence alongside effects and uncertainty.</p>
</section>
<section id="references" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> References</h1>
<ul>
<li>Bonferroni, C. E. (1936). <em>Teoria statistica delle classi e calcolo delle probabilità</em>. Pubblicazioni del R Istituto Superiore di Scienze Economiche e Commerciali di Firenze, 8, 3–62.</li>
<li>Holm, S. (1979). A simple sequentially rejective multiple test procedure. <em>Scandinavian Journal of Statistics</em>, 6(2), 65–70. <a href="https://www.jstor.org/stable/4615733">JSTOR</a>.</li>
<li>Hochberg, Y. (1988). A sharper Bonferroni procedure for multiple tests of significance. <em>Biometrika</em>, 75(4), 800–802. <a href="https://doi.org/10.1093/biomet/75.4.800">doi:10.1093/biomet/75.4.800</a>.</li>
<li>R Core Team. <code>p.adjust</code>: Adjust p-values for multiple comparisons. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/p.adjust.html">R documentation</a>.</li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Inference</category>
  <category>Multiple Testing</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/statistical-inference/bonferroni-holm-and-hochberg-procedures.html</guid>
  <pubDate>Tue, 06 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Permutation and Randomization Tests</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/statistical-inference/permutation-and-randomization-tests.html</link>
  <description><![CDATA[ 





<section id="reassignment-creates-the-reference-distribution" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Reassignment Creates the Reference Distribution</h1>
<p>A permutation or randomization test compares an observed statistic with values obtained by transformations that would be legitimate under a stated null hypothesis. Let <img src="https://latex.codecogs.com/png.latex?Z"> describe treatment assignment or group labels, let <img src="https://latex.codecogs.com/png.latex?Y"> be the observed outcomes, and let <img src="https://latex.codecogs.com/png.latex?T(Y,Z)"> be a statistic such as a difference in means. If <img src="https://latex.codecogs.com/png.latex?%5Cmathcal%20Z"> is the set of assignments allowed by the design, the randomization distribution is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5C%7BT(Y,z):z%5Cin%5Cmathcal%20Z%5C%7D.%0A"></p>
<p>For an upper-tail test with equally likely assignments, the exact p-value is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ap_%7B%5Cmathrm%7Bexact%7D%7D%0A=%0A%5Cfrac%7B1%7D%7B%7C%5Cmathcal%20Z%7C%7D%0A%5Csum_%7Bz%5Cin%5Cmathcal%20Z%7D%0A%5Cmathbf%201%5C%7BT(Y,z)%5Cgeq%20T(Y,Z_%7B%5Cmathrm%7Bobs%7D%7D)%5C%7D.%0A"></p>
<p>The arithmetic is simple; the justification is not. The permissible transformations must come from the assignment mechanism or from exchangeability under the null. Shuffling arbitrary rows does not make a test nonparametric or valid.</p>
</section>
<section id="randomization-tests-and-permutation-tests" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> Randomization Tests and Permutation Tests</h1>
<p>The terms are often used interchangeably, but their strongest justifications differ.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Setting</th>
<th>Source of the reference distribution</th>
<th>Typical null</th>
<th>Scope of interpretation</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Randomized experiment</td>
<td>Known treatment-assignment mechanism</td>
<td>Sharp null of no unit-level treatment effect</td>
<td>Design-based causal inference for the randomized units</td>
</tr>
<tr class="even">
<td>Independent samples</td>
<td>Exchangeability of pooled observations under <img src="https://latex.codecogs.com/png.latex?H_0"></td>
<td>Equality of the group distributions</td>
<td>Population comparison under sampling assumptions</td>
</tr>
<tr class="odd">
<td>Paired or blocked design</td>
<td>Within-pair swaps or within-block permutations</td>
<td>No effect within the permitted exchange units</td>
<td>Contrast respecting pairing or blocking</td>
</tr>
<tr class="even">
<td>Regression or complex design</td>
<td>Residual, score, or label transformations with additional conditions</td>
<td>Model-specific restriction</td>
<td>Conditional on the validity of the chosen transformation</td>
</tr>
</tbody>
</table>
<p>In a randomized experiment, write the potential outcomes for unit <img src="https://latex.codecogs.com/png.latex?i"> as <img src="https://latex.codecogs.com/png.latex?Y_i(1)"> and <img src="https://latex.codecogs.com/png.latex?Y_i(0)">. Fisher’s sharp null is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AH_0%5E%7B%5Cmathrm%7Bsharp%7D%7D:Y_i(1)=Y_i(0)%5Cquad%5Ctext%7Bfor%20every%20%7Di.%0A"></p>
<p>Under this null every missing potential outcome is known from the observed outcome, so <img src="https://latex.codecogs.com/png.latex?T"> can be recomputed for every allowed assignment. This yields finite-sample calibration from the design without an outcome-distribution model.</p>
<p>The weak null of zero average treatment effect,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AH_0%5E%7B%5Cmathrm%7Bavg%7D%7D:%5Cfrac1N%5Csum_%7Bi=1%7D%5EN%5C%7BY_i(1)-Y_i(0)%5C%7D=0,%0A"></p>
<p>does not make all missing potential outcomes known. A test exact for the sharp null is not automatically exact for this weaker null. Studentized statistics can provide asymptotically valid inference for average effects under suitable randomized designs, but the target and conditions must be stated.</p>
<p>For observational two-sample data, freely permuting labels is exact when the pooled observations are exchangeable under the null—for example, when both samples have the same distribution. Equality of means alone does not generally imply exchangeability when variances or shapes differ.</p>
</section>
<section id="a-small-exact-randomization-test" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> A Small Exact Randomization Test</h1>
<p>Four experimental units have observed outcomes</p>
<p><img src="https://latex.codecogs.com/png.latex?%0Ay=(8,6,5,3),%0A"></p>
<p>and exactly two units were randomly assigned to treatment. The observed treatment group contains outcomes 8 and 6, so</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AT_%7B%5Cmathrm%7Bobs%7D%7D=%5Cbar%20Y_T-%5Cbar%20Y_C=7-4=3.%0A"></p>
<p>There are <img src="https://latex.codecogs.com/png.latex?%5Cbinom42=6"> permitted assignments. If <img src="https://latex.codecogs.com/png.latex?s_T"> is the sum of the two treated outcomes, then the difference in means equals <img src="https://latex.codecogs.com/png.latex?s_T-11">. The six values are</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A3,%5C;2,%5C;0,%5C;0,%5C;-2,%5C;-3.%0A"></p>
<p>Only one is at least 3, so the upper-tail p-value is <img src="https://latex.codecogs.com/png.latex?1/6">. Two of the six have absolute value at least 3, so the two-sided absolute-statistic p-value is <img src="https://latex.codecogs.com/png.latex?2/6=1/3">. The smallest attainable upper-tail p-value is <img src="https://latex.codecogs.com/png.latex?1/6">: exact tests are discrete, and a small design may be incapable of attaining <img src="https://latex.codecogs.com/png.latex?0.05">.</p>
<p>This calculation conditions on the outcomes under the sharp null and averages over the assignment mechanism. It does not claim that the four observed outcomes are a random sample from a larger biological population. Generalizing beyond these units requires additional sampling or modeling assumptions.</p>
</section>
<section id="exhaustive-and-monte-carlo-calibration" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Exhaustive and Monte Carlo Calibration</h1>
<p>Exhaustive enumeration is feasible only when <img src="https://latex.codecogs.com/png.latex?%7C%5Cmathcal%20Z%7C"> is modest. With <img src="https://latex.codecogs.com/png.latex?n_T"> treated among <img src="https://latex.codecogs.com/png.latex?N"> units, a completely randomized design has <img src="https://latex.codecogs.com/png.latex?%5Cbinom%7BN%7D%7Bn_T%7D"> assignments. For large sets, draw <img src="https://latex.codecogs.com/png.latex?B"> valid random assignments and include the observed arrangement. A conservative Monte Carlo p-value is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cboxed%7B%0A%5Chat%20p=%5Cfrac%7B1+%5Csum_%7Bb=1%7D%5EB%0A%5Cmathbf%201%5C%7BT_b%5E*%5Cgeq%20T_%7B%5Cmathrm%7Bobs%7D%7D%5C%7D%7D%7BB+1%7D.%0A%7D%0A"></p>
<p>The added ones prevent a zero p-value and give a valid randomized Monte Carlo test when the observed and simulated assignments are handled symmetrically. Its resolution is <img src="https://latex.codecogs.com/png.latex?1/(B+1)">, and its simulation uncertainty should be small relative to any decision threshold. Increasing <img src="https://latex.codecogs.com/png.latex?B"> reduces Monte Carlo error but cannot fix an invalid permutation scheme.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># A reproducible Monte Carlo randomization test for a completely randomized design</span></span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">set.seed</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20261006</span>)</span>
<span id="cb1-3">y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">8</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">7</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>)</span>
<span id="cb1-4">z <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>)</span>
<span id="cb1-5">stat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">function</span>(labels) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(y[labels <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">mean</span>(y[labels <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>])</span>
<span id="cb1-6">t_obs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat</span>(z)</span>
<span id="cb1-7">B <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">9999</span></span>
<span id="cb1-8">t_star <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">replicate</span>(B, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">stat</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sample</span>(z, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">replace =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">FALSE</span>)))</span>
<span id="cb1-9">p_two_sided <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> (<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span> <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sum</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(t_star) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">abs</span>(t_obs))) <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span> (B <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb1-10">p_two_sided</span></code></pre></div></div>
<p>The code is appropriate only because every allocation with four treated units is permitted. A blocked, paired, clustered, or unequal-probability design needs a generator for its actual assignment mechanism.</p>
</section>
<section id="restrictions-must-follow-the-design" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> Restrictions Must Follow the Design</h1>
<table class="caption-top table">
<colgroup>
<col style="width: 33%">
<col style="width: 33%">
<col style="width: 33%">
</colgroup>
<thead>
<tr class="header">
<th>Design feature</th>
<th>Valid transformation idea</th>
<th>Invalid shortcut</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Matched pairs</td>
<td>Swap treatment labels within each pair</td>
<td>Shuffle across all specimens</td>
</tr>
<tr class="even">
<td>Randomized blocks</td>
<td>Permute within blocks using the assigned counts</td>
<td>Ignore block restrictions</td>
</tr>
<tr class="odd">
<td>Cluster randomization</td>
<td>Reassign whole clusters</td>
<td>Permute individuals within clusters</td>
</tr>
<tr class="even">
<td>Repeated measures</td>
<td>Swap condition labels within a subject when justified</td>
<td>Treat visits as independent subjects</td>
</tr>
<tr class="odd">
<td>Time or spatial dependence</td>
<td>Use design-specific shifts, blocks, or model-based methods</td>
<td>Freely shuffle individual observations</td>
</tr>
<tr class="even">
<td>Covariate-adaptive assignment</td>
<td>Reproduce the actual assignment algorithm</td>
<td>Use complete randomization</td>
</tr>
</tbody>
</table>
<p>Post-treatment missingness, noncompliance, interference between units, and outcome-adaptive stopping can break the simple reassignment argument. They require an estimand and procedure that explicitly address those features.</p>
</section>
<section id="choosing-a-statistic-and-tail" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Choosing a Statistic and Tail</h1>
<p>Exactness under a sharp null does not require the statistic itself to follow a parametric distribution. Power, however, depends strongly on the statistic. A mean difference is sensitive to average shifts; a rank statistic emphasizes ordering; a maximum may target a sparse extreme response; and a studentized contrast adjusts for estimated variability.</p>
<p>The alternative determines the tail. A two-sided p-value can be defined through <img src="https://latex.codecogs.com/png.latex?%7CT%7C">, doubled one-sided probabilities, or an ordering based on probability mass; these definitions need not agree for asymmetric or discrete randomization distributions. Specify the statistic and extremeness rule before examining the outcome.</p>
<p>Inverting a family of randomization tests can produce a confidence set, but under a constant additive-effect model this targets a model parameter stronger than an average effect. Report an effect estimate and compatible interval alongside the p-value; randomization calibration does not make magnitude optional.</p>
</section>
<section id="bioinformatics-design-and-interpretation" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Bioinformatics Design and Interpretation</h1>
<p>Suppose treatment was randomized to biological specimens and thousands of genes were measured. The specimen is the assignment and permutation unit. Reads, technical lanes, and cells nested within a specimen must travel with that specimen; permuting cell labels independently creates pseudoreplication. If randomization occurred within batches or matched donor pairs, permutations must remain within those sets.</p>
<p>For an observational case–control expression study, exchangeability is an assumption rather than a consequence of randomization. Batch, ancestry, age, or other confounders can make unrestricted case-label permutations invalid. Residual permutation methods also rely on model conditions and are not universally exact. A sensitivity analysis should compare plausible adjustment and transformation schemes rather than selecting the smallest p-value.</p>
<p>Statistically, a small randomization p-value says the chosen statistic is unusual among assignments permitted under the null and design. Biologically, it does not establish a large effect, a mechanism, absence of interference, or generalizability to another population. Multiplicity across genes remains a separate problem.</p>
</section>
<section id="assumptions-and-failure-modes" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Assumptions and Failure Modes</h1>
<ul>
<li><strong>Wrong unit:</strong> permuting cells, reads, or repeated measurements instead of independently assigned specimens exaggerates information.</li>
<li><strong>Wrong null:</strong> a sharp-null test is presented as an exact test of a zero average effect.</li>
<li><strong>Wrong transformation group:</strong> unrestricted shuffles violate pairs, blocks, clusters, or unequal assignment probabilities.</li>
<li><strong>Exchangeability assumed from “nonparametric”:</strong> different variances, shapes, or confounder distributions can invalidate pooled-label permutation under a mean-only null.</li>
<li><strong>Adaptive statistic:</strong> trying several outcomes, transformations, or tails and reporting the most favorable test omits the selection step from calibration.</li>
<li><strong>Too few assignments or simulations:</strong> attainable p-values are coarse, and Monte Carlo error can change threshold decisions.</li>
</ul>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/statistical-inference/hypothesis-tests-and-test-statistics.html">Hypothesis tests and test statistics</a> defines the decision rule and calibration target.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/null-distributions-and-p-values.html">Null distributions and p-values</a> explains tail areas and valid p-values.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/nonparametric-bootstrap.html">Nonparametric bootstrap</a> resamples units with replacement to estimate sampling uncertainty; permutation tests transform labels or assignments under a null.</li>
<li><a href="../../../knowledge/statistics/probability-randomness/independence-and-conditional-independence.html">Independence and conditional independence</a> clarifies exchangeability and dependence.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/family-wise-error-rate.html">Family-wise error rate</a> and <a href="../../../knowledge/statistics/statistical-inference/false-discovery-rate.html">false discovery rate</a> address multiplicity after individual tests are calibrated.</li>
</ul>
<p>Randomization inference obtains its strongest finite-sample guarantee from the treatment-assignment mechanism. Permutation inference in observational samples instead needs null exchangeability or a justified model-based transformation. The experimental unit, restricted assignment set, statistic, tail, and null must all align. Enumeration or many simulations improve numerical accuracy only after that scientific and design logic is correct.</p>
</section>
<section id="references" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> References</h1>
<ul>
<li>Fisher, R. A. <em>The Design of Experiments</em>. Oliver and Boyd, 1935.</li>
<li>Pitman, E. J. G. “Significance Tests Which May Be Applied to Samples from Any Populations.” <em>Supplement to the Journal of the Royal Statistical Society</em> 4 (1937): 119–130. <a href="https://doi.org/10.2307/2984124">Article</a>.</li>
<li>Lehmann, E. L. and Romano, J. P. <em>Testing Statistical Hypotheses</em>, 3rd ed.&nbsp;Springer, 2005. <a href="https://doi.org/10.1007/0-387-27605-X">Publisher page</a>.</li>
<li>Ernst, M. D. “Permutation Methods: A Basis for Exact Inference.” <em>Statistical Science</em> 19 (2004): 676–685. <a href="https://doi.org/10.1214/088342304000000396">Article</a>.</li>
<li>Phipson, B. and Smyth, G. K. “Permutation P-values Should Never Be Zero: Calculating Exact P-values When Permutations Are Randomly Drawn.” <em>Statistical Applications in Genetics and Molecular Biology</em> 9 (2010), Article 39. <a href="https://doi.org/10.2202/1544-6115.1585">Article</a>.</li>
<li>Chung, E. and Romano, J. P. “Exact and Asymptotically Robust Permutation Tests.” <em>The Annals of Statistics</em> 41 (2013): 484–507. <a href="https://doi.org/10.1214/13-AOS1090">Article</a>.</li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Inference</category>
  <category>Resampling</category>
  <category>Experimental Design</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/statistical-inference/permutation-and-randomization-tests.html</guid>
  <pubDate>Tue, 06 Oct 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Rank-based Nonparametric Tests</title>
  <dc:creator>Jiahong Sun</dc:creator>
  <link>https://sunjh22.github.io/knowledge/statistics/statistical-inference/rank-based-nonparametric-tests.html</link>
  <description><![CDATA[ 





<section id="ranks-preserve-order-not-distance" class="level1" data-number="1">
<h1 data-number="1"><span class="header-section-number">1</span> Ranks Preserve Order, Not Distance</h1>
<p>Rank-based tests replace numerical magnitudes by their order. For pooled observations <img src="https://latex.codecogs.com/png.latex?Y_1,%5Cldots,Y_N">, let <img src="https://latex.codecogs.com/png.latex?R_i"> be the rank of <img src="https://latex.codecogs.com/png.latex?Y_i">, assigning midranks to ties. Because any strictly increasing transformation preserves the ranks, these procedures are unaffected by changing from a concentration to its logarithm or by another monotone rescaling.</p>
<p>That invariance can provide robustness to skewness and extreme magnitudes, but it discards distance information. Rank methods are <strong>nonparametric</strong> because they do not specify a finite-dimensional outcome distribution; they are not assumption-free. Independence or a valid dependence structure, exchangeability under the null, appropriate handling of ties, and a design-matched statistic remain essential.</p>
</section>
<section id="the-wilcoxonmannwhitney-statistic" class="level1" data-number="2">
<h1 data-number="2"><span class="header-section-number">2</span> The Wilcoxon–Mann–Whitney Statistic</h1>
<p>Let <img src="https://latex.codecogs.com/png.latex?X_1,%5Cldots,X_m"> and <img src="https://latex.codecogs.com/png.latex?Y_1,%5Cldots,Y_n"> be independent observations from distributions <img src="https://latex.codecogs.com/png.latex?F"> and <img src="https://latex.codecogs.com/png.latex?G">. A useful population effect is the probability of superiority</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Ctheta%0A=P(X%3CY)+%5Cfrac12P(X=Y).%0A"></p>
<p>Its estimator is the normalized Mann–Whitney statistic</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Chat%5Ctheta%0A=%5Cfrac%7BU%7D%7Bmn%7D,%0A%5Cqquad%0AU=%5Csum_%7Bi=1%7D%5Em%5Csum_%7Bj=1%7D%5En%0A%5Cleft%5C%7B%5Cmathbf%201(X_i%3CY_j)+%5Cfrac12%5Cmathbf%201(X_i=Y_j)%5Cright%5C%7D.%0A"></p>
<p>Thus <img src="https://latex.codecogs.com/png.latex?%5Chat%5Ctheta"> is the fraction of cross-group pairs in which <img src="https://latex.codecogs.com/png.latex?Y"> is larger, with ties split equally. Under identical continuous distributions, <img src="https://latex.codecogs.com/png.latex?E(U)=mn/2">. If <img src="https://latex.codecogs.com/png.latex?W_Y"> is the sum of the pooled ranks for the <img src="https://latex.codecogs.com/png.latex?Y"> sample, then</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AU=W_Y-%5Cfrac%7Bn(n+1)%7D2.%0A"></p>
<p>This algebra explains why the Mann–Whitney <img src="https://latex.codecogs.com/png.latex?U"> test and the Wilcoxon rank-sum test are equivalent after a change of statistic.</p>
<p>The exact pooled-label permutation test targets equality of the full distributions,</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AH_0:F=G.%0A"></p>
<p>Under a pure location-shift model <img src="https://latex.codecogs.com/png.latex?G(t)=F(t-%5CDelta)"> with common shape and spread, the procedure can be interpreted as a test of <img src="https://latex.codecogs.com/png.latex?%5CDelta=0">, and a Hodges–Lehmann estimator summarizes the shift through pairwise differences. Without that model, it is not simply a test of equal medians: differences in spread or shape can change its distribution and interpretation.</p>
</section>
<section id="worked-two-sample-example" class="level1" data-number="3">
<h1 data-number="3"><span class="header-section-number">3</span> Worked Two-sample Example</h1>
<p>Consider independent samples</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AX=(1,2,3),%0A%5Cqquad%0AY=(4,5,6).%0A"></p>
<p>Every one of the <img src="https://latex.codecogs.com/png.latex?3%5Ctimes3=9"> cross-group comparisons has <img src="https://latex.codecogs.com/png.latex?X_i%3CY_j">, so <img src="https://latex.codecogs.com/png.latex?U=9"> and <img src="https://latex.codecogs.com/png.latex?%5Chat%5Ctheta=1">. The <img src="https://latex.codecogs.com/png.latex?Y"> rank sum is <img src="https://latex.codecogs.com/png.latex?4+5+6=15">, giving the same result:</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AU=15-%5Cfrac%7B3(4)%7D2=9.%0A"></p>
<p>Under the equality null, all <img src="https://latex.codecogs.com/png.latex?%5Cbinom63=20"> allocations of three pooled ranks to the <img src="https://latex.codecogs.com/png.latex?Y"> group are equally likely. Only one allocation gives <img src="https://latex.codecogs.com/png.latex?U=9"> and one gives the equally extreme <img src="https://latex.codecogs.com/png.latex?U=0">, so the usual two-sided exact p-value is <img src="https://latex.codecogs.com/png.latex?2/20=0.10">. Complete sample separation therefore does not attain 0.05 with only three observations per group.</p>
<p>The effect estimate <img src="https://latex.codecogs.com/png.latex?%5Chat%5Ctheta=1"> describes these observed cross-group orderings. It does not show that every future <img src="https://latex.codecogs.com/png.latex?Y"> value will exceed every future <img src="https://latex.codecogs.com/png.latex?X"> value, and the p-value’s discreteness reflects the small number of independent units.</p>
</section>
<section id="paired-data-sign-and-signed-rank-tests" class="level1" data-number="4">
<h1 data-number="4"><span class="header-section-number">4</span> Paired Data: Sign and Signed-rank Tests</h1>
<p>For paired measurements define differences <img src="https://latex.codecogs.com/png.latex?D_i=Y_i-X_i">. Pairing is part of the design; the <img src="https://latex.codecogs.com/png.latex?2n"> measurements must not be analyzed as independent groups.</p>
<p>The <strong>sign test</strong> uses only whether each nonzero <img src="https://latex.codecogs.com/png.latex?D_i"> is positive. Under independent continuous differences with median zero, the number of positive differences is binomial with success probability <img src="https://latex.codecogs.com/png.latex?1/2">. It makes relatively weak shape assumptions but discards magnitudes.</p>
<p>The <strong>Wilcoxon signed-rank test</strong> ranks <img src="https://latex.codecogs.com/png.latex?%7CD_i%7C"> and sums ranks carrying positive signs. Its exact sign-flip null distribution requires the differences to be independent and symmetric about zero, with additional care for zeros and ties. Symmetry makes positive and negative signs equally likely conditional on the absolute differences. If the distribution of differences is strongly asymmetric, the signed-rank test is not generally a distribution-free test of the median.</p>
<p>Under a symmetric location model, the signed-rank procedure targets a central shift and the Hodges–Lehmann one-sample estimator is the median of Walsh averages <img src="https://latex.codecogs.com/png.latex?(D_i+D_j)/2"> for <img src="https://latex.codecogs.com/png.latex?i%5Cleq%20j">. This is not generally identical to the sample median difference.</p>
</section>
<section id="more-than-two-groups-or-blocks" class="level1" data-number="5">
<h1 data-number="5"><span class="header-section-number">5</span> More Than Two Groups or Blocks</h1>
<p>For <img src="https://latex.codecogs.com/png.latex?k"> independent groups with sizes <img src="https://latex.codecogs.com/png.latex?n_g">, pooled rank sums <img src="https://latex.codecogs.com/png.latex?R_g">, and <img src="https://latex.codecogs.com/png.latex?N=%5Csum_g%20n_g">, the Kruskal–Wallis statistic is</p>
<p><img src="https://latex.codecogs.com/png.latex?%0AH=%0A%5Cfrac%7B12%7D%7BN(N+1)%7D%0A%5Csum_%7Bg=1%7D%5Ek%5Cfrac%7BR_g%5E2%7D%7Bn_g%7D%0A-3(N+1).%0A"></p>
<p>With no ties and under equal group distributions, its large-sample null distribution is approximately <img src="https://latex.codecogs.com/png.latex?%5Cchi%5E2_%7Bk-1%7D">. Ties require a variance correction, and sparse groups can make the approximation inaccurate. A significant global test says that the rank distributions are not all alike; it does not identify the groups that differ. Planned contrasts or multiplicity-adjusted follow-up comparisons are needed.</p>
<p>For complete block designs, the Friedman test ranks treatments <strong>within each block</strong> and compares treatment rank sums. It preserves the block as the independent replication unit. Applying Kruskal–Wallis to repeated measurements ignores within-block dependence, while applying Friedman to unrelated groups invents pairing that is not present.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th>Scientific design</th>
<th>Rank procedure</th>
<th>Key condition</th>
<th>Main effect description</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Two independent groups</td>
<td>Wilcoxon rank-sum / Mann–Whitney</td>
<td>Independent units; exchangeability for exact equality-null test</td>
<td>Relative ordering or a shift under stronger assumptions</td>
</tr>
<tr class="even">
<td>Paired observations</td>
<td>Sign test</td>
<td>Independent pairs; equal sign probabilities under null</td>
<td>Direction of within-pair differences</td>
</tr>
<tr class="odd">
<td>Paired observations</td>
<td>Wilcoxon signed-rank</td>
<td>Independent, symmetric differences</td>
<td>Symmetric location shift</td>
</tr>
<tr class="even">
<td>Several independent groups</td>
<td>Kruskal–Wallis</td>
<td>Independent units; equal distributions under null</td>
<td>Global rank-distribution difference</td>
</tr>
<tr class="odd">
<td>Several treatments in blocks</td>
<td>Friedman</td>
<td>Independent blocks; comparable within-block ranks</td>
<td>Global treatment difference conditional on blocks</td>
</tr>
</tbody>
</table>
</section>
<section id="ties-zeros-exactness-and-software" class="level1" data-number="6">
<h1 data-number="6"><span class="header-section-number">6</span> Ties, Zeros, Exactness, and Software</h1>
<p>Ties occur naturally in rounded assays, ordinal scores, counts, and measurements below a detection limit. Midranks preserve a sensible ordering statistic, but the no-tie exact distribution no longer applies. Software may use tie-corrected asymptotic approximations, conditional exact methods, or Monte Carlo calibration. Zeros in paired differences also require an explicit convention.</p>
<p>Base R’s <code>wilcox.test()</code> computes an exact p-value by default for small samples only when there are no ties; otherwise it uses a normal approximation, optionally with continuity correction. The reported statistic and confidence interval depend on whether the call is one-sample, paired, or two-sample. Record the alternative, exact/asymptotic choice, tie and zero handling, continuity correction, and effect estimate rather than reporting only “a Wilcoxon test.”</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1">x <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb1-2">y <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span>)</span>
<span id="cb1-3"></span>
<span id="cb1-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Independent samples: exact equality-of-distributions test when there are no ties</span></span>
<span id="cb1-5">stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">wilcox.test</span>(y, x, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">alternative =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"two.sided"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">exact =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>,</span>
<span id="cb1-6">                   <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">conf.int =</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">TRUE</span>)</span>
<span id="cb1-7"></span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Several independent groups: asymptotic Kruskal--Wallis test</span></span>
<span id="cb1-9">values <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.8</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">3.2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.1</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.4</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">4.8</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.0</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">5.4</span>)</span>
<span id="cb1-10">group <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">factor</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rep</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"A"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"B"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"C"</span>), <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">each =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>))</span>
<span id="cb1-11">stats<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">::</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">kruskal.test</span>(values <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">~</span> group)</span></code></pre></div></div>
<p>An asymptotic p-value can be inaccurate with few independent units or many ties. An exact conditional or Monte Carlo method can improve calibration only if its exchangeability and design conditions are correct.</p>
</section>
<section id="efficiency-robustness-and-what-ranks-cannot-fix" class="level1" data-number="7">
<h1 data-number="7"><span class="header-section-number">7</span> Efficiency, Robustness, and What Ranks Cannot Fix</h1>
<p>Under normal location shifts, the Wilcoxon rank-sum test has high asymptotic efficiency relative to the two-sample <img src="https://latex.codecogs.com/png.latex?t"> test, while often losing less power under heavy tails. Yet “use ranks when normality fails” is too crude. Welch’s test can remain appropriate for a mean estimand with unequal variances, and robust regression or permutation of a studentized statistic may address other targets.</p>
<p>Ranks cannot repair confounding, selection bias, dependence, informative missingness, batch effects, or pseudoreplication. They also cannot estimate a mean difference once magnitudes have been discarded. Choose a method from the estimand and design, not from a preliminary normality test performed on the same small dataset.</p>
</section>
<section id="bioinformatics-design-and-interpretation" class="level1" data-number="8">
<h1 data-number="8"><span class="header-section-number">8</span> Bioinformatics Design and Interpretation</h1>
<p>For a two-condition assay, donors or independently sampled specimens are normally the experimental units. Genes, reads, cells, and technical replicates are nested measurements, not extra independent ranks. A donor-level rank-sum test may be defensible with independent groups; ranking thousands of cells as though each were an independent donor can yield severely anticonservative inference.</p>
<p>With matched specimens, analyze donor-level within-pair contrasts using a sign or signed-rank procedure when its assumptions match the target. If treatments were randomized within blocks, a blocked randomization test can use ranks while preserving the design. Detection limits can create many ties; then report the tied fraction, use a calibrated method, and assess whether the scientific target is abundance, detection probability, or both.</p>
<p>Statistically, a rank effect such as <img src="https://latex.codecogs.com/png.latex?%5Ctheta"> describes relative ordering. Biologically, it does not directly state a fold change, pathway mechanism, or clinically meaningful difference. Report raw-scale or scientifically meaningful effect summaries and intervals alongside rank-based inference, and adjust for multiplicity when many features are tested.</p>
</section>
<section id="common-misinterpretations" class="level1" data-number="9">
<h1 data-number="9"><span class="header-section-number">9</span> Common Misinterpretations</h1>
<ul>
<li><strong>“Mann–Whitney tests medians.”</strong> Only with suitable common-shape or location-shift assumptions can it be reduced to that interpretation.</li>
<li><strong>“Nonparametric means no assumptions.”</strong> Validity still depends on sampling, independence, exchangeability, and tie handling.</li>
<li><strong>“Ranks solve outliers.”</strong> They limit magnitude influence but do not make an influential specimen scientifically irrelevant or correct data errors.</li>
<li><strong>“Signed-rank is the paired rank-sum test.”</strong> It analyzes ranked within-pair differences and needs symmetry; the independent-sample rank-sum test has a different design and null.</li>
<li><strong>“A significant Kruskal–Wallis test identifies the changed group.”</strong> It is a global test; follow-up comparisons require their own estimates and multiplicity control.</li>
</ul>
</section>
<section id="connections-and-take-home-messages" class="level1" data-number="10">
<h1 data-number="10"><span class="header-section-number">10</span> Connections and Take-home Messages</h1>
<ul>
<li><a href="../../../knowledge/statistics/statistical-inference/permutation-and-randomization-tests.html">Permutation and randomization tests</a> explains how exchangeability or assignment generates exact reference distributions.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/effect-sizes.html">Effect sizes</a> distinguishes relative-ordering effects from raw and standardized differences.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/one-sided-two-sided-and-equivalence-tests.html">One-sided, two-sided, and equivalence tests</a> connects the scientific claim to the alternative and tail.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/bonferroni-holm-and-hochberg-procedures.html">Bonferroni, Holm, and Hochberg procedures</a> covers adjusted follow-up tests.</li>
<li><a href="../../../knowledge/statistics/statistical-inference/sampling-distributions.html">Sampling distributions</a> explains exact and asymptotic calibration.</li>
</ul>
<p>Ranks retain ordering while discarding distance, providing monotone invariance and useful robustness. The Wilcoxon–Mann–Whitney statistic naturally estimates a probability of superiority, not automatically a median difference. Paired, independent, and blocked designs require different rank procedures. Ties, zeros, small samples, dependence, and the intended estimand determine whether exact, asymptotic, or alternative methods are appropriate.</p>
</section>
<section id="references" class="level1" data-number="11">
<h1 data-number="11"><span class="header-section-number">11</span> References</h1>
<ul>
<li>Wilcoxon, F. “Individual Comparisons by Ranking Methods.” <em>Biometrics Bulletin</em> 1 (1945): 80–83. <a href="https://doi.org/10.2307/3001968">Article</a>.</li>
<li>Mann, H. B. and Whitney, D. R. “On a Test of Whether One of Two Random Variables Is Stochastically Larger than the Other.” <em>The Annals of Mathematical Statistics</em> 18 (1947): 50–60. <a href="https://doi.org/10.1214/aoms/1177730491">Article</a>.</li>
<li>Kruskal, W. H. and Wallis, W. A. “Use of Ranks in One-Criterion Variance Analysis.” <em>Journal of the American Statistical Association</em> 47 (1952): 583–621. <a href="https://doi.org/10.1080/01621459.1952.10483441">Article</a>.</li>
<li>Friedman, M. “The Use of Ranks to Avoid the Assumption of Normality Implicit in the Analysis of Variance.” <em>Journal of the American Statistical Association</em> 32 (1937): 675–701. <a href="https://doi.org/10.1080/01621459.1937.10503522">Article</a>.</li>
<li>Hollander, M., Wolfe, D. A., and Chicken, E. <em>Nonparametric Statistical Methods</em>, 3rd ed.&nbsp;Wiley, 2014. <a href="https://doi.org/10.1002/9781119196037">Publisher page</a>.</li>
<li>R Core Team. “Wilcoxon Rank Sum and Signed Rank Tests.” <em>R statistical software documentation</em>. <a href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html">Documentation</a>.</li>
</ul>


<!-- -->

</section>

<a onclick="window.scrollTo(0, 0); return false;" id="quarto-back-to-top"><i class="bi bi-arrow-up"></i> Back to top</a> ]]></description>
  <category>Statistics</category>
  <category>Inference</category>
  <category>Nonparametric Methods</category>
  <guid>https://sunjh22.github.io/knowledge/statistics/statistical-inference/rank-based-nonparametric-tests.html</guid>
  <pubDate>Tue, 06 Oct 2026 00:00:00 GMT</pubDate>
</item>
</channel>
</rss>
