One Sample Goodness-of-fit Test

Share:

Description

Goodness-of-fit test for one sample data with two bootstrap methods: multiplier bootstrap and parametric bootstrap. The multipler bootstrap method is faster, using generic numeric derivatives.

Usage

1
2
3
4
5
gof.test(x, distr, nsim, start, 
         simulation = c("mult", "pb"),
         ng = 1000, qgrid = c("empirical", "fitted"),
         gridStat = NULL, method.args = gradControl(),
         derCdfWrtPar = NULL, derLogPdfWrtPar = NULL, ...)

Arguments

x

a vector or matrix of data to be tested.

distr

name of the hypothesized distribution, assuming that dpr functions are available for density, distribution, and random number generation. For example, if "foo" is the hypothesized distribution, then functions "dfoo", "pfoo", and "rfoo" must be available.

nsim

the bootstrap sample size.

start

a list of named components for the starting value of the parameter estimate.

ng

The size of the grid points for numerical integration.

simulation

method of bootstrap: "mult" for multiplier bootstrap; "pb" for parametric bootstrap.

qgrid

method to construct the grid for numerical integration: "empirical" for empirical quantiles; "fitted" for fitted quantiles.

gridStat

Not used for one dimensional distribution now.

method.args

a list of arguments to control the "method.args" for jocobian from package numDeriv. The defaul is: eps=1e-4, d=0.0001, zero.tol=sqrt(.Machine$double.eps/7e-7), r=6, v=2, show.details=FALSE

derCdfWrtPar

derivative function of the cdf with respect to parameters. The dedault is NULL, in which case, numerical derivative is used.

derLogPdfWrtPar

derivative function of the logPdf with respect to parameters. The dedault is NULL, in which case, numerical derivative is used.

...

other arguments to be passed to dpr function of the distribution.

Details

The function has been fully tested with dimension 1. For higher dimensions, wrapper functions are often needed. Examples will be provided in future releases.

Value

a list with the following components:

statistic

vector of test statistics

p.value

vector of p-values of the test statistics

estimate

vector of estimated parameter values

stat.sim

matrix of bootstrap draws of the test statistics

Author(s)

Ivan Kojadinovic and Jun Yan.

References

Kojadinovic I. and Yan J.: Goodness-of-fit testing based on a weighted bootstrap: A fast large-sample alternative to the parametric bootstrap. Canadian Journal of Statistics. Forthcoming.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
set.seed(123)

n <- 200
x <- rlnorm(200, 1, 1)

system.time(m1 <- gof.test(x, "lnorm", 1000, list(meanlog=1, sdlog=1), simulation="pb"))
system.time(m2 <- gof.test(x, "lnorm", 200, list(meanlog=1, sdlog=1), simulation="mult"))
apply(m1$stat.sim, 1, summary)
apply(m2$stat.sim, 1, summary)

system.time(m1 <- gof.test(x, "gamma", 1000, list(shape=1, rate=1), simulation="pb"))
system.time(m2 <- gof.test(x, "gamma", 200, list(shape=1, rate=1), simulation="mult"))
apply(m1$stat.sim, 1, summary)
apply(m2$stat.sim, 1, summary)


system.time(m1 <- gof.test(x, "exp", 1000, list(rate=1), simulation="pb"))
system.time(m2 <- gof.test(x, "exp", 200, list(rate=1), simulation="mult"))
apply(m1$stat.sim, 1, summary)
apply(m2$stat.sim, 1, summary)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.