R/davies.R

Defines functions davies

Documented in davies

davies <- function(q, lambda, h = rep(1, length(lambda)), delta = rep(0, length(lambda)), sigma = 0, lim = 10000, acc = 0.0001) {

  r <- length(lambda)
  if (any(delta < 0)) stop("All non centrality parameters in 'delta' should be positive!") 
  if (length(h) != r) stop("lambda and h should have the same length!")
  if (length(delta) != r) stop("lambda and delta should have the same length!")
  
  out <- .C("qfc", lambdas = as.double(lambda), noncentral = as.double(delta), df = as.integer(h), r = as.integer(r), sigma = as.double(sigma), q = as.double(q), lim = as.integer(lim), acc = as.double(acc), trace = as.double(rep(0, 7)), ifault = as.integer(0), res = as.double(0), PACKAGE = "CompQuadForm")

  out$res <- 1 - out$res

  if (out$res > 1) warning("Consider playing with 'lim' or 'acc'.")
  
  return(list(trace = out$trace, ifault = out$ifault, Qq = out$res))
  
}

Try the CompQuadForm package in your browser

Any scripts or data that you put into this service are public.

CompQuadForm documentation built on May 1, 2019, 7:57 p.m.