Math Atom · M-C12

Conditional probability and Bayes' rule

10 minMath AtomProbability

By the end you will be able to

  1. 1Compute a conditional probability P(A | B) from counts or from P(A and B) / P(B), and tell it apart from P(B | A).
  2. 2Use the multiplication rule and the law of total probability to build P(S) from its parts.
  3. 3Apply Bayes' rule, in probability and in odds form, to update a borrower's PD when a signal fires or stays quiet.
  4. 4Explain why a good signal on a rare event gives mostly false alarms, and avoid base-rate neglect.

Why you need it

The bank's early-warning system flags a borrower. The flag catches most firms that later default. So is this borrower now likely to default? Usually not, and Bayes' rule says by how much the news should move the PD.

These Core Path lessons use it:

You need percentages from M-A01: Percentages and the rules for “and”, “or” and independence from M-C01: Probability basics. Chains of conditional probabilities, one year after another, are M-C13: Markov chains and transition matrices.

The idea

Shrink the world, then count

A conditional probability answers a question about a smaller world: of the borrowers that were flagged, what share default? Picture 1,000 borrowers and a flag that catches 60% of defaulters but also fires on 5% of everyone else. Step through the views.

A thousand borrowers and one flag

illustrative

Step through

no default

1,000 borrowers, all looking alike today. Each has a 2% chance of defaulting within the year: the prior.

P(D), the prior2.0%
P(D | flag)?
P(flag | D)?

Only 12 of the 61 flags are on defaulters. The flag is good at catching defaulters, yet most of the borrowers it flags are fine, because there are 49 times as many survivors as defaulters to raise false alarms. Gigerenzer and Hoffrage (1995) found that people get problems like this right far more often when they are given counts like these instead of percentages, so the rest of the page uses both.

The rules

Conditional probability. Restrict the world to what you know, and rescale.

Total probability. To get the overall chance of a flag, add up the flags on defaulters and on survivors, using the hit rate and the false-alarm rate.

Bayes' rule. Turn “how often defaulters are flagged” into “how often the flagged default”. The prior goes in, the posterior comes out, and in odds the likelihood ratio does all the work.

The rules, for reference

P(D∣S)=P(D and S)P(S)P(D and S)=P(S∣D) P(D)P(D \mid S) = \frac{P(D \text{ and } S)}{P(S)} \qquad P(D \text{ and } S) = P(S \mid D)\,P(D)
P(S)=P(S∣D) P(D)+P(S∣not D) P(not D)P(S) = P(S \mid D)\,P(D) + P(S \mid \text{not } D)\,P(\text{not } D)
P(D∣S)=h ph p+f (1−p)P(D∣S)1−P(D∣S)=hf×p1−pP(D \mid S) = \frac{h\,p}{h\,p + f\,(1-p)} \qquad \frac{P(D \mid S)}{1 - P(D \mid S)} = \frac{h}{f} \times \frac{p}{1-p}

With p the prior, h = P(S | D) and f = P(S | not D). In the calculator, write the rates as decimals: h * p / (h * p + f * (1 - p)).

Try it

Pick a borrower's grade on RiskAtoms Bank's master scale from the Module 3.3 book (illustrative), then set how good the flag is. Things to try: move the grade from 1 to 10 with the flag fixed and watch the posterior; push the false-alarm rate down to 0.5% and see how much more a flag then says; switch on the second signal.

Try itUpdate a PD when the flag fires

Open the probability calculator →

A covenant breach as well? (h 50%, f 4%)

prior after the flag if the flag stays quiet
123456789100.01%0.1%1%10%100%

One-year PD on a log scale; the boxes are the bank's ten grades (illustrative master scale).

The first flag as counts: 10,000 borrowers like this one

Borrowers

10,000

default

113

no default

9,887

flagged

68

quiet

45

flagged

494

quiet

9,393

Flagged: 68 + 494 = 562, of which 68 default: 12.06%.

Prior PD1.13%
Likelihood ratio h / f12
Prior odds0.0114
Posterior odds0.1371
PD after the flag12.06%
Grade it falls in9
PD if the flag stays quiet0.48%

Worked examples

1. Reading a two-way table

Step 1 of 4
  1. 1

    The set-up

    A lender's records for last year (illustrative): 2,000 corporate borrowers, whether each was on the watchlist at the start of the year, and whether it defaulted during the year.

    On the watchlistNot on itTotal
    Defaulted181230
    Did not default1021,8681,970
    Total1201,8802,000

2. Bramwick Stores raises a flag

Step 1 of 5
  1. 1

    The set-up

    In the Module 3.3 book, Bramwick Stores plc is rated grade 6, with a one-year PD of 1.13%. This month its early-warning flag fires. Over past years the flag fired on 60% of borrowers that went on to default within a year and on 5% of those that did not (illustrative rates). What is its PD now?

3. Same flag, different borrowers, and a second signal

Step 1 of 5
  1. 1

    The set-up

    The same flag (likelihood ratio 0.6 / 0.05 = 12) fires on borrowers in each grade of the master scale. How far does each PD move?

Master scale: 10 grades from the Module 3.3 book. All rates and borrowers are illustrative.

Common mistakes

Each line below is a tempting slip. Spot what is wrong, then check.

Reaction

Check what stuck

Question 1 · objective 1

Of 300 borrowers flagged last year, 45 defaulted. Estimate P(default | flagged), as a percentage. (1 decimal place)

Question 2 · objective 2

A grade has PD 2%. A signal fires on 80% of defaulters and 10% of non-defaulters. How often does it fire overall, as a percentage? (1 decimal place)

Question 3 · objective 3

Same borrower and signal: the signal fires. What is the PD now, as a percentage? (2 decimal places)

Question 4 · objective 4

The same early-warning flag fires on a grade 2 borrower and on a grade 9 borrower. Which statement is right?

Question 5 · objective 3

Prior odds of default are 1 to 99. A signal with likelihood ratio 20 fires. What is the posterior probability of default, as a percentage? (1 decimal place)

Glossary

Conditional probability
P(A | B), read “A given B”: the probability of A once you know B has happened. P(A | B) = P(A and B) / P(B).
Law of total probability
P(S) = P(S | D)P(D) + P(S | not D)P(not D): the overall probability of S as a weighted average over the cases that cover every outcome.
Bayes' rule
P(D | S) = P(S | D)P(D) / P(S). It turns a probability of the evidence given the cause into a probability of the cause given the evidence.
Prior
The probability of an event before the new information, such as the PD of the borrower's grade.
Posterior
The probability of the event after taking the new information into account, P(D | S).
Hit rate
Hit rate: the share of defaulters that the signal flagged beforehand, P(S | D). Also called sensitivity.
False-alarm rate
False-alarm rate: the share of borrowers that did not default but were flagged anyway, P(S | not D).
Likelihood ratio
Likelihood ratio: P(S | D) / P(S | not D), how many times more likely the signal is on a defaulter than on a survivor.
Odds
Odds of an event: p / (1 − p). A probability of 20% is odds of 0.25, or 1 to 4.
Base-rate neglect
Base-rate neglect: judging P(D | S) from how good the signal looks while ignoring how rare D was to start with.