if (FALSE) {
X <- exp(rnorm(100))
lmoms.bernstein(X)$ratios
lmoms.bernstein(X, fix.lower=0)$ratios
lmoms.bernstein(X, fix.lower=0, bound.type="sd")$ratios
lmoms.bernstein(X, fix.lower=0, bound.type="Carv")$ratios
lmoms(X)$ratios
lmoms.bernstein(X, poly.type="Kantorovich")$ratios
lmoms.bernstein(X, fix.lower=0, poly.type="Kantorovich")$ratios
lmoms.bernstein(X, fix.lower=0, bound.type="sd", poly.type="Kantorovich")$ratios
lmoms.bernstein(X, fix.lower=0, bound.type="Carv", poly.type="Kantorovich")$ratios
lmoms(X)$ratios
}
if (FALSE) {
lmr <- vec2lmom(c(1,.2,.3))
par <- lmom2par(lmr, type="gev")
lmr <- lmorph(par2lmom(par))
lmT <- c(lmr$lambdas[1:2], lmr$ratios[3:5])
ns <- 200; nsim <- 1000; empty <- rep(NA, nsim)
sink("ChengLmomentTest.txt")
cat(c("N errmeanA errlscaleA errtau3A errtau4A errtau5A",
"errmeanB errlscaleB errtau3B errtau4B errtau5B\n"))
for(n in 1:ns) {
message(n);
SIM <- data.frame(errmeanA=empty, errlscaleA=empty, errtau3A=empty, errtau4A=empty,
errtau5A=empty, errmeanB=empty, errlscaleB=empty, errtau3B=empty,
errtau4B=empty, errtau5B=empty)
for(i in 1:nsim) {
X <- rlmomco(30, par)
lmrA <- lmoms(X)
lmA <- c(lmrA$lambdas[1:2], lmrA$ratios[3:5])
lmrB <- lmoms.bernstein(X, poly.type="Cheng")
lmB <- c(lmrB$lambdas[1:2], lmrB$ratios[3:5])
EA <- lmA - lmT; EB <- lmB - lmT
SIM[i,] <- c(EA,EB)
}
MeanErr <- sapply(1:length(SIM[1,]), function(x) { return(mean(SIM[,x])) })
line <- paste(c(n, round(MeanErr, digits=6), "\n"), sep=" ")
cat(line)
}
sink()
}
Run the code above in your browser using DataLab