: Login to save this software component or follow this series

# VAR_AND_ES: SHAZAM code for computing VaR and Expected Shortfall

## Author Info

• Ibrahim A. Onour

## Abstract

Since the primary goal of this program to estimate the likelihood of extreme losses (or big, unusual losses) for investors in stock markets, in Shazam program we set first the sample size (the range of the time series data) available for estimation process. In our case, the sample size extends from 1 to 1000 observations of stock prices. Immediate to the sample size command, the READ statement follows to define the variable name under investigation, which in our case is defined as x. Following the read statement, the data set should be pasted or entered. Now, compute log transformed stock returns, by successive differencing of stock prices so that (x2=x1-lag(x1)), and then determine the negative return values (x3=x2.LT.0). Estimation of likelihood of extreme risk (or extreme negative returns) justifies the use of the Generalized Pareto Distribution (GPD), which depends on extreme values and two parameters, beta1 (the tail index) and beta2 (the scale parameter). Because GPD density function requires absolute values of of the loss values, we transform the loss values into absolute values, xa=abs(x3). To determine the extreme losses we set the mean of the loss values as a threshold value (u). Set the extreme values as those values of negative returns (in absolute terms) exceeding the threshold value. Use the extreme values to estimate the GPD density parameters. Compute VaR value using the equation, v=u+(beta2/beta1)[{(N/n)(1-q)}**(-beta1)-1], where n is the number of observations of extreme losses, N is the total number of observations. Use VaR value to compute Expected Shortfall value using the relationship, ES=(VaR/1-beta1)+(beta2-ubeta1)/(1-beta1). Finally, back testing is performed by computing the percentage of number of observations of actual negative returns exceeding estimated VaR value.

If you experience problems downloading a file, check if you have the proper application to view it first. In case of further problems read the IDEAS help page. Note that these files are not on the IDEAS site. Please be patient as the files may be large.
File URL: http://www.im.pwr.wroc.pl/~hugo/RePEc/wuu/hscode/var_and_es.txt
File Function: Program file

## Bibliographic Info

Software component provided by Hugo Steinhaus Center, Wroclaw University of Technology in its series HSC Software with number M12003.

as in new window
Size:
Programming language: SHAZAM
Requires: SHAZAM VERSION 10.
Date of revision:
Handle: RePEc:wuu:hscode:m12003

Contact details of provider:
Postal: Wybrzeze Wyspianskiego 27, 50-370 Wroclaw
Phone: +48-71-3203530
Fax: +48-71-3202654
Email:
Web page: http://prac.im.pwr.wroc.pl/~hugo

## Related research

Keywords: VaR; Expected Shortfall; Extreme losses; Threshold value; Pareto distribution.;

## Lists

This item is not listed on Wikipedia, on a reading list or among the top items on IDEAS.

## Corrections

When requesting a correction, please mention this item's handle: RePEc:wuu:hscode:m12003. See general information about how to correct material in RePEc.

For technical questions regarding this item, or to correct its authors, title, abstract, bibliographic or download information, contact: (Rafal Weron).

If you have authored this item and are not yet registered with RePEc, we encourage you to do it here. This allows to link your profile to this item. It also allows you to accept potential citations to this item that we are uncertain about.

If references are entirely missing, you can add them using this form.

If the full references list an item that is present in RePEc, but the system did not link to it, you can help with this form.

If you know of missing items citing this one, you can help us creating those links by adding the relevant references in the same way as above, for each refering item. If you are a registered author of this item, you may also want to check the "citations" tab in your profile, as there may be some citations waiting for confirmation.

Please note that corrections may take a couple of weeks to filter through the various RePEc services.