Correlation between SX5E and V2TX
We can use the corr
function to derive the correlation values between each column of values in the pandas DataFrame
object, as in the following Python example:
>>> print log_returns.corr() EUROSTOXX VSTOXX EUROSTOXX 1.000000 -0.732545 VSTOXX -0.732545 1.000000 [2 rows x 2 columns]
At -0.7325
, the EURO STOXX 50 Index is negatively correlated with the STOXX. To help us better visualize this relationship, we can plot both the sets of the daily log return values as a scatter plot. The statsmodels.api
module is used to obtain the ordinary least squares regression line between the scattered data:
>>> import statsmodels.api as sm >>> >>> log_returns.plot(figsize=(10,8), ... x="EUROSTOXX", ... y="VSTOXX", ... kind='scatter') >>> >>> ols_fit = sm.OLS(log_returns['VSTOXX'].values, ... log_returns['EUROSTOXX'].values).fit() >...