class: center, middle, inverse, title-slide # Stable Coins Analysis
### Omni Analytics Group --- ## Stable Coins Stablecoins are cryptocurrencies designed to minimize the volatility of the price of a crypto asset. When functioning properly, the values of these coins do not fluctuate relative to some basket of assets. A stablecoin can be pegged to a cryptocurrency, fiat money, or to exchange-traded commodities (such as precious metals or industrial metals). The <b>denome</b> created a YouTube video: https://youtu.be/2vvHqQ0QCrQ, where he ranked some properties of the some stablecoins as follows: <p align="center"> <img src="images/stable-coin.png" width="600px"> </p> --- ## Getting Started We will be using the following libraries: ```r library(tidyverse) library(ggimage) library(psych) library(knitr) library(kableExtra) library(factoextra) library(stats) ``` --- ## The Data Using the rankings from the YouTube video, we have the following table: ```r stab <- read_csv("stablecoins.csv") stab %>% kable() %>% kable_styling(bootstrap_options = c("striped", "hover"), full_width = FALSE) ``` <table class="table table-striped table-hover" style="width: auto !important; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Coin </th> <th style="text-align:right;"> Security </th> <th style="text-align:right;"> Liquidity </th> <th style="text-align:right;"> Yield </th> <th style="text-align:right;"> Lawful </th> <th style="text-align:right;"> Transparency </th> <th style="text-align:right;"> Price_Stability </th> <th style="text-align:right;"> Backed </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> TUSD </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> DAI </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 10 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> PAX </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 9 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 9 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> RSV </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 0 </td> <td style="text-align:right;"> 6 </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> BUSD </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 9 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> USDJ </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> USDN </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 2 </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 4 </td> <td style="text-align:right;"> 3 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 0 </td> </tr> <tr> <td style="text-align:left;"> USDT </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 10 </td> <td style="text-align:right;"> 10 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 5 </td> <td style="text-align:right;"> 9 </td> <td style="text-align:right;"> 1 </td> </tr> <tr> <td style="text-align:left;"> USDC </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 7 </td> <td style="text-align:right;"> 10 </td> <td style="text-align:right;"> 9 </td> <td style="text-align:right;"> 8 </td> <td style="text-align:right;"> 9 </td> <td style="text-align:right;"> 1 </td> </tr> </tbody> </table> --- ## Dimensionality Reduction For better visualization of the ranking of these stablecoins, we will perform Principal Component Analysis. ```r pc <- prcomp(stab %>% select(-Coin), scale = TRUE) ``` Using the `factoextra` package, we can easily visualize the components. <br> <br> <p align="left"> <img src="Cut_outs/Cut_out_02.png" width="200px" height="200px"> </p> --- ## Screeplot ```r fviz_eig(pc) ``` <img src="stable-coins-case-study_files/figure-html/unnamed-chunk-4-1.png" width="600" style="display: block; margin: auto;" /> --- ## Biplot ```r fviz_pca_biplot(pc, repel = TRUE, # Avoid text overlapping col.var = "red", # Variables color col.ind = "blue") # Individuals color ``` <img src="stable-coins-case-study_files/figure-html/unnamed-chunk-5-1.png" width="600" style="display: block; margin: auto;" /> --- ## Readibility Most of the time we read things from left to right (low to high) and down to up (low to high), so let's flip the signs of the principal components. ```r pc$x <- -pc$x pc$rotation <- -pc$rotation ``` <br> <p align="right"> <img src="Cut_outs/Cut_out_25f.png" width="150px" height="250px"> </p> --- ## Biplot (after flipping signs) ```r fviz_pca_biplot(pc, repel = TRUE, # Avoid text overlapping col.var = "red", # Variables color col.ind = "blue") ``` <img src="stable-coins-case-study_files/figure-html/unnamed-chunk-7-1.png" width="600" style="display: block; margin: auto;" /> --- ## Interpretation From the biplot, we see the following: - A stablecoin being on the right side of the graph will have a higher score compared to being on the left side. - A stablecoin being at the top of the graph will have a higher score in terms of Transparency, Security, and Lawful compared to those at the bottom. - A stablecoin being at the bottom of the graph will have a higher score in terms of Yield, Liquidity and Price Stability compared to those at the top. <p align="center"> <img src="Cut_outs/Cut_out_04.png" width="200px" height="200px"> </p> --- ## Plot 1 We can use `geom_point()` from `ggplot2` to create a simple plot as well. ```r pc$x %>% as_tibble() %>% ggplot(aes(x = PC1, y = PC2)) + geom_point() ``` <img src="stable-coins-case-study_files/figure-html/unnamed-chunk-8-1.png" width="600" style="display: block; margin: auto;" /> --- ## Coins' Symbols Let's show the coins' names and symbols in the plot as well! We have the coins' names in the `stab` table. We also have the coins' symbols in our images folder. They are downloaded from the CoinGecko website: https://www.coingecko.com/en. We will create a table with the principal components, coins' names and the paths to the coins' symbols as follows: ```r mypc <- pc$x %>% as_tibble() %>% mutate(Coin = stab$Coin, Path = paste0("images/", Coin, ".png")) ``` --- ## Plot 2 Using `geom_image()` and `geom_label()`, we have the following plot: ```r ggplot(data = mypc, aes(x = PC1, y = PC2)) + geom_point() + geom_image(aes(image = Path), size = 0.08) + geom_label(aes(label = Coin), alpha = 0.8) ``` <img src="stable-coins-case-study_files/figure-html/unnamed-chunk-10-1.png" width="600" style="display: block; margin: auto;" /> --- ## Plot 3 To finalize the plot, we will do the following: - Add dividers at `\(x=0\)` and `\(y=0\)` using `geom_hline()` and `geom_vline()` - Add title and axis label using `labs()` - Include some interpretations in the plot using `scale_y_continuous` and `scale_x_continuous` ```r p3<- ggplot(data = mypc, aes(x = PC1, y = PC2)) + geom_point() + geom_image(aes(image = Path), size = 0.08) + geom_label(aes(label = Coin), alpha = 0.8) + geom_hline(yintercept = 0) + geom_vline(xintercept = 0) + scale_x_continuous(limits = c(-3, 3), breaks = -3:3, labels = c("", "Lower Scores", expression(symbol("\254")), "", expression(symbol("\256")), "Higher Scores", "")) + scale_y_continuous(limits = c(-3, 3), breaks = -3:3, labels = c("", "Investment Focused", expression(symbol("\254")), "", expression(symbol("\256")), "Security Focused", "")) + theme(axis.text.y = element_text(angle = 90, hjust = 0.5)) + labs(y = "Focus", x = "Overall Score", title = "A Visualization of the Stablecoin Landscape", subtitle = "Analysis and Rankings by @denomeme") ``` --- ```r p3 ``` <img src="stable-coins-case-study_files/figure-html/unnamed-chunk-12-1.png" width="600" style="display: block; margin: auto;" /> --- ## Conclusion Utilizing denome's stable coin data we've been able to create a projection that places each asset along two composite dimensions. The vertical `Focus` axis differentiates coins according to whether they were designed to be secure or an accessible investment. The horizontal axis looks at the overall values, assigning higher scores to the coins that scored high on each attribute. In the end we've used statistical techniques to make it easier for us to select a stablecoin that's best aligned with our needs.