Problem 1: Saving for a Downpayment

t <- 15 # Number of years after which Sara plans to buy her own house
FV <- 200000 # Down payment needed to be achieved by saving a specific amount monthly and putting it as a deposit (in CHF)
i <- 0.025 # Interest rate per year
m <- 12 # Number of compounding intervals

# Let's plug these numbers into annuity formula:
# Remark: PMT = monthly payment for saving

PMT <- (FV * (i/m)) / ((1 + i/m)^(t * m) - 1)

cat("Each month, Sara needs to save CHF", round(PMT, 2), "\n")
## Each month, Sara needs to save CHF 916.91

Problem 2: Internal rate of return (IRR) / 1st approach

n <- 12*10 # 10 years OR 120 months - number of periods when a mortgage bank can receive a payment
PMT <- 1800 # Monthly cash inflow received by the mortgage bank (in CHF)
INV <- 165000 # Initial loan amount paid out by the bank at time 0 (in CHF)

# Let's define a function that computes the absolute difference between the initial loan amount and the present value of all future monthly mortgage payments for a given IRR candidate:
IRR.fctn <- function(IRR.candidate) { # we write a function that consists of two steps
PV <- PMT*sum(sapply(1:n,function(years) 1/(1+IRR.candidate)^years))
difference <- abs(INV - PV) # The IRR is the rate that minimizes this difference
}


# Now let's use numerical optimization to find the monthly IRR that makes the present value of all future payments as close as possible to the initial loan amount
result <- optimize(f = IRR.fctn, # specifies we want to optimise the function IRR
lower = 0, upper = 0.2, # range of values to be plugged in for IRR.candidate
maximum = FALSE) # default is maximisation

irr_m <- result$minimum # Here we store the minimum value in another variable

# Finally, we convert the monthly IRR into an effective annual IRR
irr = ((1 + irr_m)^12 - 1)*100

cat("(Annual) IRR of this investment =", round(irr, 4), "%\n")
## (Annual) IRR of this investment = 5.7475 %

Problem 2: Internal rate of return (IRR) / 2nd approach

t <- 12*10 # Total number of monthly periods: 10 years × 12 months
PMT <- 1800 # Monthly cash inflow received by the mortgage bank (in CHF)
INV <- 165000 # Initial loan amount paid out by the bank at time 0 (in CHF)

# Here we define the net present value (NPV) function of the mortgage loan
# For a given monthly discount rate r, this function calculates the present value of all future monthly payments minus the initial loan amount. The IRR is the rate r that makes this NPV equal to zero.
IRR.fctn <- function(r) {
  -INV + sum(PMT / (1 + r)^(1:t))
}

# To get this monthly IRR, let's use a root-finding algorithm, i.e. the rate that solves NPV = 0
irr_m <- uniroot(IRR.fctn, lower = 0, upper = 0.2, tol = 1e-12)$root

# Finally, we can convert the monthly IRR into an effective annual IRR
irr_annual <- ((1 + irr_m)^12 - 1)

cat("(Annual) IRR of this investment =", round(irr_annual * 100, 4), "%\n")
## (Annual) IRR of this investment = 5.7605 %

Problem 3: Effective Annual Yield (EAY)

3a

i <- 0.04 # 4% interest rate is given
PV <- 10000 # Let's assume interest is to be earned on the $10,000 principal
n <- 1 # Loan term (in years)

# First, let's calculate future value of the funds when compounded annually for 1 year:

m <- 1 # Number of the desired compounding intervals within one year. In this case, it equals to 1 since we compound our interest only once
FV_annual <- PV * (1 + i/m)^(n * m)


# Secondly, let's derive future value of the funds when compounded monthly for 1 year:

m <- 12 # Intervals change since we compound monthly, i.e. 12 times within 1 year
FV_m <- PV * (1 + i/m)^(n * m)

# Now, let's calculate EAY for both cases:

EAY_annual <- (FV_annual - PV) / PV
EAY_m <- (FV_m - PV) / PV


cat("EAY compounded annually =", round(EAY_annual * 100, 4), "%\n")
## EAY compounded annually = 4 %
cat("EAY compounded monthly =", round(EAY_m * 100, 4), "%\n")
## EAY compounded monthly = 4.0742 %

As we can see, EAY of a 4% interest rate compounded monthly is more than 4%.

3b

# If payments were compounded daily, compounding intervals change to 365:
m <- 365
FV_daily <- PV * (1 + i/m)^(n * m)

# EAY will be then as follows:
EAY_daily <- (FV_daily - PV) / PV

cat("EAY compounded annually =", round(EAY_annual * 100, 4), "%\n")
## EAY compounded annually = 4 %
cat("EAY compounded daily =", round(EAY_daily * 100, 4), "%\n")
## EAY compounded daily = 4.0808 %

As we can see, EAY of a 4% interest rate compounded daily is more than 4%.

3c

# Which equivalent nominal annual rate (ENAR) quoted by the bank, with monthly compounding, gives an effective annual yield of 4%?

# It's simply the same compounding formula, but now we are looking for i, which was previously inside it:

ENAR_m <- ((1 + EAY_annual)^(1/(n * m)) - 1) * m

cat("Interest rate, originally reported by the mortgage bank, that corresponds
to an EAY of 4, equals", round(ENAR_m * 100, 4), "%\n")
## Interest rate, originally reported by the mortgage bank, that corresponds
## to an EAY of 4, equals 3.9223 %

Problem 4: Discounted Cash Flow Valuation

CF_1 <- 150000 # The expected cash flow for year 1
g <- 0.035 # (Annual) growth rate at which CF_1 is expected to grow 
t <- 15 # Number of years after which property is expected to be resold
TV <- 11000000 # Expected terminal value calculated by comparable properties
r <- 0.055 # Discount rate for the DCF calculation 

# Let's first simulate all annual CFs and discount them:
CF <- CF_1 * sum(sapply(1:t,function(year) (((1 + g)^(year-1))/((1 + r)^year))))

# Now let's discount terminal value:
PV_TV <- TV/(1 + r)^t

# Finally, let's add up discounted cash flows and terminal value to get an estimated value of an office property:
PV <- CF + PV_TV

cat("Estimated value of an office property =", format(round(PV, 2), nsmall = 2), "\n")
## Estimated value of an office property = 6798932.72