Exercise

Permutation tests for correlations

How does the volatility of Bitcoin compare to the volatility of the S&P 500?

You previously computed volatility as the percent daily change, which has been stored for you in the Pct_Daily_Change_BTC and Pct_Daily_Change_SP500 columns in your data. The question you want to answer is the extent to which these two values correlate. One way to answer this is through a permutation test. By randomly shuffling values between the S&P 500 and BTC you are able to see what a random outcome would like like, and then compare this to the observed values.

A DataFrame of S&P 500 and Bitcoin prices (btc_sp_df) has been loaded for you, as have the packages pandas as pd, NumPy as np, and stats from SciPy.

Instructions

100 XP
  • Define a statistic() function which returns just the Pearson R value between two vectors.
  • Set your data equal to a tuple containing the volatility of BTC and SP500.
  • Conduct a permutation test with this data, statistic, 1000 resamples, and with an alternative hypothesis of greater volatility with Bitcoin.
  • Print if the p-value is significant at 5%.