GOFmontecarlo function

Goodness of fit tests

Goodness of fit tests

Anderson-Darling goodness of fit tests for Regional Frequency Analysis: Monte-Carlo method.

gofNORMtest (x) gofEXPtest (x, Nsim=1000) gofGUMBELtest (x, Nsim=1000) gofGENLOGIStest (x, Nsim=1000) gofGENPARtest (x, Nsim=1000) gofGEVtest (x, Nsim=1000) gofLOGNORMtest (x, Nsim=1000) gofP3test (x, Nsim=1000)

Arguments

  • x: data sample
  • Nsim: number of simulated samples from the hypothetical parent distribution

Details

An introduction, analogous to the following one, on the Anderson-Darling test is available on https://en.wikipedia.org/wiki/Anderson-Darling_test.

Given a sample xi(i=1,...,m)xi (i=1,...,m) of data extracted from a distribution FR(x)FR(x), the test is used to check the null hypothesis H0:FR(x)=F(x,θ)H0 : FR(x) = F(x,\theta), where F(x,θ)F(x,\theta) is the hypothetical distribution and θ\theta is an array of parameters estimated from the sample xixi.

The Anderson-Darling goodness of fit test measures the departure between the hypothetical distribution F(x,θ)F(x,\theta) and the cumulative frequency function Fm(x)Fm(x) defined as:

Fm(x)=0 , x<x(1)Fm(x)=0,x<x(1) F_m(x) = 0 \ , \ x < x_{(1)}Fm(x)=0, x<x(1) Fm(x)=i/m , x(i)x<x(i+1)Fm(x)=i/m,x(i)<=x<x(i+1) F_m(x) = i/m \ , \ x_{(i)} \leq x < x_{(i+1)}Fm(x)=i/m, x(i)<=x<x(i+1) Fm(x)=1 , x(m)xFm(x)=1,x(m)<=x F_m(x) = 1 \ , \ x_{(m)} \leq xFm(x)=1, x(m)<=x

where x(i)x(i) is the ii-th element of the ordered sample (in increasing order).

The test statistic is:

Q2=m ⁣x[Fm(x)F(x,θ)]2Ψ(x)dF(x)Q2=mint[Fm(x)F(x,θ)]2Ψ(x)dF(x) Q^2 = m \! \int_x \left[ F_m(x) - F(x,\theta) \right]^2 \Psi(x) \,dF(x)Q2 = m int[Fm(x) - F(x,\theta)]^2 \Psi(x) dF(x)

where Ψ(x)\Psi(x), in the case of the Anderson-Darling test (Laio, 2004), is Ψ(x)=[F(x,θ)(1F(x,θ))]1\Psi(x) = [F(x,\theta) (1 - F(x,\theta))]^{-1}. In practice, the statistic is calculated as:

A2=m1mi=1m{(2i1)ln[F(x(i),θ)]+(2m+12i)ln[1F(x(i),θ)]}A2=m1/msum(2i1)ln[F(x(i),θ)]+(2m+12i)ln[1F(x(i),θ)] A^2 = -m -\frac{1}{m} \sum_{i=1}^m \left\{ (2i-1)\ln[F(x_{(i)},\theta)] + (2m+1-2i)\ln[1 - F(x_{(i)},\theta)] \right\}A2 = -m -1/m sum{(2i-1)\ln[F(x(i),\theta)] + (2m+1-2i)\ln[1 - F(x(i),\theta)]}

The statistic A2A2, obtained in this way, may be confronted with the population of the A2A2's that one obtain if samples effectively belongs to the F(x,θ)F(x,\theta) hypothetical distribution. In the case of the test of normality, this distribution is defined (see Laio, 2004). In other cases, e.g. the Pearson Type III case, can be derived with a Monte-Carlo procedure.

Returns

gofNORMtest tests the goodness of fit of a normal (Gauss) distribution with the sample x.

gofEXPtest tests the goodness of fit of a exponential distribution with the sample x.

gofGUMBELtest tests the goodness of fit of a Gumbel (EV1) distribution with the sample x.

gofGENLOGIStest tests the goodness of fit of a Generalized Logistic distribution with the sample x.

gofGENPARtest tests the goodness of fit of a Generalized Pareto distribution with the sample x.

gofGEVtest tests the goodness of fit of a Generalized Extreme Value distribution with the sample x.

gofLOGNORMtest tests the goodness of fit of a 3 parameters Lognormal distribution with the sample x.

gofP3test tests the goodness of fit of a Pearson type III (gamma) distribution with the sample x.

They return the value A2A2 of the Anderson-Darling statistics and its non exceedence probability PP. Note that PP is the probability of obtaining the test statistic A2A2 lower than the one that was actually observed, assuming that the null hypothesis is true, i.e., PP is one minus the p-value usually employed in statistical testing (see https://en.wikipedia.org/wiki/P-value). If P(A2)P(A2) is, for example, greater than 0.90, the null hypothesis at significance level α=10%\alpha=10\% is rejected.

Note

For information on the package and the Author, and for all the references, see nsRFA.

See Also

traceWminim, roi, HOMTESTS.

Examples

x <- rnorm(30,10,1) gofNORMtest(x) x <- rand.gamma(50, 100, 15, 7) gofP3test(x, Nsim=200) x <- rand.GEV(50, 0.907, 0.169, 0.0304) gofGEVtest(x, Nsim=200) x <- rand.genlogis(50, 0.907, 0.169, 0.0304) gofGENLOGIStest(x, Nsim=200) x <- rand.genpar(50, 0.716, 0.418, 0.476) gofGENPARtest(x, Nsim=200) x <- rand.lognorm(50, 0.716, 0.418, 0.476) gofLOGNORMtest(x, Nsim=200)
  • Maintainer: Alberto Viglione
  • License: GPL (>= 2)
  • Last published: 2024-05-14

Useful links