R/gof.mhd.asymptotic.R

Defines functions gof.mhd.asymptotic

Documented in gof.mhd.asymptotic

gof.mhd.asymptotic <-
function(observed, null.mean, null.cov, twoTailed = FALSE) {
	if (class(observed) != "numeric" | class(null.mean) != "numeric" | class(null.cov) != "matrix") {
		stop("Parameters are invalid.")
	}
	if (length(observed) != length(null.mean) | length(observed) != nrow(null.cov) | length(observed) != ncol(null.cov)) {
		stop("Dimensionality of function parameters do not match.")
	}
	tstat <- (observed - null.mean) %*% solve(null.cov) %*% (observed - null.mean)
	if (twoTailed) {
		pval <- 1- abs(1 - 2 * pchisq(tstat, length(observed)))
	} else {
		pval <- 1 - pchisq(tstat, length(observed))
	}
	
	return = list(p=pval, v.obs=tstat)
	class(return) <- "gof.mhd.asymptotic.result"
	return
}

Try the snopgof package in your browser

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

snopgof documentation built on May 2, 2019, 6:09 p.m.