14.12 Exercises
1. Create a random variable \(S\) with the earnings of your bank if you give out 10,000 loans, the default rate is 0.03, and you lose $200,000 in each foreclosure. Hint: use the code we showed in the previous section, but change the parameters.
n<-10000
loss_per_foreclosure<--200000
p_default<-.03
set.seed(1)
defaults<-sample(c(0, 1), n, prob=c(1-p_default, p_default), replace=TRUE)
sum(defaults*loss_per_foreclosure)
## [1] -6.3e+07
2. Run a Monte Carlo simulation with 10,000 outcomes for \(S\). Make a histogram of the results.
n<-10000
loss_per_foreclosure<--200000
p_default<-.03
set.seed(1)
B<-10^4
S<-replicate(B, {defaults<-sample(c(0, 1), n, prob=c(1-p_default, p_default), replace=TRUE)
sum(defaults*loss_per_foreclosure)
})
hist(S)
3. What is the expected value of \(S\)?
n<-10000
loss_per_foreclosure<--200000
p_default<-.03
pnot<-1-p_default
expval<-n*(p_default*loss_per_foreclosure)+pnot*0
4. What is the standard error of \(S\)?
n<-10000
loss_per_foreclosure<--200000
p_default<-.03
pnot<-1-p_default
se<-sqrt(n)*abs(loss_per_foreclosure)*sqrt(p_default*pnot)
5. Suppose we give out loans for $180,000. What should the interest rate be so that our expected value is 0?
loss_per_foreclosure<--200000
p_default<-.03
x<--loss_per_foreclosure*p_default*(1-p_default)
x<-x/180000
6. (Harder) What should the interest rate be so that the chance of losing money is 1 in 20? In math notation, what should the interest rate be so that \(Pr(S<0)=0.05\)?
n<-10000
loss_per_foreclosure<--200000
p_default<-.03
z<-qnorm(.05)
x<-loss_per_foreclosure*(n*p_default-z*sqrt(n*p_default*(1-p_default)))/(n*(1-p_default) + z*sqrt(n*p_default*(1-p_default)))
x<-x/180000
7. If the bank wants to minimize the probabilities of losing money, which of the following does not make interest rates go up?
The number of Monte Carlo simulations.