dgeometric.test: Geometric Goodness-of-fit Test

Description Usage Arguments Details Value Note Author(s) References See Also Examples

View source: R/GoFKernel.r

Description

Implementation of the goodness-of-fit test based on assessing the size of the area between the null hypothesis density function and a kernel density estimate of a sample.

Usage

1
2
dgeometric.test(x, fun.den, par = NULL, lower = -Inf, upper = Inf, n.sim = 101,
                bw=NULL)

Arguments

x

a numeric vector of data values for which the null hypothesis is tested.

fun.den

an actual density distribution function, such as dnorm. Only continuous densities are valid.

par

list of (additional) parameters of the density function under the null hypothesis, default NULL.

lower

lower end point of the support of the random variable defined by fun.den, default -Inf.

upper

upper end point of the support of the random variable defined by fun.den, default -Inf.

n.sim

number of iterations performed to calculate the p.value of the test, default 101.

bw

a number indicating the bandwidth to be used in the empirical kernel estimate of the data, default NULL. In its default option, the bandwidth varies in each simulated dataset and is the one estimated by default by density with a Gaussian kernel.

Details

dgeometric.test uses numerical integration and Monte Carlo simulation to implement the test based on assessing the extend of the area between a null hypothesis density function and a density kernel estimation. It works as follows. After computing by numerical integration the area between the density function under the null hypothesis and its sample empirical kernel estimate obtained using density.reflected, the p-value of the test is obtained by simulation as follows: (i) drawing n.sim samples from fun.den with the same size length(x) of our actual sample x; (ii) estimating the kernel density function for each of these new samples; (iii) computing the area between the theoretical density and each of the estimates obtained in (ii); and, (iv) calculating the p-value as the proportion of times the sample n.sim areas computed in (iii) exceed the value of the area computed from the observed sample.

Value

The output is an object of the class htest exactly like for the Kolmogorov-Smirnov test, ks.test. A list containing the following components:

statistic

the value of the test statistic.

p.value

the p-value of the test.

method

the character string "Geometric test".

data.name

a character string giving the name of the data.

Note

dgeometric.test calls density.reflected and area.between (and, in some circunstances, also inverse, random.function and support.facto), which are (internal) functions of the package GoFKernel.

Author(s)

Jose M. Pavia

References

Pavia, JM (2015) "Testing Goodness-of-fit with the Kernel Density Estimator: GoFKernel", Journal of Statistical Software, Code Snippets, 66(1), 1–27.

See Also

area.between, density.reflected, inverse random.function, support.facto and fan.test.

Examples

1
2
3
4
5
6
7
8
set.seed(12)
x <- rlnorm(50, meanlog=1, sdlog=1)
## test if x follows a Gamma distribution with shape .6 and rate .1
dgeometric.test(x, dgamma, par=list(shape=0.6, rate=0.1), lower=0, upper=Inf, n.sim=100)

f0 <- function(x) ifelse(x>=0 & x<=1, 2-2*x, 0)
## test if risk76.1929 follows the distribution characterized by f0
dgeometric.test(risk76.1929, f0, lower=0, upper=1, n.sim=21)

GoFKernel documentation built on May 2, 2019, 11:41 a.m.