https://github.com/cran/ensembleBMA
Raw File
Tip revision: a104ec38cbc1ab9c2e2cc04029220523f7d371f1 authored by Chris Fraley on 08 February 2006, 00:00:00 UTC
version 2.0
Tip revision: a104ec3
gamma0BMAquant.R
"gamma0BMAquant" <-
function(alpha, WEIGHTS, POP, MEAN, VAR)
{
 # if the probability of zero is greater than the desired alpha
 # then the quantile is zero

  if (sum(WEIGHTS*POP) > alpha) return(0)

# Initialize: Find lower and upper bounds
 
  lower <- 0
  upper <- max(MEAN+6*sqrt(VAR))

  if (gamma0BMAcdf(lower, 0, WEIGHTS, POP, MEAN, VAR) > alpha) return(NA)
  if (gamma0BMAcdf(upper, 0, WEIGHTS, POP, MEAN, VAR) < alpha) return(NA)

  z <- uniroot(gamma0BMAcdf, lower = lower, upper = upper,
               offset=alpha, WEIGHTS=WEIGHTS, POP=POP, MEAN=MEAN, VAR=VAR)

# print(c(alpha, z$root,abs(z$f.root)))

  z$root
}

back to top