Bayesian Analysis: Exercises


1. Conditional probabilities. Let P(B) be the probability that B defaults. The following variables have been defined for you in R.

$$P(A|B) = \text{prAcondB} = 0.90$$ $$P(B) = \text{prB} = 0.10$$ $$P(A) = \text{prA} = 0.20$$

Use the variables above to compute the probabilities below:

$$P(B|A) = \text{prBcondA}$$ $$P(B \cap A) = \text{prBandA}$$

prAcondB <- 0.90 prB <- 0.05 prA <- 0.07 # Compute the probability that B defaults given A. prBcondA <- ___*prB/___ # Compute the joint probability of B and A defaulting. prBandA <- prA*___ # Print the probabilities. print(c(prBcondA, prBandA)) # Compute the probability that B defaults given A. prBcondA <- prAcondB*prB/prA # Compute the joint probability of B and A defaulting. prBandA <- prA*prBcondA # Print the probabilities. print(c(prBcondA, prBandA)) test_error() test_object("prBcondA", incorrect_msg="Check the expression you used to compute `prBcondA`.") test_object("prBandA", incorrect_msg="Check the expression you used to compute `prBandA`.") success_msg("Excellent work.")
Remember that P(B|A)*P(A) = P(A|B)*P(B).

Previous Exercise Next Exercise