cutoff.bootstrap: Bootstrap critical value for the goodness-of-fit test...

View source: R/cutoff.bootstrap.R

cutoff.bootstrapR Documentation

Bootstrap critical value for the goodness-of-fit test statistic \hat{S}_n(h) of Bagkavos, Patil and Wood (2021)

Description

Implements a bootstrap critical value for testing the goodness-of-fit of a parametrically estimated density with the test statistic S.n.

Usage

cutoff.bootstrap(xin, M,  sim, dist, h.use, kfun, p1, p2, sig.lev)

Arguments

xin

A vector of data points - the available sample.

M

Number of bootstrap replications.

sim

A character string indicating the type of simulation required: "ordinary" (the default), "parametric", "balanced", "permutation", or "antithetic".

dist

The null distribution.

h.use

The test statistic bandwidth, best implemented with hopt.be.

kfun

The kernel to use in the density estimates used in the bandwidth expression.

p1

Parameter 1 (vector or object) for the null distribution.

p2

Parameter 2 (vector or object) for the null distribution.

sig.lev

Significance level of the hypothesis test.

Details

Implements the bootstrap based finite sample critical value defined in Section 2.6, Bagkavos, Patil and Wood (2021), and calculated as follows:

1. Resample the observations \mathcal{X}=\{X_1, …, X_n\} to obtain M bootstrap samples, denoted by \mathcal{X}_m^\ast=\{ X_{1m}^\ast, …, X_{nm}^\ast\}, where for each m=1,… , M, \mathcal{X}_m^\ast is sampled randomly, with replacement, from \mathcal{X}. Write \hat{θ}=θ(\mathcal{X}) for the estimator of θ based on the original sample \mathcal{X} and, for each m, define the bootstrap estimator of θ by \hat{θ}_m^\ast = θ(\mathcal{X}_m^\ast), where θ(\cdot) is the relevant functional for the parameter θ.

2. For m=1, … , M, use \mathcal{X}_m^\ast =\{X_{1m}^\ast, …, X_{nm}^\ast\} and \hat θ_m^\ast from the previous step to calculate n Δ^{2d} h^{-d/2} \hat S_{n,m}^\ast(hρ),m=1, …, M.

3. Calculate \ell_α^\ast as the 1-α empirical quantile of the values n Δ^{2d} h^{-d/2} \hat S_{n,m}^\ast(hρ), m=1, …, M. Then \ell_α^\ast approximately satisfies P^\ast [ n Δ^{2d} h^{-d/2}\hat S_{n,m}^\ast(hρ)> \ell_α^\ast ]=1-α, where P^\ast indicates the bootstrap probability measure conditional on \mathcal{X}.

Value

A scalar, the estimate of the bootstrap critical value at the given significance level.

Author(s)

Dimitrios Bagkavos

R implementation and documentation: Dimitrios Bagkavos <dimitrios.bagkavos@gmail.com>

References

Bagkavos, Patil and Wood: Nonparametric goodness-of-fit testing for a continuous multivariate parametric model, (2021), under review.

Gao and Gijbels, Bandwidth selection in nonparametric kernel testing, pp. 1584-1594, JASA (2008)

See Also

cutoff.asymptotic, cutoff.edgeworth

Examples

library(nor1mix)
library(boot)
SampleSize<-80
M<-1000
dist<- "normixt"
kfun<- Epanechnikov
p1 <-MW.nm2
p2 <-1
sig.lev <- 0.05

sim<-"ordinary"
## Not run: 
#Run the following to compare the asymptotic and bootstrap cut-off points on 4 occasions:
for(i in 15:18)
  {
    set.seed(i)
    xin<-rnorMix(SampleSize, p1)
    h.use <- hopt.be(xin)
    l.a.a<-cutoff.asymptotic( dist,   p1, p2, sig.lev )
    l.a.b<- cutoff.bootstrap(xin,  M,  sim, dist, h.use,  kfun, p1, p2, sig.lev)
    #print the result of each iteration:
    cat("Asympt. cut.off= ", l.a.a, "Boot. cut.off= ", l.a.b,  "\n")
   }

## End(Not run)

L2DensityGoFtest documentation built on Feb. 16, 2023, 9:24 p.m.