【发布时间】:2016-09-05 14:51:56
【问题描述】:
我有一个 16 年的 S&P500 回报数据集。当我绘制 S&P500 的 ECDF 并将其与等效正态分布的 CDF 进行比较时,我可以看到 S&P 500 数据中存在 Fat Tails。代码如下:-
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)为了让尾巴成为 Frechet(如果它的尾巴真的很肥)。
在 R 中有没有一种方法可以测试这一点并根据我的数据找到这些参数的值?
曾经有一个名为 POT 的包,它有一个函数 fitgpd,我相信它会给我我的比例和形状参数。但是这个包不再可用。有人知道其他包中的类似功能可以为我提供拟合参数吗?
【问题讨论】:
-
fExtremes 和 fitdistrplus 包已经存在很长时间了,我会尝试第一个。
标签: r