Tutorials › Statistical Genetics › Logistic Regression for Binary Traits

Single-Variant Association Tests · Tutorial 308 of 989

Logistic Regression for Binary Traits

Learn how genotype dosage and genotype indicators enter a logistic model, and how to translate its linear predictor into conditional probabilities.

Intermediate 9 min read

What You'll Learn

  • Define a binary phenotype as a Bernoulli response conditional on genotype
  • Write the logistic model using allele-count dosage
  • Convert a linear predictor into a conditional probability with the inverse-logit function
  • Specify a genotype-indicator model and identify its reference group
  • Distinguish a linear dosage effect on the logit scale from unrestricted genotype-specific effects
  • Recognize key modeling assumptions and common interpretation errors

Why Model a Binary Trait on the Logistic Scale?

A binary phenotype records one of two outcomes, such as affected or unaffected. A regression model for such an outcome should produce fitted values between 0 and 1, because those values represent conditional probabilities. Ordinary linear regression does not enforce that restriction: its fitted values can fall below 0 or above 1. Logistic regression instead models a transformation of the probability, allowing its predictor to range over all real numbers while the resulting probability remains valid.

In single-variant association, the predictor can be an individual's genotype dosage or a set of indicators for their genotype category. Those choices impose different patterns across the three usual genotype groups. The key is to state the coding and model clearly before interpreting a fitted value.

Definition: Let \(Y\) be a binary phenotype coded \(1\) for the outcome of interest and \(0\) otherwise, and let \(G\) denote genotype information. The conditional probability of the outcome is \(p(G)=P(Y=1\mid G)\). The logit link is \(\operatorname{logit}(p)=\log\!\left(\frac{p}{1-p}\right)\). A logistic regression specifies this logit as a linear predictor.

The Dosage Logistic Model

For a biallelic variant, let \(G\) be the count of a chosen effect allele, so an individual's genotype dosage is ordinarily 0, 1, or 2. A basic additive dosage model is

$$ Y_i\mid G_i \sim \operatorname{Bernoulli}(p_i), \qquad \operatorname{logit}(p_i)=\beta_0+\beta_1G_i, \qquad p_i=P(Y_i=1\mid G_i). $$

Here \(\beta_0\) is the logit of the conditional probability when \(G_i=0\), and \(\beta_1\) is the change in logit for a one-unit increase in dosage. The model's additive restriction is on the logit scale: the predicted logit at dosage 1 lies halfway between the predicted logits at dosages 0 and 2. It does not say that the probabilities themselves are equally spaced.

To obtain a probability from a predictor value \(\eta\), solve the definition of the logit for \(p\):

$$ \eta=\log\!\left(\frac{p}{1-p}\right) \quad\Longrightarrow\quad e^\eta=\frac{p}{1-p} \quad\Longrightarrow\quad p=\frac{e^\eta}{1+e^\eta} =\frac{1}{1+e^{-\eta}}. $$

This inverse-logit function maps every finite real predictor to a probability strictly between 0 and 1. Thus, for the dosage model, the conditional probability at a specified dosage is \(P(Y=1\mid G=g)=1/\{1+\exp[-(\beta_0+\beta_1g)]\}\).

Worked Example: Conditional Probabilities From a Dosage Model

Suppose a hypothetical analysis uses \(G=0,1,2\) and specifies \(\beta_0=-2.00\) and \(\beta_1=0.55\). Calculate the model-predicted probability of the binary outcome for each dosage.

For dosage \(G=0\), the linear predictor is \(\eta=-2.00+0.55(0)=-2.00\). Therefore, \(p=1/[1+\exp(2.00)]=1/(1+7.3891)=0.1192\).

For dosage \(G=1\), \(\eta=-2.00+0.55(1)=-1.45\), so \(p=1/[1+\exp(1.45)]=1/(1+4.2631)=0.1900\).

For dosage \(G=2\), \(\eta=-2.00+0.55(2)=-0.90\), giving \(p=1/[1+\exp(0.90)]=1/(1+2.4596)=0.2891\).

These are probabilities conditional on genotype under the specified model. The predicted probabilities are not separated by a constant amount: the increase from dosage 0 to 1 is about 0.0708, while the increase from 1 to 2 is about 0.0991. The model's constant increment is \(0.55\) on the logit scale, not on the probability scale.

A Genotype-Indicator Model

The dosage model imposes a particular relationship among the three genotype groups. To allow each group its own conditional probability, use indicators for the non-reference genotypes. Let \(I_{1i}=1\) if individual \(i\) has dosage 1 and \(0\) otherwise, and let \(I_{2i}=1\) if dosage is 2 and \(0\) otherwise. Dosage 0 is the reference group. The model is

$$ Y_i\mid G_i \sim \operatorname{Bernoulli}(p_i), \qquad \operatorname{logit}(p_i) =\beta_0+\beta_1 I_{1i}+\beta_2 I_{2i}. $$

For dosage 0, both indicators equal zero, and the predictor is \(\beta_0\). For dosage 1, the predictor is \(\beta_0+\beta_1\); for dosage 2, it is \(\beta_0+\beta_2\). Thus the model estimates a logit for each genotype group without requiring the dosage-1 logit to be halfway between the other two. The indicators must be defined so that they do not include an additional indicator for the reference group along with an intercept; that redundant coding would make the parameters non-identifiable.

Worked Example: Predicting by Genotype Category

Consider a hypothetical indicator model with dosage 0 as the reference and coefficients \(\beta_0=-1.50\), \(\beta_1=0.40\), and \(\beta_2=1.10\). Find the conditional outcome probability for each genotype.

At dosage 0, \(I_1=I_2=0\), so \(\eta=-1.50\). The probability is \(1/[1+\exp(1.50)]=1/(1+4.4817)=0.1824\).

At dosage 1, \(I_1=1\) and \(I_2=0\), so \(\eta=-1.50+0.40=-1.10\). The probability is \(1/[1+\exp(1.10)]=1/(1+3.0042)=0.2497\).

At dosage 2, \(I_1=0\) and \(I_2=1\), so \(\eta=-1.50+1.10=-0.40\). The probability is \(1/[1+\exp(0.40)]=1/(1+1.4918)=0.4013\).

The three probabilities are conditional predictions under this indicator model. Unlike the dosage model, the indicator model does not force a single linear trend in genotype dosage on the logit scale.

What the Models Assume

A logistic regression model is more than a formula for converting a predictor to a probability. Its use relies on a response and sampling structure as well as on the chosen form of the conditional mean.

  • Binary outcome coding: each \(Y_i\) is 0 or 1, with 1 denoting the outcome whose probability is modeled.
  • Bernoulli response model: conditional on the modeled predictors, each response has a Bernoulli distribution with success probability \(p_i\). For the simple likelihood calculation below, observations are assumed independent conditional on their genotypes.
  • Correct predictor form: the dosage model assumes that the conditional logit is linear in dosage. The indicator model instead assigns a separate logit to each of the three genotype groups.
  • Meaningful genotype coding: the effect allele and dosage scale must be specified consistently. If the counted allele is changed, the interpretation of the dosage predictor changes as well.

These specifications describe an association model, not a causal conclusion. A conditional probability from a model is a prediction for individuals with a given genotype under the model; by itself, it does not show that changing genotype would change an individual's outcome. Also, when observations are dependent—for example, because sampled individuals are related—the simple independent-observation likelihood is not an adequate description without an appropriate extension.

Why the Indicator Model Can Match Group Proportions

A short likelihood derivation explains how an indicator model behaves when it is fitted to grouped binary observations. Suppose one genotype group contains \(y\) outcomes coded 1 and \(m-y\) outcomes coded 0, where \(m\) is the group's total. If the group's probability is \(p\), the Bernoulli likelihood, apart from a factor not involving \(p\), is \(p^y(1-p)^{m-y}\). Its log-likelihood is

$$ \ell(p)=y\log(p)+(m-y)\log(1-p). $$

Differentiating and setting the derivative equal to zero gives

$$ \frac{d\ell}{dp} =\frac{y}{p}-\frac{m-y}{1-p}=0 \quad\Longrightarrow\quad y(1-p)=p(m-y) \quad\Longrightarrow\quad \widehat p=\frac{y}{m}. $$

When each genotype category has its own logit, the three group probabilities can be estimated separately in this way, provided each group contains both outcomes. This result illustrates why the indicator model can reproduce the observed outcome fraction within each genotype group. It does not imply that those sample fractions are exact population probabilities; they remain estimates from finite data.

Worked Example: Fitting an Indicator Model to Grouped Counts

Suppose a hypothetical cohort has these binary outcomes: among 10 individuals with dosage 0, 2 have \(Y=1\); among 10 with dosage 1, 4 have \(Y=1\); and among 10 with dosage 2, 6 have \(Y=1\). Fit the genotype-indicator model's group probabilities and write its coefficients.

The group fractions are \(\widehat p_0=2/10=0.20\), \(\widehat p_1=4/10=0.40\), and \(\widehat p_2=6/10=0.60\). The derivation above shows that, for a separate probability in each group, these fractions maximize the Bernoulli likelihood.

Convert each fraction to its fitted logit. For dosage 0, \(\widehat\eta_0=\log(0.20/0.80)=\log(0.25)=-1.3863\). For dosage 1, \(\widehat\eta_1=\log(0.40/0.60)=\log(2/3)=-0.4055\). For dosage 2, \(\widehat\eta_2=\log(0.60/0.40)=\log(1.5)=0.4055\).

With dosage 0 as the reference, \(\widehat\beta_0=\widehat\eta_0=-1.3863\). The dosage-1 indicator coefficient is \(\widehat\beta_1=\widehat\eta_1-\widehat\eta_0=-0.4055-(-1.3863)=0.9808\). The dosage-2 indicator coefficient is \(\widehat\beta_2=\widehat\eta_2-\widehat\eta_0=0.4055-(-1.3863)=1.7918\). Substituting these coefficients gives fitted probabilities 0.20, 0.40, and 0.60 for the three categories. Each genotype group has both outcomes, so the group logits are finite.

Choosing and Interpreting the Predictor

The dosage model is compact and represents a linear change in the conditional logit for each additional counted allele. It is appropriate when that additive pattern on the logit scale is the intended model. The genotype-indicator model uses more parameters but does not impose that pattern. Neither coding is automatically correct for every variant or phenotype; the choice expresses a model for how the three genotype groups relate to the outcome.

In either model, first calculate the linear predictor for the genotype of interest, then apply the inverse-logit to obtain \(P(Y=1\mid G)\). A coefficient on the logit scale is not a fixed change in probability. The probability change associated with the same logit increment can differ across starting probabilities, as the dosage example demonstrated. Keep the modeled quantity explicit: \(\beta_0\) in the dosage model refers to dosage 0, while in the indicator model \(\beta_1\) and \(\beta_2\) are category-specific additions relative to the dosage-0 reference logit.

Common Mistakes

  • Treating the linear predictor as a probability. A value such as \(-0.90\) is a logit, not a probability. Apply \(1/[1+\exp(-\eta)]\) to obtain the corresponding probability.
  • Calling the dosage coefficient a per-allele probability increase. The dosage model adds \(\beta_1\) to the logit per dosage unit. Its probability changes depend on the starting logit.
  • Assuming indicator coefficients describe a linear dosage trend. Each coefficient compares one genotype category's logit with the reference category's logit. The model does not require the dosage-1 category to sit halfway between dosages 0 and 2.
  • Changing the reference without changing the interpretation. In an indicator model, the intercept is the reference group's logit. A different reference coding changes the coefficient meanings.
  • Equating conditional association with causation. A fitted probability describes the model's conditional distribution; it does not, on its own, establish a causal effect of genotype.
Key takeaway: Logistic regression models the conditional logit of a binary outcome. A dosage predictor imposes a linear logit trend across allele counts; genotype indicators allow separate logits for the three genotype groups. Convert each resulting predictor to a probability with the inverse-logit function.

Check Your Understanding

Use the definitions and calculations above to answer these questions.

  1. In a dosage model with \(\beta_0=-1\) and \(\beta_1=0.3\), what is the linear predictor for dosage 2, and how would you convert it to a conditional probability?
  2. What logit does the intercept represent in an indicator model using dosage 0 as the reference?
  3. Why does a dosage model's constant per-allele increment on the logit scale not imply equal probability increments?
  4. For an indicator model, what do the two non-reference genotype indicators equal for an individual with dosage 0?
  5. Why can the indicator model reproduce the observed outcome fraction in each genotype group when both outcomes occur in each group?
Clinical Biostats