Tidy Discounted Cash Flow Analysis in R (for Company Valuation)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The tidy data principles are a cornerstone of financial data management and the data modeling workflow. The foundation for tidy data management is the tidyverse
, a collection of R packages, that work in harmony, are built for scalability, and are taught at Business Science University. Using this infrastructure and the core tidy concepts, we can apply the tidy data principles to the Saudi Aramco Discounted Cash Flow (DCF) Valuation.
R Packages Covered
Scraping and Tidying Unclean Data
tidyverse
– An ecosystem for wrangling and visualizing data inR
tabulizer
– PDF Scrapingfuzzyjoin
– Joining data with inexact matchingrvest
– Web Scrapingtidyxl
– Importing non-tabular (non-tidy) Excel Data
Tidy DCF Workflow
In this post, we’ll use the following workflow for performing and automating DCF Analysis.
Workflow for Tidy DCF Analysis and Company Valuation
The article is split into two sections:
-
Part 1 – Data Sources: Collect DCF input data with PDF Scraping, Web Scraping, API’s, and tidy the data into a single DCF Inputs that can be used for Part 2.
-
Part 2 – DCF Company Valuation: Model Saudi Aramco’s Company Valuation. Perform sensitivity analysis given various risks to our model.
Need to learn Data Science for Business? This is an advanced tutorial, but you can get the foundational skills, advanced machine learning, business consulting, and web application development using R
, Shiny
(Apps), H2O
(Machine Learning), AWS
(Cloud), and tidyverse
(Data Science). I recommend Business Science’s 4-Course R-Track for Business Bundle.
Part 1 – Data Sources
Saudi Aramco has set a price range for its listing that implies the oil giant is worth between USD $1.6 trillion and US $1.7 trillion, making it potentially the world’s biggest IPO. The numbers that are laid out in the Saudi Aramco Prospectus are impressive, painting a picture of the most profitable company in the world, with almost unassailable competitive advantages. In this post, I valued Saudi Aramco between US$1.69 and US$1.83 trillion using the following R packages.
tabulizer
The tabulizer package provides a suite of tools for extracting data from PDFs. We will use the extract_tables()
function to pull out tables 42 (pg 131 – gearing), 43 (pg 132 – capital), 45 (pg 133 – income statement) and 52 (pg 144 – balance sheet) from the Saudi Aramco Prospectus.
fuzzyjoin
The fuzzyjoin package is a variation on dplyr’s join operations that allows matching not just on values that match between columns, but on inexact matching. This allows the Aramco’s financial accounts (e.g., gearing, capital, income statement, balance sheet) to be quickly matched with the tables it is reported on and without having to looking for the correct location in the prospectus, a behemoth weighing in at 658 pages.
World Bank Data API
The World Bank makes available a large body of economic data from the World Development Indicators through its web API.
The WDI package for R makes it easy to search and download the annual percentage growth rate of Gross Domestic Product (GDP) for Saudi Arabia (Indicator: NY.GDP.MKTP.KD.ZG).
rvest
The rvest package makes it easy to scrape daily treasury yield curve rates from the website of the U.S. Deparment of the Treasury. Here, I use it with magrittr
so that I can express complex operations as elegant pipelines composed of simple, easily understood pieces.
tidyxl
The tidyxl package imports non-tabular data from Excel files into R. It exposes cell content, position, formatting and comments in a tidy structure for further manipulation. I use tidyxl
to capture Damodaran’s spreadsheets (risk premium, credit spread, unlevered beta, marginal tax rate) in a tidy fashion allowing for seamless interaction between rows and columns.
1.1 Libraries and Set Up
Install and load the following R packages to complete this tutorial. A few points to avoid frustration:
- The
tabulizer
package depends on Java andrJava
libraries. This can be amazingly frustrating to get set up (see my next point). - To replicate my set up, I installed the Java 11 JDK.
- I have several versions of Java (not uncommon for developers). Using
Sys.setenv()
, I pointed R to the version of Java that I wantedtabulizer
to use.
1.2 Prospectus
In this section, I extract financial data from the prospectus, using tabulizer
and fuzzyjoin
. It automates work that would have taken significant manual collection and manipulation.
For working with function programming, we solve the issue for one element, wrap the code inside a function, and then simply map extract.values.f()
to a list of elements in different tables (42, 43, 45 and 52).
1.2.1 Reserves Life
Saudi Aramco’s average reserve life is 52 years, versus 17 years at it’s closest competitor, ExxonMobil. Saudi Aramco’s crude reserves are about five times (5X) that of the combined oil reserves of the five major international oil companies, comprising ExxonMobil, Shell, Chevron, Total, and BP.
name | value |
---|---|
LONG_RESERVES_LIFE | 52 |
1.2.2 Gearing
Gearing is a measure of the degree to which Saudi Aramco’s operations are financed by debt. It is widely used by analysts and investors in the oil and gas industry to indicate a company’s financial health and flexibility.
name | value |
---|---|
LONG_RESERVES_LIFE | 52 |
TOTAL_BORROWINGS | 27018 |
CASH_AND_CASH_EQUIVALENTS | 48841 |
TOTAL_EQUITY | 274249 |
1.2.3 Capital
Saudi Aramco has a comprehensive and disciplined internal approval process for capital allocation. Average capital employed is the average of Saudi Aramco’s total borrowings plus total equity at the beginning and end of the applicable period.
name | value |
---|---|
LONG_RESERVES_LIFE | 52 |
TOTAL_BORROWINGS | 27018 |
CASH_AND_CASH_EQUIVALENTS | 48841 |
TOTAL_EQUITY | 274249 |
CAPITAL_EMPLOYED | 301267 |
1.2.4 Income Statement
The numbers in the financial statement are impressive, painting a picture of the most profitable company in the world, with almost unassailable competitive advantages.
name | value |
---|---|
LONG_RESERVES_LIFE | 52 |
TOTAL_BORROWINGS | 27018 |
CASH_AND_CASH_EQUIVALENTS | 48841 |
TOTAL_EQUITY | 274249 |
CAPITAL_EMPLOYED | 301267 |
OPERATING_INCOME | 212908 |
INCOME_BEFORE_INCOME_TAXES | 212772 |
INCOME_TAXES | 101701 |
NET_INCOME | 111071 |
1.2.5 Balance Sheet
Saudi Aramco’s unique reserves and resources base, operational flexibility, field management, and strong cash flow generation serve as a foundation for its low gearing and flexible balance sheet.
name | value |
---|---|
LONG_RESERVES_LIFE | 52 |
TOTAL_BORROWINGS | 27018 |
CASH_AND_CASH_EQUIVALENTS | 48841 |
TOTAL_EQUITY | 274249 |
CAPITAL_EMPLOYED | 301267 |
OPERATING_INCOME | 212908 |
INCOME_BEFORE_INCOME_TAXES | 212772 |
INCOME_TAXES | 101701 |
NET_INCOME | 111071 |
INVESTMENT_JOINT_VENTURES_ASSOCIATES | 6021 |
INVESTMENT_SECURITIES | 4590 |
SHAREHOLDERS_EQUITY | 271142 |
NON_CONTROLLING_INTERESTS | 3107 |
1.3 World Bank GDP
For Saudi Aramco, the growth rate in earnings corresponds closely to the growth in Saudi Arabia’s GDP. The reason is simple. Saudi Arabia derives almost 80% of its GDP from oil.
name | value |
---|---|
LONG_RESERVES_LIFE | 5.200000e+01 |
TOTAL_BORROWINGS | 2.701800e+04 |
CASH_AND_CASH_EQUIVALENTS | 4.884100e+04 |
TOTAL_EQUITY | 2.742490e+05 |
CAPITAL_EMPLOYED | 3.012670e+05 |
OPERATING_INCOME | 2.129080e+05 |
INCOME_BEFORE_INCOME_TAXES | 2.127720e+05 |
INCOME_TAXES | 1.017010e+05 |
NET_INCOME | 1.110710e+05 |
INVESTMENT_JOINT_VENTURES_ASSOCIATES | 6.021000e+03 |
INVESTMENT_SECURITIES | 4.590000e+03 |
SHAREHOLDERS_EQUITY | 2.711420e+05 |
NON_CONTROLLING_INTERESTS | 3.107000e+03 |
GDP_GROWTH | 2.434111e+00 |
1.4 U.S.Treasuries
We use the 10-Year U.S. Treasury Rate because the currency choice for the Saudi Aramco discounted cash flow valuation is U.S. dollars.
name | value |
---|---|
LONG_RESERVES_LIFE | 5.200000e+01 |
TOTAL_BORROWINGS | 2.701800e+04 |
CASH_AND_CASH_EQUIVALENTS | 4.884100e+04 |
TOTAL_EQUITY | 2.742490e+05 |
CAPITAL_EMPLOYED | 3.012670e+05 |
OPERATING_INCOME | 2.129080e+05 |
INCOME_BEFORE_INCOME_TAXES | 2.127720e+05 |
INCOME_TAXES | 1.017010e+05 |
NET_INCOME | 1.110710e+05 |
INVESTMENT_JOINT_VENTURES_ASSOCIATES | 6.021000e+03 |
INVESTMENT_SECURITIES | 4.590000e+03 |
SHAREHOLDERS_EQUITY | 2.711420e+05 |
NON_CONTROLLING_INTERESTS | 3.107000e+03 |
GDP_GROWTH | 2.434111e+00 |
TREASURY_YIELD_10YR | 1.862857e+00 |
1.5 Damodaran Online
1.5.1 Risk Premium
Damodaran’s equity risk premium is calculated by adding the mature market premium estimated for the US to the country-specific risk premium. To arrive at Saudi Arabia’s equity risk premium, Damodaran augmented the default spread by a scaling factor to reflect the higher risk of equity.
name | value |
---|---|
LONG_RESERVES_LIFE | 5.200000e+01 |
TOTAL_BORROWINGS | 2.701800e+04 |
CASH_AND_CASH_EQUIVALENTS | 4.884100e+04 |
TOTAL_EQUITY | 2.742490e+05 |
CAPITAL_EMPLOYED | 3.012670e+05 |
OPERATING_INCOME | 2.129080e+05 |
INCOME_BEFORE_INCOME_TAXES | 2.127720e+05 |
INCOME_TAXES | 1.017010e+05 |
NET_INCOME | 1.110710e+05 |
INVESTMENT_JOINT_VENTURES_ASSOCIATES | 6.021000e+03 |
INVESTMENT_SECURITIES | 4.590000e+03 |
SHAREHOLDERS_EQUITY | 2.711420e+05 |
NON_CONTROLLING_INTERESTS | 3.107000e+03 |
GDP_GROWTH | 2.434111e+00 |
TREASURY_YIELD_10YR | 1.862857e+00 |
EQUITY_RISK_PREMIUM | 6.463396e+00 |
1.5.2 Credit Spread
We use a credit spread that lenders would charge a large integrated oil & gas company with a specific credit rating, and add it to the avg. 10 year U.S. treasury rate to arrive at Saudi Aramco’s cost of debt.
name | value |
---|---|
LONG_RESERVES_LIFE | 5.200000e+01 |
TOTAL_BORROWINGS | 2.701800e+04 |
CASH_AND_CASH_EQUIVALENTS | 4.884100e+04 |
TOTAL_EQUITY | 2.742490e+05 |
CAPITAL_EMPLOYED | 3.012670e+05 |
OPERATING_INCOME | 2.129080e+05 |
INCOME_BEFORE_INCOME_TAXES | 2.127720e+05 |
INCOME_TAXES | 1.017010e+05 |
NET_INCOME | 1.110710e+05 |
INVESTMENT_JOINT_VENTURES_ASSOCIATES | 6.021000e+03 |
INVESTMENT_SECURITIES | 4.590000e+03 |
SHAREHOLDERS_EQUITY | 2.711420e+05 |
NON_CONTROLLING_INTERESTS | 3.107000e+03 |
GDP_GROWTH | 2.434111e+00 |
TREASURY_YIELD_10YR | 1.862857e+00 |
EQUITY_RISK_PREMIUM | 6.463396e+00 |
CREDIT_SPREAD | 9.750000e-01 |
1.5.3 Unlevered Beta
In calculating the cost of equity, we use an unlevered beta for Saudi Aramco based on integrated oil companies for both cash flow models: (1) cash flows after reinvestment needs and taxes, but before debt payments (FCFF); and (2) cash flows after taxes, reinvestments, and debt payments (FCFE).
name | value |
---|---|
LONG_RESERVES_LIFE | 5.200000e+01 |
TOTAL_BORROWINGS | 2.701800e+04 |
CASH_AND_CASH_EQUIVALENTS | 4.884100e+04 |
TOTAL_EQUITY | 2.742490e+05 |
CAPITAL_EMPLOYED | 3.012670e+05 |
OPERATING_INCOME | 2.129080e+05 |
INCOME_BEFORE_INCOME_TAXES | 2.127720e+05 |
INCOME_TAXES | 1.017010e+05 |
NET_INCOME | 1.110710e+05 |
INVESTMENT_JOINT_VENTURES_ASSOCIATES | 6.021000e+03 |
INVESTMENT_SECURITIES | 4.590000e+03 |
SHAREHOLDERS_EQUITY | 2.711420e+05 |
NON_CONTROLLING_INTERESTS | 3.107000e+03 |
GDP_GROWTH | 2.434111e+00 |
TREASURY_YIELD_10YR | 1.862857e+00 |
EQUITY_RISK_PREMIUM | 6.463396e+00 |
CREDIT_SPREAD | 9.750000e-01 |
UNLEVERED_BETA | 1.084964e+00 |
1.5.4 Marginal Tax
The marginal tax rate is the number we use to compute Saudi Aramco’s after-tax cost of debt. Given Saudi Aramco’s marginal corporate tax rate, the after-tax cost of debt equates to the treasury rate plus the credit spread that lenders would charge Saudi Aramco multiplied by one minus the marginal tax rate.
name | value |
---|---|
LONG_RESERVES_LIFE | 5.200000e+01 |
TOTAL_BORROWINGS | 2.701800e+04 |
CASH_AND_CASH_EQUIVALENTS | 4.884100e+04 |
TOTAL_EQUITY | 2.742490e+05 |
CAPITAL_EMPLOYED | 3.012670e+05 |
OPERATING_INCOME | 2.129080e+05 |
INCOME_BEFORE_INCOME_TAXES | 2.127720e+05 |
INCOME_TAXES | 1.017010e+05 |
NET_INCOME | 1.110710e+05 |
INVESTMENT_JOINT_VENTURES_ASSOCIATES | 6.021000e+03 |
INVESTMENT_SECURITIES | 4.590000e+03 |
SHAREHOLDERS_EQUITY | 2.711420e+05 |
NON_CONTROLLING_INTERESTS | 3.107000e+03 |
GDP_GROWTH | 2.434111e+00 |
TREASURY_YIELD_10YR | 1.862857e+00 |
EQUITY_RISK_PREMIUM | 6.463396e+00 |
CREDIT_SPREAD | 9.750000e-01 |
UNLEVERED_BETA | 1.084964e+00 |
MARGINAL_TAX_RATE | 2.000000e+01 |
Part 2 - DCF Company Valuation
We now have all of the data needed to calculate the Company Valuation.
- Calculate the discount rate or rates to use in the valuation for Saudi Aramco.
- cost of equity for equity investors (FCFE)
- cost of capital for all claimholders (FCFF)
-
Calculate the current earnings and cash flows of Saudi Aramco for equity investors and for all claimholders.
-
Calculate the future earnings and cash flows of Saudi Aramco by estimating an expected growth rate in earnings (GDP growth).
- Calculate Saudi Aramco’s Discounted Cash Flow valuations.
name | value |
---|---|
FCFF_EQUITY_VALUATION | 1.765728e+06 |
VALUE_OPERATING_ASSETS | 1.736401e+06 |
EXPECTED_FCFF | 1.075534e+05 |
EXPECTED_OPERATING_INCOME_AFTER_TAX | 1.138473e+05 |
REINVESTMENT_RATE | 5.528360e-02 |
EXPECTED_ROIC | 4.402954e-01 |
EXPECTED_GROWTH_RATE | 2.434110e-02 |
FCFE_EQUITY_VALUATION | 1.613303e+06 |
VALUE_EQUITY | 1.553851e+06 |
PAYOUT_RATIO | 9.405795e-01 |
EXPECTED_GROWTH_EARNINGS | 2.434110e-02 |
EXPECTED_RETURN_EQUITY | 4.096414e-01 |
NUMBER_YEARS | 5.200000e+01 |
COST_CAPITAL | 8.283050e-02 |
COST_EQUITY | 8.875410e-02 |
COST_DEBT | 2.837860e-02 |
INVESTED_CAPITAL | 2.524260e+05 |
DEBT_RATIO | 8.968120e-02 |
EFFECTIVE_TAX_RATE | 4.779811e-01 |
2.1 DCF Summary
Below, I valued Saudi Aramco at about USD$1.76 trillion using a weighted DCF equity valuation:
- 50% for Operating income & FCFF
- 50% for Equity income & FCFE.
Weighted | FCFF | FCFE |
---|---|---|
$1.69 | $1.77 | $1.61 |
2.2 Sensitivity
It is very likely that investors will reward Saudi Aramco for:
- Ultralong reserve life
- Lower gearing than each of the five major international oil companies
- Ability to execute some of the world’s largest upstream and downstream capital projects
- Higher operating cash flow, free cash flow, EBIT, EBITDA, and Return on Average Capital Employed (ROACE) than each of the five major international oil companies
However, investors could also penalize Saudi Aramco for the geopolitical risk and the central banking conspiracy to keep interest rates low.
2.2.1 Risk Premium Sensitivity
Given the risk of attacks against Saudi Aramco’ oil and gas infrastructure, there is a chance that the equity risk premium and the cost of capital could go up. However, if we remove that geopolitical risk from consideration and look at the remaining risk, Aramco is a remarkably safe investment, with the mind-boggling profits and cash flows and access to huge oil reserves consisting of $201.4$ billion barrels of crude oil and condensate, $25.4$ billion barrels of NGLs, and $185.7$ trillion standard cubic feet of natural gas.
EQUITY_RISK_PREMIUM | COST_CAPITAL | WEIGHTED | FCFF | FCFE |
---|---|---|---|---|
6.00% | 7.83% | $1.81 | $1.89 | $1.72 |
6.25% | 8.07% | $1.74 | $1.82 | $1.66 |
6.50% | 8.32% | $1.68 | $1.76 | $1.61 |
6.75% | 8.57% | $1.62 | $1.70 | $1.55 |
7.00% | 8.81% | $1.57 | $1.64 | $1.50 |
7.25% | 9.06% | $1.52 | $1.59 | $1.45 |
7.50% | 9.31% | $1.47 | $1.54 | $1.41 |
7.75% | 9.55% | $1.43 | $1.49 | $1.36 |
8.00% | 9.80% | $1.39 | $1.45 | $1.32 |
8.25% | 10.05% | $1.35 | $1.41 | $1.29 |
8.50% | 10.29% | $1.31 | $1.37 | $1.25 |
8.75% | 10.54% | $1.27 | $1.33 | $1.22 |
9.00% | 10.79% | $1.24 | $1.29 | $1.18 |
9.25% | 11.04% | $1.21 | $1.26 | $1.15 |
9.50% | 11.28% | $1.18 | $1.23 | $1.12 |
9.75% | 11.53% | $1.15 | $1.20 | $1.10 |
10.00% | 11.78% | $1.12 | $1.17 | $1.07 |
2.2.2 Treasury Yield Sensitivity
Central banks around the world have conspired to keep interest rates low and artificially push up the price of financial assets. The end game in this story is that the central banks will eventually be forced to face reality, where the U.S. 10-Year Treasury will rise to normal levels and the value of Saudi Aramco could decrease.
TREASURY_YIELD_10YR | WEIGHTED | FCFF | FCFE |
---|---|---|---|
1.00% | $1.91 | $2.00 | $1.81 |
1.25% | $1.84 | $1.93 | $1.75 |
1.50% | $1.78 | $1.86 | $1.69 |
1.75% | $1.72 | $1.79 | $1.64 |
2.00% | $1.66 | $1.73 | $1.59 |
2.25% | $1.61 | $1.68 | $1.54 |
2.50% | $1.56 | $1.62 | $1.49 |
2.75% | $1.51 | $1.57 | $1.45 |
3.00% | $1.46 | $1.52 | $1.40 |
3.25% | $1.42 | $1.48 | $1.36 |
3.50% | $1.38 | $1.43 | $1.33 |
3.75% | $1.34 | $1.39 | $1.29 |
4.00% | $1.31 | $1.35 | $1.26 |
2.2.3 Reserves Life Sensitivity
Saudi Aramco’s oil equivalent reserves were sufficient for proved reserves life of $52$ years, which was significantly longer than the $9$ to $17$ year proved reserves life of any of the five major international oil companies based on publicly available information.
RESERVES_LIFE | WEIGHTED | FCFF | FCFE |
---|---|---|---|
52 | $1.69 | $1.77 | $1.61 |
51 | $1.68 | $1.76 | $1.61 |
50 | $1.68 | $1.75 | $1.60 |
49 | $1.67 | $1.75 | $1.60 |
48 | $1.67 | $1.74 | $1.59 |
47 | $1.66 | $1.73 | $1.59 |
46 | $1.65 | $1.73 | $1.58 |
45 | $1.65 | $1.72 | $1.58 |
44 | $1.64 | $1.71 | $1.57 |
43 | $1.63 | $1.70 | $1.56 |
42 | $1.62 | $1.69 | $1.56 |
41 | $1.61 | $1.68 | $1.55 |
40 | $1.60 | $1.67 | $1.54 |
Conclusion
We performed a Saudi Aramco Discounted Cash Flow (DCF) Valuation leveraging:
tidyverse
- An ecosystem for wrangling and visualizing data inR
tabulizer
- PDF Scrapingfuzzyjoin
- Joining data with inexact matchingrvest
- Web Scrapingtidyxl
- Importing non-tabular (non-tidy) Excel Data
If you would like to learn these skills, I recommend Business Science University’s 4-Course R-Track Program. This program teaches you the essential skills to apply data science to finance and accelerate you career. Learn more.
About the Author
Business Science would like to thank the author, Rafael Nicolas Fermin Cota (Follow Nico here), for contributing this powerful article on “Tidy Discounted Cash Flow Valuation”.
Rafael Nicolas Fermin Cota (Nico) founded and is the CEO at 162 Labs. He is also a part-time faculty member at the National University of Singapore.
Prior to founding 162 Labs, Nico co-founded and led the technology and research teams at OneSixtyTwo Capital. In this role, he was responsible for quantitative application development supporting various systematic trading strategies and the integration of trading/market data-driven technologies.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.