2016-09-05 117 views
0

我有一个S & P500数据集为16年的收益率。当我绘制S & P500的ECDF并将其与等效正态分布的CDF进行比较时,可以看到P 500数据中存在脂肪尾部。代码如下: -将尾数据拟合为R中的广义帕累托分布

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)) 

现在我想在GPD的帮助下模拟我的数据的尾部。现在,如果我是正确的,那么形状参数(ξ> 0)和缩放参数(β> 0)以使尾部成为一个虚线(如果它真的有尾巴)。

在R中有没有一种方法来测试这一点,并根据我的数据找到这些参数的值?

曾经有一个叫POT包,其中有一个功能fitgpd我相信会按我的比例和形状参数。但是这个软件包不再可用。是否有人知道一些其他软件包中的类似功能,这些软件包给我提供了拟合参数?

+0

fExtremes和fitdistrplus软件包已经存在了很长时间,并且会是我第一次尝试。 –

回答

0

我认为这应该为我工作

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 

请让我知道这看起来不错?