Originally posted: 2023-10-18. Live edit this notebook here.

# #Visualising Bayes Theorem and its application to the Fellegi Sunter model

This visualisation aims to clarify the intuition behind the following formula from the Fellegi Sunter model, which was presented in the article on the maths of Fellegi Sunter in the main tutorial.

$\text{posterior match probability} = \frac{\lambda m }{\lambda m + (1 - \lambda) u}$

where

$\lambda = \text{prior match probability}$

and the m and u probabilities are defined in relation to a scenario:

$m = \text{Pr}(\text{scenario}|\text{records match})$

$u = \text{Pr}(\text{scenario}|\text{records do not match})$

This article also explains why it's just a re-statement of Bayes Theorem.

## #Visualising the parameters in a treemap

Recall that the prior is the probability that two random records match, which is one of the parameters to be estimated.

We can visualise this parameter by showing how it divides the set of all pairwise record comparisons:

Using the definition of the m and u probabilities above, we can further subdivide this space as follows:

Given our observation that the scenario holds, we can discard the areas in white as no longer applicable given this new information.

Turning this back into formulas we can write:

Substituting in numbers we have:

## #Bayes Theorem

In a more general sense, these visualisations explains the intuition behind Bayes Theorem.

Recall that Bayes Theorm is:

$\text{posterior probability} = \frac{\text{likelihood} \times \text{prior probability}}{\text{evidence}}$

or:

$\operatorname{Pr}(a|b) = {\frac{\operatorname{Pr}(b|a)\operatorname{Pr}(a)}{\operatorname{Pr}{(b)}}}$

In the context of record linkage, we can describe these parts as:

Prior: The overall proportion of comparisons which are matches $\operatorname{Pr}(\text{match})$

Evidence: We have observed that a scenario holds, $\operatorname{Pr}(\text{scenario})$

Likelihood: The probability that the scenario holds amongst matches, given by $\operatorname{Pr}(\text{scenario}|\text{records match})$

So Bayes' Theorem is:

$\operatorname{Pr}(\text{match}|\text{scenario}) = \frac{\operatorname{Pr}(\text{scenario}|\text{match})\operatorname{Pr}(\text{match})}{\operatorname{Pr}{(\text{scenario})}}$

but:

$\text{Pr}(\text{scenario}) = \lambda m + (1 - \lambda) u$

So Bayes Theorem is just our original formula:

$\text{posterior match probability} = \frac{\lambda m }{\lambda m + (1 - \lambda) u}$