Correlation Analysis of Silver, Bitcoin, SOXX, and Blockchain Index with {corrr} package

[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.

Silver, Nasdaq Blockchain Economy Index, Bitcoin, and iShares Semiconductor ETF are always thought of as correlated with each other by investors.

We will test this perception with the corrr package.

#iShares Semiconductor ETF (SOXX)
df_soxx <- 
  tq_get(x = "SOXX") %>% 
  select(date, soxx = close)

#Nasdaq Blockchain Economy Index
df_nasdaq_blockchain <- 
  openxlsx::read.xlsx("https://github.com/mesdi/investingcom/raw/refs/heads/main/nasdaq_blockchain.xlsx",
                      sheet = "History",
                      detectDates = TRUE) %>% 
  as_tibble() %>% 
  janitor::clean_names() %>%
  select(date = trade_date, blcn = index_value)

#Bitcoin
df_btc <- 
  tq_get("BTC-USD") %>% 
  select(date, btc = close)


#Merging the datasets
df_merged <- 
  df_silver %>% 
  left_join(df_soxx) %>% 
  left_join(df_nasdaq_blockchain) %>% 
  left_join(df_btc) %>% 
  drop_na() %>% 
  filter(date >= last(date) - months(36))

#Correlation
d <- correlate(df_merged, quiet = TRUE)

d %>% 
  focus(silver:btc, mirror = TRUE) %>%  
  fashion()

#    term silver soxx blcn  btc
#1 silver         .78  .89  .89
#2   soxx    .78       .85  .80
#3   blcn    .89  .85       .97
#4    btc    .89  .80  .97     

#Network plot
df_merged %>% 
  correlate() %>% 
  network_plot(min_cor = .7,
               legend = "full")


The common perception appears to be correct based on the correlation analysis, specifically between the Nasdaq Blockchain Economy index and Bitcoin.

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)