lmom2par
).For nsim
simulation runs (ideally a very large number), samples of size $n$ are drawn from $Q(F,\theta)$ using the R-function runif(n)
to generate the simulated $F$ values and the par2qua
function to compute the quantile. The L-moments of the simulated sample are computed using lmoms
and a distribution of the same type as the parent is fit to these simulated L-moments. The $F$-quantile of the just-fitted distribution is computed and placed into a vector. The process of simulating the sample, computing the L-moments, computing the parameters, and solving for the $F$-quantile is repeated for the specified number of simulation runs.
To estimate the confidence interval, the L-moments of the vector simulated quantiles are computed. Subsequently, the parameters of a user-specified distribution
Finally, it is often useful to have vectors of lower and upper limits for confidence intervals for a vector of $F$ values. The function genci
does just that and uses the qua2ci
function as the computational engine.
qua2ci(f, para, n, ci=0.90, edist='nor', nsim=1000,
verbose=FALSE, showpar=FALSE, maxlogdiff=6)
lmom2par
or similar.ci
$< 1$). The interval is specified as the size of the interval. The default is 0.90 or the 90th percentile. The function will return the 5th (1-0.90)/2 and 95th (1-(1-0.90)/2) percentile cumulative probabin
to perform. Large numbers produce more refined confidence limit estimates at the cost of CPU time. The default is anticipated to be large enough for evaluative-useage without too much computatioedist
for each simulation are printed.list
is returned.ci
)/2.par2qua(f,para)
.ci
)/2.elmoms
.lmoms
, lmom2par
, par2qua
, genci
# It is well known that standard deviation (sigma) of the
# sample mean is equal to sigma/sample_size.
MEAN <- 0
SIGMA <- 100
PAR <- vec2par(c(MEAN,SIGMA),type='nor')
CI <- qua2ci(0.5,PAR,n=10,nsim=20) # F=0.5-->median=mean
# Theoretrical sample mean sigma = 100/10 = 10
# L-moment theory: L-scale*sqrt(pi) = sigma
# Thus, it follows that
CI$elmoms$lambdas[2]/sqrt(pi)
# approaches 10 as nsim --> Inf.
# Another example.
D <- c(123,34,4,654,37,78, 93, 95, 120) # fake sample
lmr <- lmoms(D) # compute the lmoments of the data
WEI <- parwei(lmr) # estimate parameters of the weibull
CI <- qua2ci(0.75,WEI,20,nsim=20,ci=0.95)
# CI contains the estimate 95-percent
# confidence interval for the 75th-percent of the parent
# weibull distribution for size 20 samples from the parent
Run the code above in your browser using DataLab