The questionInvented counts

Bayesian vs Frequentist approach (to statistics)

Jessica Cox

A rate above five events per unit seemed plausible enough to investigate. We counted eight events in one unit.

How likely is a rate above five?

The questionWorked example

Two probability questions

At a specified rate

How often would we count eight or more events if the rate were five?

\[\Pr(K\ge 8\mid\lambda=5)\]

After an observed count

Given eight events, how likely is the rate to exceed five?

\[\Pr(\lambda>5\mid K=8)\]
The questionWorked example

The model both analyses use

\[K\mid\lambda,T\sim\mathrm{Poisson}(T\lambda)\]
\[L(\lambda;k,T)\propto\lambda^k e^{-T\lambda}\]

Count \(k=8\). Observation time \(T=1\).

\[\hat\lambda=k/T=8\]
Two approaches to inferenceWorked example

A test of the reference rate

One-sided test for an increase

\[\Pr_{5}(K\ge8)=1-\sum_{j=0}^{7}e^{-5}\frac{5^j}{j!}\]
13.3%

of counts reach eight or more when the reference rate holds.

Frequentist
Two approaches to inferenceWorked example

A confidence interval for the rate

Which rates make eight unusually high or low?

\[\Pr_{\lambda_L}(K\ge8)=0.025\]
\[\Pr_{\lambda_H}(K\le8)=0.025\]

95% confidence interval

[3.45, 15.76]
Frequentist
Two approaches to inferenceWorked example

A posterior probability for the rate

Choose a starting distribution

For illustration, use an exponential prior with mean four events per unit.

\[p(\lambda\mid 8)\propto\underbrace{\lambda^8e^{-\lambda}}_{\text{likelihood}}\;\underbrace{e^{-\lambda/4}}_{\text{prior}}\]

Posterior probability above five

82.0%

18.0% lies at or below five.

Bayesian
Two approaches to inferenceEight events, broad exponential prior

A credible interval for the rate

Leave 2.5% of the posterior in each tail

\[\Pr(\lambda\le L\mid K=8)=0.025\]
\[\Pr(\lambda\le H\mid K=8)=0.975\]

Central 95% credible interval

[3.29, 12.61]
Bayesian
Two approaches to inferenceWorked example

The p-value and the probability of no increase

One-sided p-value

13.3%

At a rate of five, this fraction of repeated counts reach eight or more.

Posterior probability of no increase

18.0%

The remaining posterior area lies at or below five, given eight events and the broad exponential prior.

95% confidence interval[3.45, 15.76]
95% credible interval[3.29, 12.61]
Two approaches to inferenceSimulated repeats and an invented observation

What 95% means in each analysis

Repeated counts at a fixed rate

True rate \(\lambda=5\), time \(T=1\).

The count we actually observed

Eight events, exponential prior.

95% credible interval   [3.29, 12.61]

Two approaches to inferenceWorked example

Prediction for the next count

With the same rate, what is the chance of another count of eight or more?

\[\int \Pr(K_{\rm next}\ge8\mid\lambda)\,p(\lambda\mid8)\,d\lambda\]
41.9%

under the broad exponential prior.

Bayesian
Choices made before observingExample range from 0.25 to 25

What does “anywhere in the range” mean?

Each gap between marks holds 10% of the prior probability.

Flat in rate

Rates between one and two get the same probability as rates between two and three.

Flat in log rate

Rates between one and two get the same probability as rates between two and four. Both ranges span one doubling.

Bayesian
Choices made before observingInvented earlier and current counts

Earlier observations in both analyses

An independent earlier record has four events in one unit. Assume the same rate in both periods.

Frequentist pooling

\[\hat\lambda=(4+8)/(1+1)=6\]
\[\Pr_{5}(K_{T=2}\ge12)=30.3\%\]

Bayesian update

Gamma shape \(a\) and rate \(b\)

\[(a,b)\longmapsto (a+k,b+T)\]
\[\Pr(\lambda\le5\mid k_{\rm old},k_{\rm new})=33.9\%\]
95% confidence interval[3.10, 10.48]
95% credible interval[3.08, 9.32]
Choices made before observingIllustrative earlier result

Using a published upper limit as a prior judgment

The earlier study

Four events in one unit give a one-sided 95% confidence limit.

\[\Pr_{U_0}(K\le4)=0.05\]
\[U_0\simeq 9.15\]

The choice in our analysis

Suppose we give rates above that limit 5% prior probability.

\[\Pr_{\pi}(\lambda>U_0)=0.05\]
\[\lambda\sim\mathrm{Exp}(\mathrm{rate}=b),\quad b=\frac{\log20}{U_0}\]

The earlier result supplies 9.15. We supply the exponential shape and the 5% tail.

Prior sensitivityEight events in one unit

Five priors for the same rate

\[\lambda\sim\mathrm{Exp}(\mathrm{rate}=0.25)\]
Broad exponential
Smaller rates are more likely. The mean and standard deviation are both four.
Earlier counts
Update the broad prior with four events in one earlier unit of time.
Earlier limit
Choose an exponential prior with 5% probability above the earlier limit of 9.15.
Flat in rate
Give equal-width intervals equal probability between 0.25 and 25.
Flat in log rate
Give each doubling equal probability between 0.25 and 25.
Bayesian
Prior sensitivityConstructed records at eight events per unit

The same counts under five priors

Smaller rates are more likely. The mean and standard deviation are both four.

1 unit

\(\Pr(\lambda\le5\mid k)\)
\(\Pr(\lambda>5\mid k)\)
Posterior mean
Central 95% interval
Probability at or below five
Bayesian
Prior sensitivityConstructed records at eight events per unit

Prior influence as observation time increases

Each record has \(k/T=8\).

Spread of the posterior means

One time unit3.22Ten time units0.54

Rates are in events per unit time.

Bayesian
Prior sensitivityGamma prior, Poisson counts

The weight given to earlier information

\[\mathbb E[\lambda\mid k,T]=\frac{b}{b+T}\,\underbrace{\frac ab}_{\text{prior mean}}+\frac{T}{b+T}\,\underbrace{\frac kT}_{\text{observed rate}}\]

For a \(\mathrm{Gamma}(a,b)\) prior, \(b\) acts like prior observation time.

With the earlier-count priorOne time unitTen time units
Prior weight \(b/(b+T)\)55.6%11.1%
Posterior mean5.787.56
Bayesian
Setting a limitConstructed records at eight events per unit

A one-sided 95% upper limit

Posterior upper limits across the five priors

Choose an exponential prior with 5% probability above the earlier limit of 9.15.

1 unit

Confidence limit from the new count

\[\Pr(K\le k\mid\lambda=U_F,T)=0.05\]
14.43

Posterior limit

\[\Pr(\lambda>U_B\mid k,T)=0.05\]
10.88
ConclusionWorked example

Frequentist and Bayesian inference

Frequentist

  • Suppose the rate is five. How often would a repeat count reach eight or more?
  • In the long run, these confidence intervals cover the true rate at least 95% of the time.
  • Pool earlier counts if both records share a rate.
  • A 5% test controls how often we falsely report an increase under the null.

Bayesian

  • Given eight events and a prior, what is the probability that the rate exceeds five?
  • For this count, the credible interval contains 95% of the posterior probability.
  • Use the earlier posterior as the prior for the new count if the rate is shared.
  • Use posterior probabilities to weigh a missed increase (cost \(C\)) against a false alarm (cost \(F\)).
ConclusionEight new events and the illustrative earlier limit

Two mistakes in interpreting frequentist results

Dismissing an increase

\[p=0.133>0.05\]

Ten events per unit, twice the reference rate, lies inside the 95% confidence interval. Stopping here could miss an increase that large.

Treating an upper limit as a hard cutoff

\[U_0\simeq 9.15\]

A prior that ends at this limit gives zero posterior probability to the whole range above it, whatever the next count.

Conclusion

Why we chose to run the experiment

We chose to measure the rate because we thought it might have risen.

That was already a prior judgment. Bayesian analysis lets us say which rates seemed plausible and how the count changed our view.

Bayesian

Questions?

Backup slides

  1. B1A skeptical prior for an increase
  2. B2Costs of missed increases and false alarms
  3. B3Risk aversion with fixed error costs
  4. B4A prior on risk aversion
  5. B5Decisions under the five priors
  6. B6What counts did the priors predict?
  7. B7The value of taking a measurement
  8. B8Counting an earlier record twice
  9. B9Why two upper limits can agree
  10. B10A second look at the count

Press 1–9 for B1–B9 or 0 for B10. Press I to return here.

Backup slides · B1Two illustrative rate priors

A skeptical prior for an increase

In one unit, \(K\mid\lambda\sim\mathrm{Poisson}(\lambda)\). We observe eight events. Both priors are exponential with rate parameter \(b\).

\[\Pr(\lambda>5\mid K=8)=\int_5^\infty \pi(\lambda\mid K=8)\,d\lambda\]

Prior probability of an increase

\[\Pr(\lambda>5)=e^{-5b}\]

The broad prior uses \(b=0.25\). A skeptical prior assigns 10% above five, giving \(b=\log(10)/5\).

Posterior after eight events

\[\pi(\lambda\mid K=8)\propto\lambda^8 e^{-(1+b)\lambda}\]
\[\lambda\mid K=8\sim\mathrm{Gamma}(9,\underbrace{1+b}_{\rm rate})\]
Bayesian
Backup slides · B2Illustrative costs of reporting an increase

Costs of missed increases and false alarms

Eight Poisson events in one unit. Prior \(\lambda\sim\mathrm{Exp}(\mathrm{rate}=0.25)\). Chance of an increase \(p=\Pr(\lambda>5\mid K=8)\simeq 0.820\).

A missed increase costs \(C\), a false alarm costs \(F\), and a correct decision costs zero.

\[\underbrace{F(1-p)}_{\text{expected loss if reporting}}<\underbrace{Cp}_{\text{expected loss if withholding}}\quad\Longleftrightarrow\quad p>\frac{F}{F+C}\]
Miss cost \(C\)False-alarm cost \(F\)Reporting thresholdExpected loss if reportingExpected loss if withholdingChoice
1480.0%0.720.82Report
1990.0%1.620.82Withhold
Bayesian
Backup slides · B3Linear and squared loss

Risk aversion with fixed error costs

Eight Poisson events in one unit. Prior \(\lambda\sim\mathrm{Exp}(\mathrm{rate}=0.25)\). Chance of an increase \(p=\Pr(\lambda>5\mid K=8)\simeq 0.820\).

A sure loss of two units, or an even chance of zero or four

\[2^2=4 \;<\; \tfrac12(0^2+4^2)=8\]

Choose the smaller expected loss

A missed increase costs \(C=1\), a false alarm costs \(F=4\), and a correct decision costs zero.

\[\begin{aligned}R_{\rm report}&=(1-p)\,\ell(F)\\R_{\rm withhold}&=p\,\ell(C)\end{aligned}\]
Penalty \(\ell(x)\)ReportWithhold
\(x\)0.720.82
\(x^2\)2.870.82
Bayesian
Backup slides · B4Uncertain preference for linear or squared loss

A prior on risk aversion

Eight Poisson events in one unit. Prior \(\lambda\sim\mathrm{Exp}(\mathrm{rate}=0.25)\). Chance of an increase \(p=\Pr(\lambda>5\mid K=8)\simeq 0.820\).

\[\begin{gathered}F_w=(1-w)F+wF^2,\quad C_w=(1-w)C+wC^2\\\text{Report if }\ (1-p)F_w<pC_w\ \Longleftrightarrow\ p>\frac{F_w}{F_w+C_w}\end{gathered}\]

A missed increase costs \(C=1\), a false alarm costs \(F=4\), and a correct decision costs zero.

\[\ell_\gamma(x)=x^\gamma,\quad \gamma\in\{1,2\},\quad \Pr(\gamma=2)=w\]

Take \(\gamma\) independent of the event rate.

Mean false-alarm penalty \(F_w\)
Reporting threshold
Decision
Bayesian
Backup slides · B5Two illustrative records at eight events per unit

Decisions under the five priors

For \(K\mid\lambda,T\sim\mathrm{Poisson}(T\lambda)\), compare eight events in one unit with eighty in ten units.

\[p_\pi=\Pr_\pi(\lambda>5\mid k,T)=\frac{\int_5^\infty \lambda^k e^{-T\lambda}\pi(\lambda)\,d\lambda}{\int_0^\infty \lambda^k e^{-T\lambda}\pi(\lambda)\,d\lambda}\]

Rule for reporting an increase

A missed increase costs \(C=1\), a false alarm costs \(F=9\), and a correct decision costs zero.

\[F(1-p_\pi)<Cp_\pi\iff p_\pi>\frac{F}{F+C}=0.90\]

Priors that favour reporting

After one unit1 of 5After ten units5 of 5
Bayesian
Backup slides · B6Prior predictive distribution for one unit

What counts did the priors predict?

Before observing a count, take \(K\mid\lambda\sim\mathrm{Poisson}(\lambda)\) for one unit and \(\lambda\sim\mathrm{Exp}(b)\) with rate parameter \(b\).

\[\Pr_b(K=k)=\int_0^\infty \underbrace{\frac{e^{-\lambda}\lambda^k}{k!}}_{\text{count at rate }\lambda}\underbrace{b e^{-b\lambda}}_{\text{prior density}}\,d\lambda=\frac{b}{(1+b)^{k+1}}\]

Chance of eight or more events

\[\sum_{k=8}^\infty \Pr_b(K=k)=(1+b)^{-8}\]
Broad \(b=0.25\)16.8%Skeptical \(b=\log(10)/5\)4.8%
Bayesian
Backup slides · B7Expected loss before observing any data

The value of taking a measurement

Plan one unit with \(\lambda\sim\mathrm{Exp}(\mathrm{rate}=0.25)\) and \(K\mid\lambda\sim\mathrm{Poisson}(\lambda)\). A missed increase costs \(C=1\), a false alarm costs \(F=4\), and a correct decision costs zero.

Decide before counting

If \(p\) is the chance that the rate exceeds five, report when \(p>F/(F+C)=0.8\).

\[r(p)=\min\{\underbrace{F(1-p)}_{\text{report}},\ \underbrace{Cp}_{\text{withhold}}\}\]
\[p_{\rm prior}=e^{-0.25\times5},\qquad R_{\rm before}=r(p_{\rm prior})\]
0.287

Count first, then decide

\[\lambda\mid K=k\sim\mathrm{Gamma}(k+1,\underbrace{1.25}_{\rm rate})\]
\[\text{Report if }\underbrace{\Pr(\lambda>5\mid k)}_{p_k}>0.8\iff k\ge 8\]
\[R_{\rm after}=\sum_{k=0}^\infty \underbrace{0.2(0.8)^k}_{\Pr(K=k)}\,r(p_k)\]
0.172

Counting saves \(R_{\rm before}-R_{\rm after}\simeq 0.115\) expected loss units before the cost of the measurement.

Bayesian
Backup slides · B8Two one-unit records, a common rate

Counting an earlier record twice

Given a common rate \(\lambda\), two independent one-unit Poisson counts yield four earlier events and eight new events. Start with \(\lambda\sim\mathrm{Exp}(\mathrm{rate}=0.25)\).

\[\pi_m(\lambda)\propto \underbrace{e^{-0.25\lambda}}_{\text{prior}}\;\underbrace{(\lambda^4e^{-\lambda})^m}_{m\text{ copies of the earlier likelihood}}\;\underbrace{\lambda^8e^{-\lambda}}_{\text{new likelihood}}\]
Uses of the earlier countGamma shape \(a\), rate \(b\)Mean rateCentral 95% credible interval
Once\((a,b)=(13,\,2.25)\)5.78[3.08, 9.32]
Twice in error\((a,b)=(17,\,3.25)\)5.23[3.05, 7.99]
\[a=9+4m,\qquad b=1.25+m,\qquad \mathbb E_m[\lambda]=a/b\]
Bayesian
Backup slides · B9Eight events in one unit

Why two upper limits can agree

For \(K\mid\lambda,T\sim\mathrm{Poisson}(T\lambda)\), the improper flat prior on \(\lambda>0\) gives a \(\mathrm{Gamma}(k+1,T)\) posterior with rate parameter \(T\).

\[S(u)=\underbrace{\Pr(\lambda>u\mid k,T)}_{\text{flat-prior posterior tail}}=e^{-Tu}\sum_{j=0}^{k}\frac{(Tu)^j}{j!}=\underbrace{\Pr(K\le k\mid\lambda=u,T)}_{\text{Poisson sampling tail}}\]
95% upper limitEquation for \(u\), with \(k=8,\ T=1\)Rate
Exact Poisson confidence limit\(\Pr(K\le 8\mid\lambda=u)=0.05\)14.43465
Posterior, flat on \((0,\infty)\)\(S(u)=0.05\)14.43465
Posterior, flat on \([0.25,25]\)\(\dfrac{S(u)-S(25)}{S(0.25)-S(25)}=0.05\)14.43180
Backup slides · B10Two planned tests under a constant rate

A second look at the count

At the reference rate, independent one-unit counts satisfy \(X,Y\sim\mathrm{Poisson}(5)\), so \(X+Y\sim\mathrm{Poisson}(10)\).

At each look, use the smallest count whose upper-tail probability is at most 5%.

When we testReport an increase ifFalse-alarm probability
After two units\(X+Y\ge 16\)4.87%
After one or two units\(X\ge 10\) or \(X+Y\ge 16\)6.46%
\[\begin{aligned}\Pr(\text{report at either look})&=\underbrace{\Pr(X\ge10)}_{\text{early report}}+\underbrace{\sum_{x=0}^{9}\Pr(X=x)\Pr(Y\ge16-x)}_{\text{first report at the final look}}\\&\simeq 3.18\%+3.28\%=6.46\%\end{aligned}\]
Frequentist

All speaker notes