Learn R Programming

MGBT (version 1.0.4)

EMS: Expected values of M and S

Description

Compute expected values of \(M\) and \(S\) given \(q_\mathrm{min}\) and define the quantity $$z_r = \Phi^{(1)}(q_\mathrm{min})\mbox{,}$$ where \(\Phi^{(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 = \Psi(z_r, 1)\mbox{,}$$ where \(\Psi(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 \(\alpha = \mbox{}_2S_1^2 / \mbox{}_2S_2\) and \(\beta = \mbox{}_2S_2 / \mbox{}_2S_1\). The \(S\) is then defined by $$S = \sqrt{\beta}\biggl(\frac{\Gamma(\alpha+0.5)}{\Gamma(\alpha)}\biggr)\mbox{.}$$

Usage

EMS(n, r, qmin)

Arguments

n

The number of observations;

r

The number of truncated observations? (confirm); and

qmin

A nonexceedance probability threshold for \(X > q_\mathrm{min}\).

Value

The expected values of \(M\) and \(S\) in the form of an R vector.

References

Cohn, T.A., 2013--2016, Personal communication of original R source code: U.S. Geological Survey, Reston, Va.

See Also

CondMomsChi2, EMS, VMS, V, gtmoms

Examples

Run this code
# NOT RUN {
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()
# }

Run the code above in your browser using DataLab