Skip to contents

This function performs the kernel-based quadratic distance goodness-of-fit tests using the Gaussian kernel with tuning parameter h.

Usage

kb.test(
  x,
  y = NULL,
  h = NULL,
  method = "subsampling",
  B = 150,
  b = NULL,
  Quantile = 0.95,
  mu_hat = NULL,
  Sigma_hat = NULL,
  centeringType = "Nonparam",
  K_threshold = 10,
  alternative = "skewness"
)

# S4 method for ANY
kb.test(
  x,
  y = NULL,
  h = NULL,
  method = "subsampling",
  B = 150,
  b = 0.9,
  Quantile = 0.95,
  mu_hat = NULL,
  Sigma_hat = NULL,
  centeringType = "Nonparam",
  K_threshold = 10,
  alternative = "skewness"
)

# S4 method for kb.test
show(object)

Arguments

x

Numeric matrix or vector of data values.

y

Numeric matrix or vector of data values. Depending on the input y, the corresponding test is performed.

  • if y = NULL, the function performs the tests for normality on x

  • if y is a data matrix, with same dimensions of x, the function performs the two-sample test between x and y.

  • if y is a numeric or factor vector, indicating the group memberships for each observation, the function performs the k-sample test.

h

Bandwidth for the kernel function. If a value is not provided, the algorithm for the selection of an optimal h is performed automatically. See the function select_h for more details.

method

The method used for critical value estimation ("subsampling", "bootstrap", or "permutation")(default: "subsampling").

B

The number of iterations to use for critical value estimation (default: 150).

b

The size of the subsamples used in the subsampling algorithm (default: 0.8).

Quantile

The quantile to use for critical value estimation, 0.95 is the default value.

mu_hat

Mean vector for the reference distribution.

Sigma_hat

Covariance matrix of the reference distribution.

centeringType

String indicating the method used for centering the normal kernel ('Param' or 'Nonparam').

K_threshold

maximum number of groups allowed. Default is 10. It is a control parameter. Change in case of more than 10 samples.

alternative

Family of alternative chosen for selecting h, between "location", "scale" and "skewness" (only if h is not provided).

object

Object of class kb.test

Value

An S4 object of class kb.test containing the results of the kernel-based quadratic distance tests, based on the normal kernel. The object contains the following slots:

  • method: String indicating the normal kernel-based quadratic distance test performed.

  • x Data list of samples X (and Y).

  • Un The value of the U-statistics.

  • H0_Un A logical value indicating whether or not the null hypothesis is rejected according to Un.

  • CV_Un The critical value computed for the test Un.

  • Vn The value of the V-statistic (if available).

  • H0_Vn A logical value indicating whether or not the null hypothesis is rejected according to Vn (if available).

  • CV_Vn The critical value computed for the test Vn (if available).

  • h List with the value of bandwidth parameter used for the normal kernel function. If select_h is used, the matrix of computed power values and the corresponding power plot are also provided.

  • B Number of bootstrap/permutation/subsampling replications.

  • var_Un exact variance of the kernel-based U-statistic.

  • cv_method The method used to estimate the critical value (one of "subsampling", "permutation" or "bootstrap").

Details

The function kb.test performs the kernel-based quadratic distance tests using the Gaussian kernel with bandwidth parameter h. Depending on the shape of the input y the function performs the tests of multivariate normality, the non-parametric two-sample tests or the k-sample tests.

References

Markatou, M., Saraceno, G., Chen Y (2024). “Two- and k-Sample Tests Based on Quadratic Distances.” Manuscript, (Department of Biostatistics, University at Buffalo)

Lindsay, B.G., Markatou, M. & Ray, S. (2014) "Kernels, Degrees of Freedom, and Power Properties of Quadratic Distance Goodness-of-Fit Tests", Journal of the American Statistical Association, 109:505, 395-410, DOI: 10.1080/01621459.2013.836972

Examples

# create a kb.test object
x <- matrix(rnorm(100),ncol=2)
y <- matrix(rnorm(100),ncol=2)
# Normality test
my_test <- kb.test(x, h=0.5)
my_test
#> 
#>  Kernel-based quadratic distance Normality test 
#> 		U-statistic	V-statistic
#> ------------------------------------------------
#> Test Statistic:	 2.978473 	 1.098674 
#> Critical Value:	 1.466736 	 6.071062 
#> H0 is rejected:	 TRUE 		 FALSE 
#> Selected tuning parameter h:  0.5 
#> 
# Two-sample test
my_test <- kb.test(x,y,h=0.5, method="subsampling",b=0.9,
                     centeringType = "Nonparam")
my_test
#> 
#>  Kernel-based quadratic distance two-sample test 
#> U-statistics	 Dn 		 Trace 
#> ------------------------------------------------
#> Test Statistic:	 0.8134901 	 1.059493 
#> Critical Value:	 1.174737 	 1.531701 
#> H0 is rejected:	 FALSE 		 FALSE 
#> CV method:  subsampling 
#> Selected tuning parameter h:  0.5 
#> 
# k-sample test
z <- matrix(rnorm(100,2),ncol=2)
dat <- rbind(x,y,z)
group <- rep(c(1,2,3),each=50)
my_test <- kb.test(x=dat,y=group,h=0.5, method="subsampling",b=0.9)
my_test
#> 
#>  Kernel-based quadratic distance k-sample test 
#> U-statistics	 Dn 		 Trace 
#> ------------------------------------------------
#> Test Statistic:	 8.168068 	 13.92795 
#> Critical Value:	 0.6400931 	 1.092282 
#> H0 is rejected:	 TRUE 		 TRUE 
#> CV method:  subsampling 
#> Selected tuning parameter h:  0.5 
#>