Browsing resource, all submissions are temporary.
For many people, buying a house is probably one of the biggest financial purchase in one's life. If you are a few people who are rich, you can purchase a house of your dream today by just paying the amount of the house's selling price. For most people, the housing prices are too expensive and they need to obtain a mortgage. A mortgage is a loan where a lender gives the money a borrower needed to purchase a house. Mortgages require borrowers to make monthly payments to repay the debt. The borrower will not only pay the amount of the loan, but also the interests the lender charges. The interests depend on the mortgage plans. For a fixed-interest rate, it can be shown that the monthly payment M is given by the formula
where L is the amount of loan, m is the length of the mortgage in months, and α = c/1200. Here c is the annual interest rate in percentage. For example, suppose you borrow $100,000 from a 15-year mortgage with a fixed annual interest of 3%. The loan L = $100000, c = 3 and α = 3/1200 = 0.0025; length = 15 years = 15×12 months = 180 months, so m=180. Equation (1) gives the monthly payment M = $690.58. Every year, your mortgage payment is $690.58×12 = $8286.96. Since you need to pay this amount of money for 15 years, the total amount of money you end up paying is A = $8286.96×15 = $124304.4 or 24.3% more than the original $100,000. However, this is not as bad as you may think. A large portion of the money will be paid in the future where inflation will decrease the purchasing power of $8286.96. It's like renting a house with a fixed monthly rent for 15 years. Your other expenses increase because of inflation but the mortgage payment remains fixed, so it occupies smaller and smaller proportion of your expenses as the year goes by.
To find out the purchasing power of the total mortgage payment $124304.4, we take inflation into account and convert it to A*, the amount of money today with the same purchasing power as the inflation-adjusted total mortgage payment $124304.4. To do the calculation, we adjust the inflation year by year. In the first year, the annual mortgage payment is 12M = $8286.96. In the second year, the annual motgage payment is still 12M = $8286.96 but its purchasing power is the same as 12M/(1+f1) today, where f1 is the inflation rate of the first year. In the third year, the motgage payment is again 12M but its purchasing power is the same as 12M/(1+f1)/(1+f2) today, where f2 is the inflation rate of the second year. In general, the purchasing power of 12M in the kth year is the same as
today. The inflation adjusted total mortgage payment A* is equal to the sum from the first year to the 15th year:
where n = 15 for a 15-year mortgage. To calculate A*, we need to know the inflation rates f1, f2, ..., f14 in the next 14 years. However, inflation rates fluctuate stochastically and no one knows for sure what they will be. In this problem, you are going to perform a Monte Carlo simulation to obtain a distribution for A* using a simple probability model for the future inflation rates.
You will use the same simple model for inflation as in the notes by drawing 14 random samples with replacement from the historical inflation data from 1981 to 2015. Copy and paste the following inflation rates for the years in the US from 1981 to 2015 to R.
historical_inflation <- c(0.1031553, 0.06160616, 0.03212435, 0.04317269, 0.03561116, 0.01858736, 0.03740876, 0.04009088, 0.04827003, 0.05397956, 0.04234964, 0.0302882, 0.02951657, 0.02607442, 0.0280542, 0.02931204, 0.0233769, 0.01552279, 0.02188027, 0.03376857, 0.02826171, 0.01586032, 0.02270095, 0.02677237, 0.03392747, 0.03225944, 0.02852672, 0.038391, -0.003555463, 0.01640043, 0.03156842, 0.02069337, 0.01464833, 0.01622223, 0.001186271)
Write a function named compute_Astar() that takes the arguments M (monthly payment) and n (mortgage length in years). Inside the function, use sample() to draw n-1 inflation rates with replacement from historical_inflation (corresponding to f1, f2, ..., fn-1) and then calculate A* using equation (2).
compute_Astar()
M
n
sample()
n-1
historical_inflation
A prototype of the function is as follows.
compute_Astar <- function(M, n) { # generate f1, f2, ..., fn-1 by drawing n-1 random samples with replacement from historical_inflation f <- sample(historical_inflation, n-1, replace=TRUE) # calculate A* using equation (2) }
Hint: You may be tempted to use a for-loop to carry out the calculation, but you can actually write a one-line R code to compute equation (2) by combining sum() and cumprod(). The secret is to learn how to use the function cumprod() you haven't seen before. Search the internet for help. Don't kill yourself if you can't figure it out. You can still use a for-loop to do the calculation.
sum()
cumprod()
Here are some example output from this function:
RNGversion("3.5.0") set.seed(123456) compute_Astar(100, 6)
[1] 6669.45
RNGversion("3.5.0") set.seed(648791738) compute_Astar(308.75, 30)
[1] 76356.86
RNGversion("3.5.0") set.seed(6498855) compute_Astar(690.58, 15)
[1] 101626.4
The function that you write should be able to match these numbers.
a. Do one calculation to get a feeling. Copy and paste the following code to R and run it.
RNGversion("3.5.0") set.seed(1814285) compute_Astar(690.58,15)
What is the returned value of A*? Round your answer to the nearest integer.
A* =
Now perform a Monte Carlo simulation to calculate the distribution of A*. You will do the calculation 100,000 (1e5) times to obtain decent statistics. Copy and paste the following commands to R and run them.
RNGversion("3.5.0") set.seed(1814285) Astar <- replicate(1e5, compute_Astar(690.58, 15))
The variable Astar is a vector of length 100,000. Make sure that the first element, Astar[1], is exectly the same as the value in part (a).
Astar
Astar[1]
b. What is the mean of Astar? This is the expected value of the total mortgage payment adjusted for inflation. Round your answer to the nearest integer.
mean of A* =
c. What is the probability that A* < $100,000? This is the probability that you will effectively pay less than $100,000 in terms of purchasing power. Give your answer to 4 decimal places.
P(A* < $100000) =