S.nd: Density goodness-of-fit test statistic based on discretized...

View source: R/S.nd.R

S.ndR Documentation

Density goodness-of-fit test statistic based on discretized L2 distance

Description

Implements the multivariate (d >=2) density goodness of fit test statistic \hat{S}_n(h) of Bagkavos, Patil and Wood (2021), based on aggregation of local discrepancies between the fitted parametric density and a nonparametric empirical density estimator.

Usage

S.nd(xin, h,  dist, p1, p2)

Arguments

xin

A matrix (n x d) of data points - the available sample with n rows and d columns, each column corresponds to a different coordinate axis.

h

The bandwidth vector to use, typically the output of hopt.be in each coordinate direction.

dist

The null distribution.

p1

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

p2

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

Details

Implements the test statistic used for testing the hypothesis

H_0: f(x) = f_0(x, p1, p2) \;\; vs \;\; H_a: f(x) \neq f_0(x, p1, p2).

This density goodness-of-fit test is based on a discretized approximation of the L2 distance. Assuming that n is the number of observations and g = (max(xin)-min(xin))/n^{-drate} is the number of bins in which the range of the data is split, the test statistic is:

S_n(h) = n Δ^2 {∑∑}_{i \neq j} K \{ (X_{i1}-X_{j1})h_1^{-1}, …, (X_{id}-X_{jd})h_d^{-1} \} \{Y_i -f_0(X_i) \}\{Y_j -f_0(X_j) \}

where K is the Epanechnikov kernel implemented in this package with the Epanechnikov function. The null model f_0 is specified through the dist argument with parameters passed through the p1 and p2 arguments. The test is implemented either with bandwidth hopt.edgeworth or with bandwidth hopt.be which provide the value of h needed for calculation of S_n(h) and the critical value used to determine acceptance or rejection of the null hypothesis.

Value

A vector with the value of the test statistic as well as the Delta value used for its calculation

Author(s)

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.

See Also

S.n

Examples

library(mvtnorm)
sigma <- matrix(c(4,2,2,3), ncol=2)

x <- rmvnorm(n=100, mean=c(1,2), sigma=sigma)
h.be1 <- hopt.be(x[,1])
h.be2 <- hopt.be(x[,2])
h<-c(h.be1, h.be2)
Nulldist<-"normal"

S.nd(x, h,  Nulldist, c(1,2), sigma)

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