Tutorials › Statistical Genetics › Covariate Selection Without Data-Driven Overfitting

Covariates, Missingness, and Robust Inference · Tutorial 323 of 989

Covariate Selection Without Data-Driven Overfitting

Compare principled covariate strategies and understand why selecting adjustment variables by their association p-values can undermine genetic effect estimates and inference.

Intermediate 10 min read

What You'll Learn

  • Distinguish prespecified adjustment from covariate screening based on observed p-values
  • Compare nested logistic regression models with a likelihood-ratio test
  • Calculate and interpret AIC and BIC for candidate covariate sets
  • Explain how omitting a covariate associated with genotype and phenotype can alter a genetic effect estimate
  • Recognize why ordinary standard errors and p-values may not account for data-driven model selection
  • Use a transparent workflow to choose and report covariate sets

Why Covariate Selection Needs a Plan

A genetic association estimate depends on the model used to obtain it. Adding or removing covariates can change the estimated genotype effect, its standard error, and even the question the model answers. A convenient-looking rule, such as retaining only covariates whose outcome-association p-values are below 0.05, does not by itself identify a sound adjustment set.

The goal is not to include every available variable or to maximize the number of small p-values. It is to define the association being estimated, decide which covariates are justified by the study design and scientific rationale, and then use model comparisons for a clearly stated purpose. This is especially important in genome-wide association analyses, where a model-selection rule applied repeatedly can create systematic inferential problems.

Definition: A prespecified covariate set is a set of adjustment variables chosen before inspecting their associations with the phenotype or the genetic effect in the analysis being reported. A data-driven covariate selection procedure uses observed data, such as covariate p-values or fit statistics, to choose which variables enter the reported model.

Prespecification does not mean that one universal set is correct for every study. Age, sex, study site, and ancestry-related variables may be justified by the design, the target population, or the association question. The decision should be made in light of the estimand and plausible sources of bias, rather than by a threshold applied mechanically to each covariate’s p-value. As established in the earlier material on covariate roles, adjustment can also change the interpretation of an effect; adding a variable is not automatically beneficial.

Write Down the Model Before Comparing It

For a binary phenotype, a common single-variant model uses logistic regression. Let \(Y_i\) indicate case status for person \(i\), let \(G_i\) be genotype dosage coded as 0, 1, or 2 copies of the effect allele, and let \(Z_i\) denote the chosen covariates. A main-effects model can be written as:

$$ \operatorname{logit}\{P(Y_i=1\mid G_i,Z_i)\} =\beta_0+\beta_G G_i+\boldsymbol{\gamma}^{T}Z_i. $$

Here, \(\beta_G\) is the log odds ratio per additional effect-allele copy, conditional on the covariates in that model; \(\exp(\beta_G)\) is the corresponding conditional odds ratio. The model assumes the observations are independent for the likelihood used, the log odds are correctly represented by the included terms, and the parameters can be estimated without complete or quasi-complete separation. The usual Wald inference additionally relies on an adequate large-sample approximation. If genotype effects vary across covariate levels, a model without interaction terms may not describe that variation.

These assumptions do not dictate a covariate set. They clarify what a fitted model means and what conditions support its inference. When candidate models are compared, the sample and outcome definition should be held fixed. In particular, a change in the set of complete cases can make a fit comparison reflect both different covariates and different data.

Worked Example: Interpreting a Prespecified Adjustment Model

Suppose a hypothetical study analyzes 2,400 unrelated participants, including 800 cases. Before fitting the association model, investigators specify age, sex, and four ancestry principal components as covariates, based on the study design and analysis plan. The fitted logistic regression gives \(\hat{\beta}_G=0.300\) with \(SE=0.100\).

Estimate. The estimated odds ratio per additional effect-allele copy is:

$$ \exp(\hat{\beta}_G)=\exp(0.300)=1.350. $$

Wald test and interval. Under the stated model and a large-sample normal approximation, \(z=\hat{\beta}_G/SE=0.300/0.100=3.00\). The two-sided p-value is approximately 0.0027. A 95% Wald confidence interval for the log odds ratio is:

$$ 0.300\mathbin{\pm}1.96(0.100) =0.300\mathbin{\pm}0.196 =(0.104,\ 0.496). $$

Exponentiating the endpoints gives an odds-ratio interval of \((\exp(0.104),\exp(0.496))=(1.110,1.642)\). In this hypothetical analysis, the estimated conditional odds are multiplied by about 1.35 per additional effect-allele copy, holding the specified covariates fixed. The interval describes uncertainty under this model; it does not include uncertainty from choosing the covariate set after looking at the data.

Nested-Model Tests: A Targeted Comparison

A nested-model test compares a restricted model with a larger model that contains all the restricted model’s terms plus additional parameters. For logistic regression, the likelihood-ratio test uses the maximized log likelihoods from the two models, fitted to the same observations. If the restricted model has log likelihood \(\ell_R\), the larger model has log likelihood \(\ell_F\), and the larger model adds \(q\) parameters, the test statistic is:

$$ G^2=2(\ell_F-\ell_R). $$

Under the null hypothesis that all \(q\) added coefficients are zero, and under the regularity conditions for the likelihood-ratio approximation, \(G^2\) is approximately distributed as a chi-square random variable with \(q\) degrees of freedom. The comparison is useful when the added terms form a prespecified block—for example, testing whether a categorical variable’s set of indicator coefficients is jointly zero.

Worked Example: Testing an Added Covariate Block

In a hypothetical analysis of the same 1,500 participants, investigators planned to compare a model containing genotype dosage and age with a model that additionally contains sex. Both models use the same participants and logistic likelihood. The restricted model has maximized log likelihood \(\ell_R=-1000.0\); the full model has \(\ell_F=-997.8\). Adding sex contributes one coefficient, so \(q=1\).

The likelihood-ratio statistic is:

$$ G^2=2\{-997.8-(-1000.0)\} =2(2.2)=4.4. $$

Under the null hypothesis that the sex coefficient is zero, compare 4.4 with a chi-square distribution on 1 degree of freedom. The two-sided-equivalent upper-tail p-value is approximately 0.036. At \(\alpha=0.05\), the data provide evidence against that restricted-model null in this planned comparison. This result tests the added sex term in these models; it does not establish that every analysis should include sex, nor does it establish that selecting variables by p-values gives valid inference for the genotype effect.

A likelihood-ratio test is not a general-purpose instruction to keep every covariate with a significant p-value. If many candidate blocks are tested and only “significant” ones retained, the final model has been selected using the data. The ordinary p-values from that selected model do not account for the selection process. Moreover, a covariate’s individual test of association with the phenotype is not the same question as whether controlling for it is important for the genetic association estimate.

Information Criteria: Balancing Fit and Complexity

Information criteria summarize a trade-off between model fit and the number of estimated parameters. For a fitted maximum-likelihood model with maximized log likelihood \(\ell\), parameter count \(k\), and sample size \(n\), the Akaike information criterion and Bayesian information criterion are:

$$ \operatorname{AIC}=-2\ell+2k, \qquad \operatorname{BIC}=-2\ell+k\log(n). $$

The parameter count includes all estimated parameters in the likelihood, including the intercept and genotype coefficient. Among the candidate models being compared, a smaller AIC or BIC is preferred by that criterion. AIC is motivated by estimating relative predictive information loss; BIC applies a larger complexity penalty as sample size grows and, under regularity conditions when the true model is among the candidates, can favor selection of that model. Neither criterion is a test of whether a covariate is a confounder, and neither guarantees adequate control of population structure or other bias.

Worked Example: Comparing Covariate Sets With AIC and BIC

Consider two hypothetical logistic models fitted to the same \(n=2{,}000\) participants. Model A contains an intercept, genotype dosage, age, and sex, so \(k_A=4\), and has \(\ell_A=-1200.0\). Model B adds three ancestry principal components, so \(k_B=7\), and has \(\ell_B=-1197.5\). These are nested fits, but the information-criterion comparison itself is not a hypothesis test.

For Model A:

$$ \operatorname{AIC}_A=-2(-1200.0)+2(4)=2400+8=2408. $$

For Model B:

$$ \operatorname{AIC}_B=-2(-1197.5)+2(7)=2395+14=2409. $$

AIC is lower for Model A by 1 point. For BIC, \(\log(2000)\approx7.601\), so:

$$ \operatorname{BIC}_A=2400+4(7.601)=2430.4, \qquad \operatorname{BIC}_B=2395+7(7.601)=2448.2. $$

BIC is lower for Model A by about 17.8 points. Thus both criteria prefer Model A among these two fits, with a much larger difference under BIC. That ranking alone is not a reason to omit ancestry adjustment if study design or scientific knowledge indicates it is needed to address population structure. The criteria compare fit and complexity within the candidate set; they do not supply the scientific rationale for defining that set.

How P-Value Screening Can Change an Effect Estimate

A covariate can matter for a genotype association even if its own phenotype-association p-value does not pass a chosen threshold. In a simple linear model, this can be seen directly. Suppose a quantitative phenotype satisfies \(Y=\beta_G G+\gamma C+\varepsilon\), with an intercept understood, and the error has mean zero conditional on \(G\) and \(C\). If \(C\) is omitted, the population slope from regressing \(Y\) on \(G\) alone is:

$$ \widetilde{\beta}_G =\beta_G+\gamma\frac{\operatorname{Cov}(G,C)} {\operatorname{Var}(G)}. $$

This expression follows from the one-predictor regression slope, \(\operatorname{Cov}(G,Y)/\operatorname{Var}(G)\). Substituting the model for \(Y\) gives \(\operatorname{Cov}(G,Y)=\beta_G\operatorname{Var}(G)+\gamma\operatorname{Cov}(G,C)\), since the conditional-mean-zero error contributes zero covariance. Dividing by \(\operatorname{Var}(G)\) yields the result. The discrepancy is zero if \(\gamma=0\) or if \(G\) and \(C\) are uncorrelated; otherwise, omission changes the slope. This linear derivation illustrates a general concern, not an exact omitted-variable formula for logistic regression.

Worked Example: A Weak Covariate P-Value Does Not Guarantee a Stable Genetic Estimate

Suppose a hypothetical quantitative-trait analysis has a centered genotype dosage \(G\) with \(\operatorname{Var}(G)=0.25\), and a centered ancestry-related covariate \(C\) with \(\operatorname{Cov}(G,C)=0.05\). Assume the conditional mean model has genotype coefficient \(\beta_G=0.20\) trait units per allele and covariate coefficient \(\gamma=1.00\) trait unit per covariate unit. In a particular sample, the covariate’s phenotype-association test has p-value 0.12, so a rule retaining only covariates with p-values below 0.05 would drop it.

The omitted-variable formula gives the genotype slope after dropping \(C\):

$$ \widetilde{\beta}_G =0.20+1.00\left(\frac{0.05}{0.25}\right) =0.20+0.20 =0.40. $$

The adjusted estimate is 0.20 trait units per allele, whereas the unadjusted slope is 0.40 trait units per allele. The difference arises because the covariate is related to both genotype and phenotype in this hypothetical setup. A p-value of 0.12 is not evidence that the covariate has no role in the estimate; it may also reflect limited precision. In practice, the numerical size and direction of such a change depend on the data and model. The example shows why a covariate’s own p-value is not a sufficient rule for deciding adjustment.

There is a second issue: selection itself uses random data. If analysts try several covariate sets and report the one that gives the preferred genotype estimate or the smallest genotype p-value, the reported estimate and its ordinary standard error are conditional on an unreported search. Conventional confidence intervals and p-values are calculated as if the reported model had been fixed in advance; they generally do not account for this selection. The resulting uncertainty can be understated, and effect estimates can be exaggerated by choosing a model that happens to produce a large association in that sample.

This does not mean that every use of model comparison is invalid. A prespecified likelihood-ratio test answers a defined nested-model question. AIC or BIC can provide a transparent comparison for a stated candidate set and objective. The concern is treating a data-dependent selection step as though it never happened, or allowing a fit criterion to replace knowledge of the study design and the target association.

A Practical Covariate-Selection Workflow

1
Define the association.
State the phenotype, genetic coding, target population, and the conditional or marginal interpretation sought. Specify a primary covariate set based on design and scientific rationale before examining association results.
2
Fit and report the planned model.
Check that candidate models use the same observations and that the chosen regression form is appropriate. Report the genotype effect and its uncertainty with the covariate set identified.
3
Use comparisons for their stated purpose.
Use a nested-model test for a defined joint null hypothesis, or information criteria to compare relative fit and complexity in a prespecified candidate set. Do not describe either as proof that a covariate is or is not a confounder.
4
Assess sensitivity transparently.
When scientifically reasonable alternative sets exist, report how the genotype estimate and uncertainty change across them. Label such analyses as sensitivity analyses rather than presenting the best-looking model as if it were prespecified.

Common Mistake

  • Wrong reasoning: “This covariate has p=0.12, so it is unrelated to the phenotype and should be removed; the resulting genotype p-value is the valid primary result.”
  • Correction: A covariate p-value does not determine whether adjustment is appropriate. A covariate can be imprecisely associated with the phenotype yet alter the genotype estimate, and selecting variables using the same data can make standard inference ignore the selection step. Base the primary set on the question and design; use comparisons as supporting, explicitly qualified evidence.
Key takeaway: Prespecify a scientifically justified primary covariate set. Nested-model tests and information criteria can answer defined comparison questions, but neither makes p-value-based covariate screening a substitute for sound design or selection-adjusted inference.

Check Your Understanding

Try these questions before reviewing the tutorial.

  1. What two conditions make a likelihood-ratio comparison a nested-model comparison on a common basis?
  2. A full logistic model adds two coefficients and improves maximized log likelihood by 1.4. Calculate the likelihood-ratio statistic and state its null degrees of freedom.
  3. Why can a covariate with a phenotype-association p-value above 0.05 still affect a genotype effect estimate?
  4. For two models fitted to the same sample, what does a lower AIC indicate, and what does it not establish?
  5. Why may the usual standard error and p-value be misleading after choosing the reported covariate set using the same data?
Clinical Biostats