Parameter estimation: Skewed Normal
In the previous exercise you found that fitting a Normal distribution to the investment bank portfolio data from 2005 - 2010 resulted in a poor fit according to the Anderson-Darling test.
You will test the data using the skewtest() function from scipy.stats. If the test result is statistically different from zero, then the data support a skewed distribution. 
Now you'll parametrically estimate the 95% VaR of a loss distribution fit using scipy.stats's skewnorm skewed Normal distribution. This is a more general distribution than the Normal and allows losses to be non-symmetrically distributed. We might expect losses to be skewed during the crisis, when portfolio losses were more likely than gains.
Portfolio losses for the 2007 - 2009 period are available.
Diese Übung ist Teil des Kurses
Quantitative Risk Management in Python
Anleitung zur Übung
- Import 
skewnormandskewtestfromscipy.stats. - Test for skewness in portfolio 
lossesusingskewtest. The test indicates skewness if the result is statistically different from zero. - Fit the 
lossesdata to the skewed Normal distribution using the.fit()method. - Generate and display the 95% VaR estimate from the fitted distribution.
 
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Import the skew-normal distribution and skewness test from scipy.stats
from scipy.stats import skewnorm, skewtest
# Test the data for skewness
print("Skewtest result: ", ____(____))
# Fit the portfolio loss data to the skew-normal distribution
params = ____.____(losses)
# Compute the 95% VaR from the fitted distribution, using parameter estimates
VaR_95 = ____.____(0.95, *params)
print("VaR_95 from skew-normal: ", VaR_95)