R/colpoisdisp.tests.R

Defines functions colpoisdisp.tests

Documented in colpoisdisp.tests

#[export]
colpoisdisp.tests <- function(y, alternative = "either", logged = FALSE) {
  n <- dim(y)[1]
  m <- Rfast::colmeans(y)
  up <- Rfast::colsums(y^2) - n * m^2 - n * m
  stat <- up / ( sqrt(2 * n) * m )
  if (alternative == "either") {
    if (logged) {
      pval <- log(2) + pnorm(abs(stat), lower.tail = FALSE, log.p = logged)
	} else   pval <- 2 * pnorm(abs(stat), lower.tail = FALSE)
  } else if (alternative == "over") {
    pval <- pnorm(stat, lower.tail = FALSE, log.p = logged)
  } else pval <- pnorm(stat)
  res <- cbind(stat, pval)
  colnames(res) <- c("stat", "p-value")
  res
}
   

Try the Rfast package in your browser

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

Rfast documentation built on Nov. 9, 2023, 5:06 p.m.