Learn R Programming

compositions (version 1.40-2)

ccompgof: Compositional Goodness of fit test

Description

Goodness of fit tests for count compositional data.

Usage

PoissonGOF.test(x,lambda=mean(x),R=999,estimated=missing(lambda))
ccompPoissonGOF.test(x,simulate.p.value=TRUE,R=1999)
ccompMultinomialGOF.test(x,simulate.p.value=TRUE,R=1999)

Arguments

x

a dataset integer numbers (PoissonGOF) or count compositions (compPoissonGOF)

lambda

the expected value to check against

R

The number of replicates to compute the distribution of the test statistic

estimated

states whether the lambda parameter should be considered as estimated for the computation of the p-value.

simulate.p.value

should all p-values be infered by simulation.

Value

A classical "htest" object

data.name

The name of the dataset as specified

method

a name for the test used

alternative

an empty string

replicates

a dataset of p-value distributions under the Null-Hypothesis got from nonparametric bootstrap

p.value

The p.value computed for this test

Missing Policy

Up to now the tests can not handle missings.

Details

The compositional goodness of fit testing problem is essentially a multivariate goodness of fit test. However there is a lack of standardized multivariate goodness of fit tests in R. Some can be found in the energy-package.

In principle there is only one test behind the Goodness of fit tests provided here, a two sample test with test statistic. $$\frac{\sum_{ij} k(x_i,y_i)}{\sqrt{\sum_{ij} k(x_i,x_i)\sum_{ij} k(y_i,y_i)}}$$ The idea behind that statistic is to measure the cos of an angle between the distributions in a scalar product given by $$ (X,Y)=E[k(X,Y)]=E[\int K(x-X)K(x-Y) dx] $$ where k and K are Gaussian kernels with different spread. The bandwith is actually the standarddeviation of k. The other goodness of fit tests against a specific distribution are based on estimating the parameters of the distribution, simulating a large dataset of that distribution and apply the two sample goodness of fit test.

References

Aitchison, J. (1986) The Statistical Analysis of Compositional Data Monographs on Statistics and Applied Probability. Chapman & Hall Ltd., London (UK). 416p.

See Also

fitDirichlet,rDirichlet, runif.acomp, rnorm.acomp,

Examples

Run this code
# NOT RUN {
x <- runif.acomp(100,4)
y <- runif.acomp(100,4)

erg <- acompGOF.test(x,y)
#continue
erg
unclass(erg)
erg <- acompGOF.test(x,y)


x <- runif.acomp(100,4)
y <- runif.acomp(100,4)
dd <- replicate(1000,acompGOF.test(runif.acomp(100,4),runif.acomp(100,4))$p.value)
hist(dd)

dd <- replicate(1000,acompGOF.test(runif.acomp(20,4),runif.acomp(100,4))$p.value)
hist(dd)
dd <- replicate(1000,acompGOF.test(runif.acomp(10,4),runif.acomp(100,4))$p.value)

hist(dd)
dd <- replicate(1000,acompGOF.test(runif.acomp(10,4),runif.acomp(400,4))$p.value)
hist(dd)
dd <- replicate(1000,acompGOF.test(runif.acomp(400,4),runif.acomp(10,4),bandwidth=4)$p.value)
hist(dd)


dd <- replicate(1000,acompGOF.test(runif.acomp(20,4),runif.acomp(100,4)+acomp(c(1,2,3,1)))$p.value)

hist(dd)


x <- runif.acomp(100,4)
acompUniformityGOF.test(x)

dd <- replicate(1000,acompUniformityGOF.test(runif.acomp(10,4))$p.value)

hist(dd)

# }

Run the code above in your browser using DataLab