The Altman’s Z-Score is a very fascinating metric used in the world of finance, in a way of predicting whether a company would exist in the next two years. Although the history is rather short, it has been proved many times as an accurate proxy of predicting a company’s bankruptcy. Developed by a professor of finance, Edward Altman, it gives a clear indication of a company’s financial strength.
The Altman’s Z-Score is calculated using 5 different key financial ratios. The formula is as follows:
\[\zeta = 1.2A + 1.4B + 3.3C + 0.6D + 1.0E \] Where:
Zeta (\(\zeta\)): The Altman’s Z Score A: Working Capital/Total Assets Ratio B: Retained Earings/Total Assets Ratio C: Earnings Before Interest and Tax/Total Assets Ratio D: Market Value of Equity/Total Liabilities Ratio E: Total Sales/Total Assets Ratio
Usually, if a company’s Altman’s Z Score is below 1.8, it means that the company is going through financial distress and that there is high chance of it collapsing within the time span of 2 years. An Altman’s Z Score between 1.8 and 3 means that the company is doing moderately okay, and a score of 3 or above meaning the company is in the safe zone.
Investors can use Altman’s Z-score to screen out companies that are deemed financially unstable, especially if their investment strategy relies on long-term, fundamentally driven trades. Altman’s Z-scores are rather frequently updated, showing the most updated financial conditions of companies.
If a single Altman’s Z score, represents the financial stability of a company at a current moment in time (most recent quarter usually), I wanted to try collecting Altman’s Z scores for all of the companies that are listed on S&P 500. I had a sense that would show me the overall strength of the market. The plan was to scrape off all of the information from the financial information platform called “Gurufocus,” and visualize the distribution of all Altman’s Z-Scores of the S&P 500 listed companies. The R codes were written as follows.
# install_github('OliverHennhoefer/quant')
if (!require("pacman")) install.packages("pacman")
## Loading required package: pacman
## Warning: package 'pacman' was built under R version 4.3.2
pacman::p_load(remotes, rvest, dplyr, ggplot2,stringr, quant)
df <- data_sp500()
df2 <- df %>% select(symbol)
head(df2, 10)
## symbol
## <char>
## 1: MMM
## 2: AOS
## 3: ABT
## 4: ABBV
## 5: ACN
## 6: ADBE
## 7: AMD
## 8: AES
## 9: AFL
## 10: A
symbol_vec <- df2$symbol
length(symbol_vec)
z_score <- c()
for (i in seq(1,length(symbol_vec),1)){
url <- paste0('https://www.gurufocus.com/term/zscore/', symbol_vec[i])
webpage <- read_html(url)
node <- webpage %>% html_nodes("p")
node <- node[6] %>% html_text()
numbers <- str_extract(node, "\\d+\\.\\d+")
numeric_value <- as.numeric(numbers)
z_score[i] <- numeric_value
print(paste0(round(i/length(symbol_vec)*100,1), "% Completed"))
}
This step is important, because for some companies in the financial sector such as banks or insurance companies, we cannot calculate the Altman’s Z-Score. We need to exclude those companies from our analysis.
df <- data.frame(symbol = symbol_vec, z_score = z_score)
df_rmna <- na.omit(df)
summary(df_rmna)
## symbol z_score
## Length:454 Min. : 0.040
## Class :character 1st Qu.: 1.865
## Mode :character Median : 3.245
## Mean : 4.799
## 3rd Qu.: 5.420
## Max. :68.990
ggplot(data = df, aes(x = z_score)) +
geom_histogram(color="darkblue", fill="lightblue", bins = 100) +
ggtitle('Histogram of the Z-Score Distribution') +
labs(x="Altman's Z-Score", y="Counts")
## Warning: Removed 49 rows containing non-finite values (`stat_bin()`).
ggplot(data = df, aes(x = z_score)) +
geom_boxplot() +
theme_classic() +
ggtitle('Box Plot of the Z-Score Distribution')
## Warning: Removed 49 rows containing non-finite values (`stat_boxplot()`).
We can infer a few things:
The first quantile of Altman’s Z-Score distribution is 1.865. This means that around of 25% of the S&P 500 companies are in financial distress, while around 75% of the companies are doing okay or in good shape. This indicates that the economy is rather in good shape, and that it is not a bad time to invest in U.S stock market.