Skip to content

Commit

Permalink
20240907 - law of total probability
Browse files Browse the repository at this point in the history
  • Loading branch information
isaactpetersen committed Sep 7, 2024
1 parent ba3959d commit 0f47e74
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions 10-Prediction.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,24 @@ $$
(\#eq:conditionalProbabilityRevised)
$$

We can then estimate the marginal probability of the event, substititing in $P(R | \text{not } C)$, using the law of total probability.
The [`petersenlab`](https://cran.r-project.org/web/packages/petersenlab/index.html) package [@R-petersenlab] contains the `pA()` function that estimates the marginal probability of one event, $A$.

```{r, eval = FALSE, class.source = "fold-hide"}
pA <- function(pAgivenB, pB, pAgivenNotB){
value <- (pAgivenB * pB) + pAgivenNotB * (1 - pB)
value
}
```

```{r}
pA(
pAgivenB = .95,
pB = .003,
pAgivenNotB = .007171515)
```

The [`petersenlab`](https://github.com/DevPsyLab/petersenlab) package [@R-petersenlab] contains the `pBgivenNotA()` function that estimates the probability of one event, $B$, given that another event, $A$, did not occur.\index{petersenlab package}\index{Bayesian!Bayes' theorem}

```{r, eval = FALSE, class.source = "fold-hide"}
Expand Down

0 comments on commit 0f47e74

Please sign in to comment.