*Last modified: September 21, 2024*

*This article is written in: 🇺🇸*

## Bayesian vs Frequentist Statistics

Bayesian and frequentist statistics are two distinct approaches to statistical inference. Both approaches aim to make inferences about an underlying population based on sample data. However, the way they interpret probability and handle uncertainty is fundamentally different.

### Frequentist Statistics

- Frequentist statistics operates under the assumption that parameters in a population are fixed but unknown, such as the true mean, which remains constant even though its value is not directly observed.
- Confidence intervals are constructed to estimate the range within which a parameter likely falls. For example, a 95% confidence interval means that if an experiment were repeated many times, 95% of the intervals generated would capture the true parameter value.
- Null hypothesis testing is a core component of frequentist analysis. It tests observed data against a null hypothesis, which typically asserts no effect or no difference, such as the hypothesis that two groups do not differ significantly.

#### Mathematical Foundations

- Frequentist probability is defined in terms of long-run frequency. This interpretation suggests that, in a large number of trials, the probability of an event, like getting heads in a coin toss, reflects its relative frequency over time.
- Test statistics are used to measure how unusual the observed data is compared to what would be expected under the null hypothesis. The extremeness of the data is quantified by the p-value, which indicates the probability of obtaining such data if the null hypothesis is true. A small p-value suggests the observed data is inconsistent with the null hypothesis.

#### Advantages

- Frequentist methods are known for their simplicity and accessibility, making them easier for non-experts to understand and apply in practical settings.
- These methods are well-suited for large sample sizes, often yielding highly reliable results when ample data is available.
- Frequentist statistics offer standardized methods, supported by extensive tables and procedures, which have been widely adopted in fields like medicine and social sciences.

#### Limitations

- One major limitation is that frequentist methods can produce misleading results when applied to small sample sizes or complex data structures, potentially leading to inaccurate conclusions.
- Frequentist statistics do not incorporate prior knowledge or beliefs about the parameters; they rely solely on the data at hand, potentially missing valuable context.
- The binary decision-making process, where one either rejects or fails to reject the null hypothesis, can be overly simplistic, often ignoring the nuance and depth of the data, leading to a lack of deeper interpretation.

#### Example

Let's assume we have a population of ten items, where X represents the attribute we are looking for and O represents the absence of this attribute.

Population:

`O O X O O O X X O X`

We take a sample of 4 randomly from this population:

```
Sample:
X O O X
```

A frequentist would calculate the probability of the attribute in the population based on this sample, which is 50% (2 out of 4), and would apply this probability to any future samples.

### Bayesian Statistics

- Bayesian statistics treats parameters as random variables with associated probability distributions, reflecting the uncertainty about their true values rather than considering them fixed.
- A prior distribution represents pre-existing knowledge or beliefs about a parameter, formulated as a probability distribution that captures this initial understanding before observing new data.
- The likelihood function expresses the probability of observing the data given different parameter values. This function plays a key role in updating beliefs as new data becomes available.
- The posterior distribution is the updated probability distribution after combining the prior distribution and the likelihood. It forms the core of Bayesian inference, offering a new perspective on the parameter based on the data.

#### Mathematical Framework

- Bayes' Theorem serves as the foundation of Bayesian analysis. It mathematically updates the prior belief in light of new evidence by using the formula: Posterior ∝ Likelihood × Prior, reflecting how new data influences prior knowledge.
- In Bayesian statistics, probability is interpreted as a degree of belief or certainty about an event or parameter, rather than as a long-run frequency of occurrence as in frequentist statistics.

#### Incorporating Prior Knowledge

- Bayesian methods allow for the use of general knowledge priors, even without specific domain expertise. For example, in a study on snake lifespans, a prior could favor a lifespan around 10 years, rather than something implausible like 1000 years, based on biological understanding.
- As new data is collected, Bayesian inference updates the prior to form the posterior, which reflects the combined influence of prior knowledge and new observations. For instance, if new research suggests that certain snakes live longer than expected, the posterior distribution would adjust to reflect this new evidence alongside previous beliefs.

#### Advantages

- One of the key strengths of Bayesian statistics is its ability to incorporate prior knowledge or expertise into the analysis, making it particularly valuable in situations where data is limited or difficult to obtain.
- Bayesian methods often lead to more intuitive and direct interpretations, especially in scenarios where the data is complex or the sample size is small, as the results are framed in terms of probabilities and uncertainties.
- Bayesian analysis provides a probabilistic understanding of estimates, allowing for a more nuanced and detailed interpretation of uncertainty around the parameter estimates.
- These methods offer great flexibility in handling complex models and uncertainty, making them well-suited for sophisticated models and smaller datasets.

#### Limitations

- Bayesian analysis is computationally intensive, requiring significant resources to calculate posterior distributions, particularly when dealing with complex models or large datasets.
- The choice of prior can heavily influence the results, potentially introducing bias if the prior is not carefully selected or justified based on solid reasoning.
- Implementing Bayesian methods requires a more advanced understanding of statistical principles, making them harder to apply and interpret without specialized knowledge.

#### Example

Assume we have a prior belief about the probability of a coin landing on heads (H) or tails (T).

```
Prior:
H: 0.5, T: 0.5
```

Now we flip the coin 3 times, and get all heads.

```
Data:
H H H
```

A Bayesian would use this data to update their prior belief into a posterior belief. After seeing 3 heads, the updated (posterior) probabilities might look like this:

```
Posterior:
H: 0.8, T: 0.2
```

This means that the Bayesian approach allows for updating beliefs (probabilities) based on new data.

### Bayesian vs Frequentist Convergence

As the sample size increases, Bayesian and frequentist methods often produce similar results, but this convergence depends on the complexity of the model and the specific circumstances of the analysis. When using uninformed or non-informative priors (indicating a lack of prior knowledge), the results from Bayesian and frequentist approaches are frequently comparable, if not identical. However, the interpretation of these results can still differ between the two frameworks.

#### When Do They Diverge?

- In cases involving complex models or smaller sample sizes, Bayesian and frequentist methods may produce significantly different outcomes. Bayesian approaches may perform better in these scenarios because they can incorporate prior information, which helps when data is limited or the model is sophisticated.
- The specific context of the problem, such as the presence of prior information or a complicated data structure, can also lead to divergence between the two methods. Bayesian methods might yield more nuanced results in certain situations where frequentist methods may struggle.

#### Example: Frequentist vs. Bayesian Mean Estimation

- We generated synthetic data consisting of 100 random values drawn from a normal distribution with a mean of 5 and a standard deviation of 2. This dataset simulates real-world measurements with inherent variability around the central value of 5. The goal was to compare how the frequentist and Bayesian approaches estimate the mean and uncertainty of this data.
- Using the
**frequentist approach**, we calculated the sample mean and constructed a 95% confidence interval (CI). The mean came out to be approximately 4.79, and the confidence interval was between 4.44 and 5.15. This interval suggests that, if we repeated this experiment many times, 95% of the calculated intervals would contain the true population mean. - In the
**Bayesian approach**, we incorporated prior knowledge about the data by assuming a prior mean of 5 and a prior variance of 1. Combining this prior belief with the observed data, we calculated a posterior mean of 4.80. The 95% credible interval, which reflects where the true mean is likely to lie given both the prior and observed data, ranged from 4.42 to 5.18. This interval accounts for both the prior information and the variability in the data.

The analysis results are as follows:

**Frequentist Mean:**4.79, with a 95% confidence interval of (4.44, 5.15).**Bayesian Mean:**4.80, with a 95% credible interval of (4.42, 5.18).