Python Exercise Set 320170509165948
Python Exercise Set 320170509165948
Finance/CLEFIN
2016/2017 Edition
Hints in Python:
Use the scipy library to calculate descriptive statistics
Use the statsmodels.formula.api.ols module to estimate the regression
2) Test for cointegration (à la Granger, see Brooks, or sample homework posted on class web
site).
Please use for the cointegration test, -4 as 1% test size critical value for the model with no
intercept and -3.37 for the 5% test.
Hints in Python:
Use the statsmodels.formula.api.ols module to estimate the regression
GARCH with Leverage
1) Estimate a GARCH (1, 1) model with leverage effects (of NAGARCH type) on Spanish stock
returns using maximum likelihood estimation (MLE). Set the variance of the first observation
to be equal to the unconditional sample variance of the data.
2) Plot sample autocorrelation coefficients at lags 1 through 100 for squared (𝑅𝑡2 ) as well as
squared standardized (𝑅𝑡2 /𝜎𝑡2 ) returns and compare the two.
3) Estimate a regression of daily squared returns on the variance forecasts from the GARCH
model with leverage (use the results from Question 1). Include a constant in the regression
Hints in Python:
Use the scipy.optimize module to maximize the Log Likelihood function.
QQ Plots
1) Construct a QQ plot for Spanish stock returns divided by the unconditional standard
deviation. Please use the normal distribution as the benchmark, theoretical distribution.
2) Using the conditional variance estimated obtained from the "GARCH with Leverage" part,
standardize the Italian equity returns. Construct a QQ plot for the standardized returns using
the normal distribution as a benchmark.
Hints in Python:
Use the scipy.stats.norm.ppf function to calculate the standard normal quantiles.
Use the matplotlib.pyplot module to plot graphs.
Hints in Python:
Use the numpy module to calculate covariance and correlation values.
Use the scipy.optimize module to maximize the Log Likelihood function.
Use the scipy.stats.norm.ppf function to calculate the standard normal quantiles.