Tutorials › Generalized Linear Models › Bernoulli Responses in Canonical Form

Exponential-Family Representation · Tutorial 27 of 981

Bernoulli Responses in Canonical Form

Express a single Bernoulli response in canonical form and see how its log-odds parameter, log-partition function, and base measure fit together.

Beginner 9 min read

What You'll Learn

  • Convert a Bernoulli success probability into its canonical log-odds parameter
  • Identify the response statistic and log-partition function in the canonical representation
  • Distinguish the counting base measure from the carrier term on the Bernoulli support
  • Verify normalization for every finite canonical parameter
  • Derive the Bernoulli mean and variance directly from the canonical form
  • Recognize why probabilities zero and one are not represented by finite canonical parameters

Why Write a Bernoulli Response in Canonical Form?

A binary response records one of two outcomes, conventionally coded \(Y=0\) or \(Y=1\). Its probability model is simple, but putting it in exponential-family form makes explicit how the outcome enters the likelihood and which function normalizes the probabilities. This representation is also the starting point for later GLM work with binary responses; here the focus is the probability model for one response, not a regression model.

Let \(Y\) have a Bernoulli distribution with success probability \(p\), where \(0<p<1\). Its mass is \(P(Y=1)=p\) and \(P(Y=0)=1-p\). The canonical parameter will be the log-odds, denoted by \(\eta\). The strict inequalities on \(p\) matter: they ensure that \(\eta\) is finite.

Definition: For a Bernoulli response with \(0<p<1\), define the canonical parameter by \(\eta=\log\!\left(\frac{p}{1-p}\right)\). Its inverse relation is \(p=\frac{e^\eta}{1+e^\eta}\). In canonical exponential-family form, the response statistic is \(T(y)=y\), the log-partition function is \(A(\eta)=\log(1+e^\eta)\), and the carrier term is \(h(y)=1\) on \(y\in\{0,1\}\) and \(0\) otherwise.

Deriving the Canonical Representation

For \(y\in\{0,1\}\), the Bernoulli mass function can be written in a single expression:

$$ f(y;p)=p^y(1-p)^{1-y}. $$

Take logarithms of the two factors, then collect the terms that depend on \(y\):

$$ \begin{aligned} \log f(y;p) &=y\log p+(1-y)\log(1-p)\\ &=y\log\!\left(\frac{p}{1-p}\right)+\log(1-p). \end{aligned} $$

By definition, \(\eta=\log\!\left(\frac{p}{1-p}\right)\). Solving this equation for \(p\) gives \(p=e^\eta/(1+e^\eta)\), and therefore \(1-p=1/(1+e^\eta)\). Hence \(\log(1-p)=-\log(1+e^\eta)\). Substitution yields the canonical form:

$$ f(y;\eta)=\exp\!\left\{y\eta-\log(1+e^\eta)\right\},\qquad y\in\{0,1\}. $$

This is the one-parameter exponential-family expression \(\exp\{T(y)\eta-A(\eta)\}\) on the Bernoulli support. Thus \(T(y)=y\) and \(A(\eta)=\log(1+e^\eta)\). There is no additional parameter-dependent dispersion factor in this single Bernoulli form.

Base measure and carrier: The sample space is \(\{0,1\}\), equipped with counting measure: each point has measure one. Relative to that measure, the Bernoulli density is its probability mass function. The carrier term is \(h(y)=1\) on \(\{0,1\}\) and \(h(y)=0\) outside it. Consequently, on the support the mass can be written \(h(y)\exp\{y\eta-A(\eta)\}\); outside the support it is zero. The carrier does not depend on \(\eta\).

In a discrete model, it is useful to keep two ideas separate. The counting measure specifies how probabilities are summed over possible outcomes. The carrier term records the support in the density expression relative to that measure. Here the carrier equals one at both allowed outcomes, so it does not change either mass; it makes explicit that the response can only be zero or one.

Normalization and the Natural Parameter

A log-partition function is the term that makes the exponential expression sum to one. For this Bernoulli model, normalization follows directly from the two possible outcomes.

Theorem: For every finite \(\eta\in\mathbb{R}\), the canonical Bernoulli masses are nonnegative and sum to one. The associated success probability is \(p=e^\eta/(1+e^\eta)\), which lies strictly between zero and one.

Proof. Since \(e^\eta>0\), the denominator \(1+e^\eta\) is positive and \(p=e^\eta/(1+e^\eta)\) is strictly between zero and one. Evaluating the canonical expression at both possible outcomes gives

$$ \begin{aligned} f(0;\eta)+f(1;\eta) &=\exp\{-A(\eta)\}+\exp\{\eta-A(\eta)\}\\ &=\frac{1}{1+e^\eta}+\frac{e^\eta}{1+e^\eta}\\ &=1. \end{aligned} $$

Each term is positive, so these are valid masses. The first is \(1-p\), and the second is \(p\), as claimed. \(\square\)

The finite natural-parameter space is therefore all of \(\mathbb{R}\): \(A(\eta)=\log(1+e^\eta)\) is finite for every real \(\eta\). Conversely, every \(p\in(0,1)\) gives a finite \(\eta\). The endpoints \(p=0\) and \(p=1\) correspond only to limits \(\eta\to-\infty\) and \(\eta\to+\infty\), not to finite values in this parameterization.

What the Log-Partition Function Encodes

For the Bernoulli model, \(A(\eta)\) does more than normalize the masses: its first two derivatives give the response mean and variance. These identities can be verified directly without appealing to a general result about exponential families.

Theorem: In the canonical Bernoulli model, \(A'(\eta)=E[Y]=p\) and \(A''(\eta)=\operatorname{Var}(Y)=p(1-p)\), where \(p=e^\eta/(1+e^\eta)\).

Proof. Differentiate \(A(\eta)=\log(1+e^\eta)\):

$$ A'(\eta)=\frac{e^\eta}{1+e^\eta}=p. $$

Because \(Y\) is one for a success and zero otherwise, \(E[Y]=1\cdot p+0\cdot(1-p)=p\). Differentiating once more gives

$$ A''(\eta)=\frac{e^\eta}{(1+e^\eta)^2} =\frac{e^\eta}{1+e^\eta}\frac{1}{1+e^\eta} =p(1-p). $$

Also \(Y^2=Y\) for both possible values, so \(E[Y^2]=p\). Therefore

$$ \operatorname{Var}(Y)=E[Y^2]-(E[Y])^2=p-p^2=p(1-p)=A''(\eta). $$

This proves both identities for the Bernoulli response. \(\square\)

The variance is positive for every finite \(\eta\), since then \(0<p<1\). It approaches zero as \(p\) approaches either endpoint. These are properties of this particular response distribution; the calculation above does not require a general theorem about derivatives of log-partition functions.

Worked Representations

Worked Example: Converting a Success Probability to Canonical Form

Suppose \(Y\) is Bernoulli with \(p=0.2\). Find \(\eta\), \(A(\eta)\), and the two canonical masses.

The odds of success are \(p/(1-p)=0.2/0.8=0.25=1/4\). Thus \(\eta=\log(1/4)=-\log 4\), approximately \(-1.3863\). The log-partition value is \(A(\eta)=\log(1+e^\eta)=\log(1+1/4)=\log(5/4)\), approximately \(0.2231\).

For \(y=1\), \(f(1;\eta)=\exp\{\eta-A(\eta)\}=\exp\{\log(1/4)-\log(5/4)\}=1/5=0.2\). For \(y=0\), \(f(0;\eta)=\exp\{-A(\eta)\}=\exp\{-\log(5/4)\}=4/5=0.8\). The masses sum to \(0.2+0.8=1\), as required.

Worked Example: Starting From a Canonical Parameter

Let \(\eta=\log 3\). Recover the Bernoulli probability and check the canonical masses.

Since \(e^\eta=3\), the inverse log-odds relation gives \(p=3/(1+3)=3/4\). The log-partition value is \(A(\eta)=\log(1+3)=\log 4\). The mass at one is \(f(1;\eta)=\exp\{\log 3-\log 4\}=3/4\), and the mass at zero is \(f(0;\eta)=\exp\{-\log 4\}=1/4\).

Their ratio is \(f(1;\eta)/f(0;\eta)=3\), which agrees with the odds \(p/(1-p)=(3/4)/(1/4)=3=e^\eta\).

Worked Example: Evaluating a Single-Response Likelihood Contribution

Suppose \(p=0.6\) and the observed response is \(y=0\). Find the canonical parameter and evaluate the likelihood contribution in both forms.

The odds are \(0.6/0.4=1.5\), so \(\eta=\log(1.5)\). Also \(A(\eta)=\log(1+1.5)=\log(2.5)\). In the original Bernoulli form, the likelihood contribution is \(f(0;p)=1-p=0.4\).

In canonical form, it is \(f(0;\eta)=\exp\{0\cdot\eta-A(\eta)\}=\exp\{-\log(2.5)\}=1/2.5=0.4\). Its log-likelihood contribution is \(\ell(\eta)=\log f(0;\eta)=-\log(2.5)\), approximately \(-0.9163\), which also equals \(\log(0.4)\).

Common Mistakes and Interpretation

  • Using \(p\) as the canonical parameter. The canonical parameter here is \(\eta=\log(p/(1-p))\), not \(p\). The probability is recovered from \(\eta\) by \(p=e^\eta/(1+e^\eta)\).
  • Dropping the log-partition term. Writing \(\exp(y\eta)\) alone does not give probabilities that sum to one. The subtraction of \(A(\eta)\) supplies the required normalization.
  • Putting the sign on the wrong term. The canonical exponent is \(y\eta-A(\eta)\), with \(A(\eta)=\log(1+e^\eta)\). For \(y=0\), this yields \(1/(1+e^\eta)\); for \(y=1\), it yields \(e^\eta/(1+e^\eta)\).
  • Treating the base measure as the log-partition function. The base measure here is counting measure on the two-point sample space; the carrier is one on the support. The log-partition function is the parameter-dependent term \(A(\eta)\).
  • Assuming the endpoints have finite log-odds. If \(p=0\) or \(p=1\), the logit formula is not finite. The regular canonical representation uses \(0<p<1\) and finite \(\eta\).

The canonical form separates the response-dependent statistic \(y\eta\) from the parameter-dependent normalizer \(A(\eta)\). For a single binary response, that separation is especially transparent because the statistic is simply the observed value itself. It also makes checking a proposed expression straightforward: evaluate it at zero and one, verify that the masses are \(1-p\) and \(p\), and confirm that they sum to one.

Check Your Understanding

Use the canonical representation to answer each question.

  1. For a Bernoulli response with \(p=0.4\), calculate \(\eta\) and \(A(\eta)\).
  2. Given \(\eta=0\), find \(p\), then evaluate \(f(0;\eta)\) and \(f(1;\eta)\).
  3. State the response statistic, log-partition function, sample space, and base measure for the single Bernoulli response.
  4. Why does \(\exp(y\eta)\) by itself fail to be the Bernoulli probability mass function?
  5. What limits of \(\eta\) correspond to \(p\) approaching zero and one?
Clinical Biostats