Bayesian Analysis: Exercises


2. Bayes' Theorem. Let P(B) be the probability that B defaults. The following variables have been defined for you in R.

$$P(B) = \text{prB} = 0.05$$ $$P(A) = \text{prA} = 0.10$$

Compute P(A|B) under the following two assumptions:

1. P(B|A) = 0.45.

2. A and B are independent.


prB <- 0.05 prA <- 0.10 # Compute P(A|B) if A and B are independent. prBcondA0 <- ___ # Define P(B|A) for case where A and B are not independent. prBcondA <- ___ # Compute P(A|B) for case where A and B are not independent. prAcondB1 <- ___*prA/___ # Compute P(A|B) if A and B are independent. prBcondA0 <- prA # Define P(B|A) for case where A and B are not independent. prBcondA <- 0.45 # Compute P(A|B) for case where A and B are not independent. prAcondB1 <- prBcondA*prA/prB test_error() test_object("prBcondA0", incorrect_msg="Check the expression you used to compute `prBcondA0`.") test_object("prBcondA", incorrect_msg="Check the expression you used to compute `prBcondA`.") test_object("prAcondB1", incorrect_msg="Check the expression you used to compute `prAcondB1`.") success_msg("Excellent work.")
Remember that Bayes' Theorem can be used to relate conditional and unconditional probabilities.

Previous Exercise Next Exercise