LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Foundations of Inference in Python

Kurs anzeigen

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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:', ____)
Code bearbeiten und ausführen