Microsoft WACC

Page: https://rpubs.com/staszkiewicz/FM_WACC

Let us calculate WACC for Microsoft Using R and Financial Data

Understanding the Components: To calculate WACC for Microsoft, we need the following:

  • Cost of Debt: This can be estimated from the yield to maturity of Microsoft’s bonds.
  • Cost of Equity: This can be estimated using the Capital Asset Pricing Model (CAPM).
  • Market Value of Debt: This can be obtained from Microsoft’s financial statements.
  • Market Value of Equity: This is the market capitalization of Microsoft’s stock.
  • Tax Rate: The corporate tax rate.

R Code to Calculate WACC:

Load necessary libraries

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(quantmod)
## Ładowanie wymaganego pakietu: xts
## Ładowanie wymaganego pakietu: zoo
## 
## Dołączanie pakietu: 'zoo'
## 
## Następujące obiekty zostały zakryte z '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.  #
## #                                                                             #
## ###############################################################################
## 
## Dołączanie pakietu: 'xts'
## 
## Następujące obiekty zostały zakryte z 'package:dplyr':
## 
##     first, last
## 
## Ładowanie wymaganego pakietu: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo

Get Microsoft’s stock data

getSymbols("MSFT")
## [1] "MSFT"

Calculate market value of equity (market capitalization)

oustanding_shares<- 30000000
#note: you might use the current volume instant as the instrument for.

market_cap <- last(MSFT$MSFT.Adjusted) * oustanding_shares

Assuming the following (replace with actual values):

cost_of_debt <- 0.03  # 3%
tax_rate <- 0.25  # 25% tax rate
beta <- 1.1  # Beta of Microsoft's stock
risk_free_rate <- 0.02  # 2% risk-free rate
market_risk_premium <- 0.06  # 6% market risk premium

Calculate cost of equity using CAPM

cost_of_equity <- risk_free_rate + beta * market_risk_premium

Assuming market value of debt (replace with actual value)

market_value_of_debt <- 100e9  # $100 billion

Calculate total market value of capital

total_market_value <- market_cap + market_value_of_debt

Calculate weights of debt and equity

weight_of_debt <- market_value_of_debt / total_market_value
weight_of_equity <- market_cap / total_market_value

Calculate WACC

wacc <- (weight_of_debt * cost_of_debt * (1 - tax_rate)) + (weight_of_equity * cost_of_equity)