Title: | Simultaneous Goodness-of-Fits Tests |
---|---|
Description: | Routine that allows the user to run several goodness-of-fit tests. It also combines the tests and returns a properly adjusted family-wise p value. Details can be found in <arXiv:2007.04727>. |
Authors: | Wolfgang Rolke [aut, cre]
|
Maintainer: | Wolfgang Rolke <[email protected]> |
License: | GPL-2 |
Version: | 1.0.2 |
Built: | 2025-02-21 02:43:34 UTC |
Source: | https://github.com/cran/simgof |
This function does the chisquare test
chisquare.test(x, case, which = "RGd")
chisquare.test(x, case, which = "RGd")
x |
data set |
case |
setup info |
which |
type of binning (either RGd, Equal Size or Equal Prob) |
A numeric vector of length 1 with the value of the chi-square statistic.
case <- list(B=1000, param = NULL, n = 1000, pnull = function(x, param) punif(x), rnull = function(n, param) runif(n), qnull = function(x, param) qunif(x), est.mle = function(x) NA, nbins = 10) x <- runif(1000) chisquare.test(x, case)
case <- list(B=1000, param = NULL, n = 1000, pnull = function(x, param) punif(x), rnull = function(n, param) runif(n), qnull = function(x, param) qunif(x), est.mle = function(x) NA, nbins = 10) x <- runif(1000) chisquare.test(x, case)
This function performs a number of gof tests and rejects the null if any of the tests does so. Then it finds the adjusted p-value.
simgof.test( x, pnull, rnull, qnull = function(x) NULL, do.estimation = TRUE, estimate = function(x) NULL, include.methods = c(rep(TRUE, 7), rep(FALSE, 9)), B = 10000, lambda, nbins = NULL )
simgof.test( x, pnull, rnull, qnull = function(x) NULL, do.estimation = TRUE, estimate = function(x) NULL, include.methods = c(rep(TRUE, 7), rep(FALSE, 9)), B = 10000, lambda, nbins = NULL )
x |
data set |
pnull |
distribution function under the null hypothesis |
rnull |
routine to generate data under the null hypothesis |
qnull |
quantile function under the null hypothesis |
do.estimation |
TRUE if parameters are to be estimated |
estimate |
routine for parameter estimation |
include.methods |
which methods should be used, a vector of length 16 of T/F |
B |
=10000 number of simulation runs |
lambda |
rate of Poisson if sample size is random |
nbins |
number of bins for chisquare test |
A numeric vector of p values
x <- runif(1000) pnull <- function(x) x rnull <- function(n) runif(n) qnull <- function(x) x simgof.test(x, pnull, rnull, qnull, FALSE, B=500) x <- rnorm(1000, 100, 20) pnull <- function(x, param) pnorm(x, param[1], param[2]) rnull <- function(n, param) rnorm(x, param[1], param[2]) qnull <- function(x, param) qnorm(x, param[1], param[2]) estimate <- function(x) c(mean(x), sd(x)) simgof.test(x, pnull, rnull, qnull, TRUE, estimate, B=500)
x <- runif(1000) pnull <- function(x) x rnull <- function(n) runif(n) qnull <- function(x) x simgof.test(x, pnull, rnull, qnull, FALSE, B=500) x <- rnorm(1000, 100, 20) pnull <- function(x, param) pnorm(x, param[1], param[2]) rnull <- function(n, param) rnorm(x, param[1], param[2]) qnull <- function(x, param) qnorm(x, param[1], param[2]) estimate <- function(x) c(mean(x), sd(x)) simgof.test(x, pnull, rnull, qnull, TRUE, estimate, B=500)
This function unbins data. If qnull is given it uses quantiles, otherwise uniform
spreadout(x, case)
spreadout(x, case)
x |
data set |
case |
setup info |
A numeric vector of observations without ties.
case <- list(B=1000, param = NULL, n = 1000, pnull = function(x, param) punif(x), rnull = function(n, param) runif(n), qnull = function(x, param) qunif(x), est.mle = function(x) NA, nbins = 10) y=runif(1000) bins=seq(0, 1, length=11) counts=hist(y, bins, plot=FALSE)$counts x=list(bins=bins,counts=counts) spreadout(x, case)
case <- list(B=1000, param = NULL, n = 1000, pnull = function(x, param) punif(x), rnull = function(n, param) runif(n), qnull = function(x, param) qunif(x), est.mle = function(x) NA, nbins = 10) y=runif(1000) bins=seq(0, 1, length=11) counts=hist(y, bins, plot=FALSE)$counts x=list(bins=bins,counts=counts) spreadout(x, case)
This function finds various gof statistics
TS(x, case)
TS(x, case)
x |
data |
case |
setup info |
A numeric vector with the values of various test statistics.
case <- list(B=1000, param = NULL, n = 1000, pnull = function(x, param) punif(x), rnull = function(n, param) runif(n), qnull = function(x, param) qunif(x), est.mle = function(x) NA, nbins = 10) case$methods=c("KS", "AD", "CdM", "W", "ZA", "ZK", "ZC") x <- runif(1000) TS(x, case)
case <- list(B=1000, param = NULL, n = 1000, pnull = function(x, param) punif(x), rnull = function(n, param) runif(n), qnull = function(x, param) qunif(x), est.mle = function(x) NA, nbins = 10) case$methods=c("KS", "AD", "CdM", "W", "ZA", "ZK", "ZC") x <- runif(1000) TS(x, case)