你看是不是这样的——
#calculating VaR requires S-PLUS 7.0 and S+FinMetrics 2.0.
# compute log-returns
DowJones30.ret = getReturns(DowJones30)
# compute equally weighted portfolio return
w = rep(1,30)/30
port.ret.ts = rowSums(DowJones30.ret, weights=w)
#
# Extreme Value Theory
#
# compute mean excess plots for negative returns
# threshold appears to be near 0.015
par(mfrow=c(2,1))
tmp = meplot(-port.ret.ts)
shape.plot(-port.ret.ts, from=0.9, to=0.98)
par(mfrow=c(1,1))
# estimate parameters of GPD with u = 0.015
gpd.fit = gpd(-port.ret.ts, threshold=0.015)
gpd.fit
tailplot(gpd.fit)
# compute 1% VaR and ETL from fitted GPD
riskmeasures(gpd.fit, p=0.99)
gpd.q(pp=0.99, ci.p = 0.95, plot=F)
gpd.sfall(pp=0.99, ci.p = 0.95, plot=F)
|