Uncertainty Analysis: Gold vs. Bitcoin

[This article was first published on DataGeeek, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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"))

To leave a comment for the author, please follow the link and comment on their blog: DataGeeek.

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)