Cost Accounting

A carpenter shop and workshop has the following parameters:

Assume that all our production can be sold. Assume that you have 2 people to do the work (you plan and sell)

What is the sales price to be asked for a chair and a table? What happens if we only would sell tables or chairs?

note: this excercise might be easier in a spreadsheet than in R.

Management Accounting

Propose a balanced scorecard for the workshop

Interest

What is the interest rate curve? Compare the interest rate curve in PLN with EUR

Amortisation table

Make the amortization table (this is a table with for each month: The outstanding amount (principle at the beginning of the period), the amount to pay (periodic payment), the interest to pay, the capital redeemed, the principle at the end of the period). Use the following loan: 2000 PLN, monthly installments, interest calculated at the beginning of the monthly period, interest is 5 % per year, equal period payments, payback in 2 years.

A = 2000
T = 2 * 12
i = (1 + 0.05)^(1/12) - 1
u = 1 + i
v = 1 / u
a <- i / (1 - v^T) * A

tbl <- data.frame(principal_start = numeric(0), 
                  payment = numeric(0),
                  interest = numeric(0),
                  capital_redeemed = numeric(0),
                  principle_end = numeric(0))
theRow <- 0
for (t in 1:T) {
  theRow[1] <- A
  theRow[2] <- a
  theRow[3] <- A * i
  K <- a - A * i
  theRow[4] <- K
  A <- A - K
  theRow[5] <- A
  tbl <- rbind(tbl, theRow)
}

colnames(tbl) <- c("principle_start", "payment", "interest", "capital_redeemed", "principle_end")

knitr::kable(round(tbl, 2))

Bonds

Compare the Macaulay Duration and market values

for the following bonds:

  1. ten years, coupon 5%, nominal 1000
  2. five years, coupon 5%, nominal 1000
  3. 3 years, coupon 5%, nominal 1000

for the following interest rates: 3%, 4%, 5% and 10%

What do you conclude?

bond_value <- function(time_to_mat, coupon, disc_rate, nominal){
  value  <- 0
  # 1/ all coupons
  for (t in 1:time_to_mat) {
     value <- value + coupon * (1 + disc_rate)^(-t)
     }
  # 2/ end payment of face value
  value <- value + nominal * (1 + disc_rate)^(-time_to_mat)
  value
}

MacDur <- function(time_to_mat, coupon, disc_rate, nominal) {
  V <- bond_value(time_to_mat, coupon, disc_rate, nominal)
  CFs <- c(seq(coupon, coupon, length.out = time_to_mat - 1), nominal + coupon)
  t   <- c(1:time_to_mat)
  1 / V * sum(t * CFs / (1 + disc_rate)^t)
}

intRates <- c(0.03, 0.04, 0.05, 0.1)
myRow <- function(bond_name, FUN, time_to_mat, coupon, intRates, nominal) {
  fName <- as.character(substitute(bond_value))
  x <- data.frame(bond_name = bond_name)
  for (k in intRates) {
    rname <- paste0("Intr=",k)
    x[[rname]] <- FUN(time_to_mat, coupon, k, nominal)
  }
  x
}

values

values <- rbind(
  myRow("TenYears", bond_value, 10, 0.05*1000, intRates, 1000),
  myRow("FiveYears", bond_value, 5, 0.05*1000, intRates, 1000),
  myRow("ThreeYears", bond_value, 3, 0.05*1000, intRates, 1000)
)
knitr::kable(values)

durations

durations <- rbind(
  myRow("TenYears", MacDur, 10, 0.05*1000, intRates, 1000),
  myRow("FiveYears", MacDur, 5, 0.05*1000, intRates, 1000),
  myRow("ThreeYears", MacDur, 3, 0.05*1000, intRates, 1000)
)
knitr::kable(durations)

CAPM and Equity Pricing

Microsoft

Calculate the beta of Microsoft (ticker = “MSFT”), best use the library quantmod

library(quantmod)
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## ######################### Warning from 'xts' package ##########################
## #                                                                             #
## # The dplyr lag() function breaks how base R's lag() function is supposed to  #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or       #
## # source() into this session won't work correctly.                            #
## #                                                                             #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop           #
## # dplyr from breaking base R's lag() function.                                #
## #                                                                             #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning.  #
## #                                                                             #
## ###############################################################################
## 
## Attaching package: 'xts'
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
#library(tidyverse)
library(lubridate)
library(xts)

Use the beta to estimate the price of Microsoft (MSFT) Is it worth to buy or sell? What growth rate is the market implying?

t0    <- Sys.Date() - years(5)
SPX   <- getSymbols("^GSPC",auto.assign = FALSE, from = t0)
MS    <- getSymbols("MSFT", auto.assign = FALSE, from = t0)
t10yr <- getSymbols(Symbols = "DGS10", src = "FRED", auto.assign = FALSE)

# calculate the beta
R_M <- periodReturn(SPX) # monthly returns are default
R_MS <- periodReturn(MS) # monthly returns are default
R_F <- (1 + t10yr$DGS10 / 100)^(1/12) - 1
ts   <- merge.xts(R_M, R_MS, R_F, join = "inner")
## Warning in merge.xts(R_M, R_MS, R_F, join = "inner"): 'join' only applicable to
## two object merges
colnames(ts) <- c("R_M", "R_MS", "R_F")
ts$RP_M  <- ts$R_M - ts$R_F
ts$RP_MS  <- ts$R_MS - ts$R_F
lm1 <- lm(RP_MS ~ RP_M + 0, ts)
summary(lm1)

beta_MS <- lm1$coefficients[1]
ER_MS_month <- beta_MS * (mean(ts$R_M - ts$R_F)) + mean(ts$R_F)
ER_MS <- (1 + ER_MS_month)^12 - 1

D_MS <- 0.62 #USD
P_MS <- 296.7 # USD

g_MS <- (1 + 2)^(1/5 - 1)
# 40% stable growth per year over the last 5 years ...
# too high --> take 15%:
paste("our price", 0.62 / (ER_MS - 0.15))

Google

Try the same for Google

t0    <- Sys.Date() - years(5)
SPX   <- getSymbols("^GSPC",auto.assign = FALSE, from = t0)
GGL   <- getSymbols("GOOG", auto.assign = FALSE, from = t0)
t10yr <- getSymbols(Symbols = "DGS10", src = "FRED", auto.assign = FALSE)

# calculate the beta
R_M <- periodReturn(SPX) # monthly returns are default
R_G <- periodReturn(GGL) # monthly returns are default
R_F <- (1 + t10yr$DGS10 / 100)^(1/12) - 1
ts   <- merge.xts(R_M, R_G, R_F, join = "inner")
## Warning in merge.xts(R_M, R_G, R_F, join = "inner"): 'join' only applicable to
## two object merges
colnames(ts) <- c("R_M", "R_G", "R_F")
ts$RP_M  <- ts$R_M - ts$R_F
ts$RP_G  <- ts$R_G - ts$R_F
lm1 <- lm(RP_G ~ RP_M + 0, ts)
summary(lm1)

beta_G <- lm1$coefficients[1]

paste("the beta of GOOG is:", beta_G)

But the dividend is 0 USD. Therefor this method is not applicable.