R/cat.goftests.R

Defines functions cat.goftests

Documented in cat.goftests

#[export]
cat.goftests <- function(x, props, type = "gsquare", logged = FALSE) {
  obs <- Rfast::colTabulate(x)
  est <- props * dim(x)[1]
  if (type == "chisquare" ) {
    sta <- 2 * obs * log( obs / est)
  } else  sta <- (obs - est)^2 / est
  stat <- Rfast::colsums(sta) 
  pvalue <- pchisq(stat, length(props) - 1, lower.tail = FALSE, log.p = logged )
  cbind(stat, pvalue)
}

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.