Effect size for correlations
The volatility of an asset is roughly defined by how much its price changes. In this exercise you'll measure volatility on a per-day basis, defined as the (high price - low price) / closing price.
What factors explain the volatility of Bitcoin? Is the volatility of the S&P500 closely related to this? Does volatility increase or decrease as prices rise? In other words, what is the effect size of the correlation between these different factors? You'll compute both of these effect size in this exercise.
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
, Matplotlib as plt
, and stats
from SciPy.
This exercise is part of the course
Foundations of Inference in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Compute the volatility of Bitcoin
btc_sp_df['Volatility_BTC'] = ____
# Compute the volatility of the S&P500
btc_sp_df['Volatility_SP500'] = ____
# Compute and print R^2 between the volatility of BTC and SP500
r_volatility, p_value_volatility = ____
print('R^2 between volatility of the assets:', ____)
# Compute and print R^2 between the volatility of BTC and the closing price of BTC
r_closing, p_value_closing = ____
print('R^2 between closing price and volatility of BTC:', ____)