Uncertainty Analysis: Gold vs. Bitcoin

Deutsche Bank Research Institute stated in its published report that Bitcoin has undergone a process similar to what gold experienced over the past 100 years.

According to the report, Bitcoin’s increasing adoption and reduced volatility may transform it into a reserve asset that central banks could hold by 2030.

The uncertainty graph below confirms the analysis mentioned above. Especially over the last two years, gold and bitcoin have converged in terms of monthly returns distribution.

Chart Code:

library(tidyverse)
library(tidyquant)
library(ggdist)

#Gold
df_gold <- 
  tq_get("GC=F") %>% 
  tq_transmute(select = close,
            mutate_fun = periodReturn,
            period = "monthly",
            col_rename = "gold_returns") %>% 
  drop_na()

#Bitcoin
df_btc <- 
  tq_get("BTC-USD") %>% 
  tq_transmute(select = close,
               mutate_fun = periodReturn,
               period = "monthly",
               col_rename = "btc_returns") %>% 
  drop_na()

#Merging the datasets
df_merged <- 
  df_gold %>% 
  left_join(df_btc) %>% 
  filter(date >= as.Date("2020-01-01")) %>% 
  drop_na() %>% 
  pivot_longer(-date) %>% 
  mutate(year = year(date) %>% as_factor())


#Uncertainty Distribution Plot
df_merged %>% 
  ggplot(aes(y = value, 
             x = year,
             fill =  name)) +
  stat_slab(aes(thickness = after_stat(pdf*n)), scale = 0.7) +
  stat_dots(side = "bottom", 
            scale = 0.7, 
            slab_linewidth = NA) +
  scale_y_continuous(labels = scales::percent) +
  scale_fill_manual(values = c("darkorange","goldenrod")) +
  labs(x = "",
       y = "", 
       fill = "",
       title = "Comparison of Monthly Returns: <span style = 'color:goldenrod;'>Gold</span> vs. <span style = 'color:darkorange;'>Bitcoin</span>") +
  theme_minimal(base_family = "Roboto Slab",
                base_size = 20) +
  theme(axis.text = element_text(face = "bold"),
        plot.title = ggtext::element_markdown(size =  18, 
                                              hjust = 0.5,
                                              face = "bold"),
        axis.text.x = element_text(angle = 45, 
                                   hjust = 1, 
                                   vjust = 1),
        legend.position = "none",
        plot.background = element_rect(fill = "azure", color = "azure"),
        panel.background = element_rect(fill = "snow", color = "snow"))

Leave a comment

I’m Selcuk Disci

Welcome to DataGeeek.com, dedicated to data science and machine learning with R, mostly based on financial data.

Let’s connect