Fitting a Generalized Pareto Distribution to Return Tails
Summary
The document asks how to fit a generalized Pareto distribution to the tail of S&P 500 daily returns after comparing their empirical distribution with a normal distribution and observing heavier tails. It focuses on estimating the scale and shape parameters and on selecting a threshold beyond which observations are treated as tail data. The suggested R workflow reverses the sign of returns to examine the lower tail as an upper tail, then fits a GPD above a chosen threshold with a function from the ismev package and reads the maximum likelihood estimates from the result.
The response is a short proposed implementation rather than a validated analysis. It does not show fitted estimates, diagnostics, uncertainty, threshold selection checks, or tests that the tail is adequately modeled. A positive shape parameter is associated with a heavy, unbounded GPD tail, but the post does not establish that this property holds for the sample. The method’s conclusions depend on the threshold and on checking the fit.
Key ideas
- The peaks-over-threshold approach fits a GPD to observations beyond a selected cutoff.
- Reversing the sign of returns allows the lower tail to be analyzed as an upper tail.
- Maximum likelihood fitting can provide estimates of the GPD scale and shape parameters.
- A positive shape parameter corresponds to a heavy-tailed GPD model.
- The document does not provide diagnostics or evidence that its threshold or fitted model is appropriate.
Tags
Full text
# Fitting Tail Data to Generalized Pareto Distribution in R
# Fitting Tail Data to Generalized Pareto Distribution in R
I have a dataset of S&P500 returns for 16 yrs. When I plot the ECDF of the S&P500 and compare it against the CDF of an equivalent Normal distribution, I can see the existence of Fat Tails in the S&P 500 data. The code is as below:-
```
library(quantmod) # Loading quantmod library
getSymbols("^GSPC", from = as.character(Sys.Date()-365*16)) # SPX price date for 16 yrs
SPX <- dailyReturn(GSPC)
SPX_ecdf <- ecdf(as.numeric(SPX)) # dropping xts class
plot(SPX_ecdf,lwd=2,col="red")# Plotting the empirical CDF of S&P500
SPX_mean <- mean(as.numeric(SPX))
SPX_sd <- sd(as.numeric(SPX))
xseq<-seq(-4,4,.01)
cumulative<-pnorm(xseq, mean=SPX_mean, sd=SPX_sd)
lines(xseq,cumulative,col="blue",lwd=2) #Plotting the CDF of a Normal Distribution
legend(x="topleft",c("Empirical CDF of S&P 500 Daily returns","CDF of the Normal Distribution"),col=c("red","blue"),lwd=c(2,2))
```
Now I would like to model the Tail of my data with the help of GPD. Now if I am correct, the shape parameter ($\xi > 0$) and scale parameter ($ \beta> 0$) in order for the Tail to be a Frechet (If it has really fat tails).
Is there a way in R, to test this out and also find the value of these parameters based on my data?
There used to be a package called POT which had a function fitgpd which I believe would have given me my scale and shape parameters. But this package is no longer available. Is anybody aware of a similar function in some other package which gives me the fitted parameters?
## Answer by Deb (score 0)
https://quant.stackexchange.com/a/30001
I think this should work for me
```
library(ismev)
SPX <- SPX*(-1) # Converting the lower tail to the upper tail
fit<-gpd.fit(as.numeric(SPX),0.04) # This will fit my data of the upper tail beyond threshold of 0.04 to a GPD
fit$mle # This should give me the Maximum Likelihood estimates for the scale and shape parameter
```
Please let me know if this looks fine?Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.