# NOT RUN {
samsize <- 128; nsim <- 2000; f <- 0.999
wei <- parwei(vec2lmom(c(100,75,-.3)))
set.seed(1734); X <- rlmomco(samsize, wei); set.seed(1734)
tmp <- qua2ci.cov(X, f, type="wei", nsim=nsim)
print(tmp) # show results of one 2000 replicated Monte Carlo
# nonexceed lwr fit upr qua_med qua_mean qua_var qua_lam2
# 0.999 310.4 333.2 360.2 333.6 334.3 227.3 8.4988
set.seed(1734)
qf <- qua2ci.cov(X, f, type="wei", nsim=nsim, interval="none") # another
boxplot(qf)
message(" quantile variance: ", round(tmp$qua_var, digits=2),
" compared to ", round(var(qf, na.rm=TRUE), digits=2))
set.seed(1734)
genci.simple(wei, n=samsize, f=f)
# nonexceed lwr fit upr qua_med qua_mean qua_var qua_lam2
# 0.999 289.7 312.0 337.7 313.5 313.6 213.5 8.2330
#----------------------------------------
# Using X from above example, demonstrate that using dimensionless
# simulation that the results are the same.
set.seed(145); qua2ci.cov(X, 0.1, type="wei") # both outputs same
set.seed(145); qua2ci.cov(X, 0.1, type="wei", dimless=TRUE)
# nonexceed lwr fit upr qua_med qua_mean qua_var qua_lam2
# 0.1 -78.62 -46.01 -11.39 -43.58 -44.38 416.04 11.54
#----------------------------------------
# Using X again, demonstration application of the flip and notice that just
# simple reversal is occurring and that the Weibull is a reversed GEV.
eta <- 0
set.seed(145); qua2ci.cov(X, 0.9, type="wei", nsim=nsim)
# nonexceed lwr fit upr qua_med qua_mean qua_var qua_lam2
# 0.9 232.2 244.2 255.9 244.3 244.1 51.91 4.0635
set.seed(145); qua2ci.cov(X, 0.9, type="gev", nsim=nsim, flip=eta)
# nonexceed lwr fit upr qua_med qua_mean qua_var qua_lam2
# 0.9 232.2 244.2 256.2 244.2 244.3 53.02 4.1088
# The values are slightly different, which likely represents a combination
# of numerics of the variance-covariance matrix because the Monte Carlo
# is seeded the same.
#----------------------------------------
# Using X again, removed dimension and have the function add it back.
lmr <- lmoms(X); Y <- (X - lmr$lambdas[1])/lmr$lambdas[2]
set.seed(145); qua2ci.cov(Y, 0.9, type="wei", altlmoms=lmr, nsim=nsim)
# nonexceed lwr fit upr qua_med qua_mean qua_var qua_lam2
# 0.9 232.2 244.2 255.9 244.3 244.1 51.91 4.0635
# }
Run the code above in your browser using DataLab