np.deneqtest.Rdnpdeneqtest implements a consistent integrated squared
difference test for equality of densities as described in Li, Maasoumi,
and Racine (2009).
npdeneqtest(x = NULL,
y = NULL,
bw.x = NULL,
bw.y = NULL,
boot.num = 399,
random.seed = 42,
...)data frames for the two samples for which one wishes to test equality of densities. The variables in each data frame must be the same (i.e. have identical names).
optional bandwidth objects for x,y
an integer value specifying the number of bootstrap
replications to use. Defaults to 399.
an integer used to seed R's random number generator. This is to ensure replicability. Defaults to 42.
additional arguments supplied to specify the bandwidth
type, kernel types, and so on. This is used if you do not pass in
bandwidth objects and you do not desire the default behaviours. To
do this, you may specify any of bwscaling, bwtype,
ckertype, ckerorder, ukertype,
okertype.
npdeneqtest returns an object of type deneqtest with the
following components
the (standardized) statistic Tn
the (unstandardized) statistic In
contains the bootstrap replications of Tn
contains the bootstrap replications of In
the P-value of the Tn statistic
the P-value of the In statistic
number of bootstrap replications
summary supports object of type deneqtest.
Li, Q. and E. Maasoumi and J.S. Racine (2009), “A Nonparametric Test for Equality of Distributions with Mixed Categorical and Continuous Data,” Journal of Econometrics, 148, pp 186-200.
npdeneqtest computes the integrated squared density difference
between the estimated densities/probabilities of two samples having
identical variables/datatypes. See Li, Maasoumi, and Racine (2009) for
details.
If you are using data of mixed types, then it is advisable to use the
data.frame function to construct your input data and not
cbind, since cbind will typically not work as
intended on mixed data types and will coerce the data to the same
type.
It is crucial that both data frames have the same variable names.
if (FALSE) { # \dontrun{
set.seed(1234)
## Distributions are equal
n <- 250
sample.A <- data.frame(x=rnorm(n))
sample.B <- data.frame(x=rnorm(n))
npdeneqtest(sample.A,sample.B,boot.num=99)
Sys.sleep(5)
## Distributions are unequal
sample.A <- data.frame(x=rnorm(n))
sample.B <- data.frame(x=rchisq(n,df=5))
npdeneqtest(sample.A,sample.B,boot.num=99)
## Mixed datatypes, distributions are equal
sample.A <- data.frame(a=rnorm(n),b=factor(rbinom(n,2,.5)))
sample.B <- data.frame(a=rnorm(n),b=factor(rbinom(n,2,.5)))
npdeneqtest(sample.A,sample.B,boot.num=99)
Sys.sleep(5)
## Mixed datatypes, distributions are unequal
sample.A <- data.frame(a=rnorm(n),b=factor(rbinom(n,2,.5)))
sample.B <- data.frame(a=rnorm(n,sd=10),b=factor(rbinom(n,2,.25)))
npdeneqtest(sample.A,sample.B,boot.num=99)
} # }