Description Usage Arguments Value Note Author(s) Source References See Also Examples
Compute expected values of M and S given q_\mathrm{min} and define the quantity
z_r = Φ^{(1)}(q_\mathrm{min})\mbox{,}
where Φ^{(1)}(\cdot) is the inverse of the standard normal distribution. As result, q_\mathrm{min} is itself a probability because it is an argument to the qnorm()
function. The expected value M is defined as
M = Ψ(z_r, 1)\mbox{,}
where Ψ(a,b) is the gtmoms
function. The S requires the conditional moments of the Chi-square (CondMomsChi2
) defined as the two value vector \mbox{}_2S that provides the values α = \mbox{}_2S_1^2 / \mbox{}_2S_2 and β = \mbox{}_2S_2 / \mbox{}_2S_1. The S is then defined by
S = √{β}\biggl(\frac{Γ(α+0.5)}{Γ(α)}\biggr)\mbox{.}
1 | EMS(n, r, qmin)
|
n |
The number of observations; |
r |
The number of truncated observations? (confirm); and |
qmin |
A nonexceedance probability threshold for X > q_\mathrm{min}. |
The expected values of M and S in the form of an R vector
.
TAC sources call on the explicit first index of M as literally “Em[1]
” for the returned vector, which seems unnecessary. This is a potential weak point in design because the gtmoms
function is naturally vectorized and could potentially produce a vector of M values. For the implementation here, only the first value in qmin
is used and a warning otherwise issued. Such coding prevents the return value from EMS
accidentally acquiring a length greater than two. For at least samples of size n=2, overranging in a call to lgamma(alpha)
happens for alpha=0
. A suppressWarnings()
is wrapped around the applicable line. The resulting NaN
cascades up the chain, which will end up inside peta
, but therein SigmaMp
is not finite and a p-value of unity is returned.
W.H. Asquith consulting T.A. Cohn sources
LowOutliers_jfe(R).txt
, LowOutliers_wha(R).txt
, P3_089(R).txt
—Named EMS
Cohn, T.A., 2013–2016, Personal communication of original R source code: U.S. Geological Survey, Reston, Va.
CondMomsChi2
, EMS
, VMS
, V
, gtmoms
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | EMS(58,2,.5)
#[1] 0.7978846 0.5989138
# Monte Carlo experiment to test EMS and VMS functions
"test_EMS" <- function(nrep=1000, n=100, r=0, qr=0.2, ss=1) { # TAC named function
set.seed(ss)
Moms <- replicate(n=nrep, {
x <- qnorm(runif(n-r,min=qr,max=1));
c(mean(x),var(x))}); xsi <- qnorm(qr);
list(
MeanMS_obs = c(mean(Moms[1,]), mean(sqrt(Moms[2,])), mean(Moms[2,])),
EMS = c(EMS(n,r,qr), gtmoms(xsi,2) - gtmoms(xsi,1)^2),
CovMS2_obs = cov(t(Moms)),
VMS2 = V(n,r,qr),
VMS_obs = array(c(var( Moms[1,]),
rep(cov( Moms[1,], sqrt(Moms[2,])),2),
var(sqrt(Moms[2,]))), dim=c(2,2)),
VMS = VMS(n,r,qr) )
}
test_EMS()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.