-1
$\begingroup$

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?

$\endgroup$

1 Answer 1

0
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ Why is the threshold 0.04? $\endgroup$
    – Nick
    Commented Nov 6, 2016 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.