gnfit {gnFit} | R Documentation |
Goodness of Fit Test for Continuous Distribution Functions
Description
Computes the test statistic and p-value of the Cramer-von Mises and Anderson-Darling test for some continuous distribution functions proposed by Chen and Balakrishnan (1995). In addition to our classic distribution functions here, we calculate the Goodness of Fit (GoF) test to dataset which follows the extreme value distribution function, without remembering the formula of distribution/density functions.
Usage
gnfit(dat, dist, df = NULL, pr = NULL, threshold = NULL)
Arguments
dat |
A numeric vector of data values. |
dist |
A named distribution function in R, such as "norm", "t", "laplace", "logis", "gev", "gum", "gpd". |
df |
Degrees of freedom (> 2) for Student-t's distribution. This value is set to NULL by default. |
pr |
An object returned by maximum likelihood estimation of gev.fit, gum.fit or gpd.fit. It is also numeric vector giving the maximum likelihood estimation for the nonstationary model with location, scale and shape parameters for "gev" (generalized extreme value distribution), location and scale parameters in gumbel distribution or scale and shape parameters in case of "gpd" (generalized pareto distribution), resp. |
threshold |
The threshold is a single number. It is allocated by "gpd" with shape and scale parameters. |
Details
To test is a random sample from a continuous distribution with cumulative distribution function
, where the form of
is known but
is unknown. We first esitmate
by
(for eg. maximum likelihood estimation method). Next, we compute
, where the
's are in ascending order.
The Cramer-von Mises test statistic is
and
where, ,
, and
is the standard normal CDF and
its inverse.
Modify and
into
and
The p-value is computed from the modified statistic and
according to Table 4.9 in Stephens (1986).
Value
The output is an object of the class "htest" for the Cramer-von Mises and Anderson-Darling statistics corresponding to p-values.
References
Stephens (1986, ISBN:0824774876)
Chen and Balakrishnan (1995) <http://asq.org/qic/display-item/index.html?item=11407>
Marsaglia (2004) <doi:10.18637/jss.v009.i02>
See Also
The package of nortest for performing the Anderson-Darling test for normality. ADGofTest implementation of the Anderson-Darling goodness of fit test based on Marsaglia's (2004).
Examples
library(rmutil)
r <- rlaplace(1000, m = 1, s = 2)
gnfit(r, "laplace")
library(ismev)
pr <- c(-0.5, 1, 0.2)
r <- gevq(pr, runif(1000, 0, 1))
model <- gev.fit(r)$mle
gnfit(r, "gev", pr = model)
library(ismev)
r <- gum.q(runif(1000, 0, 1), -0.5, 1)
n <- length(r)
time <- matrix(1:n, ncol=1)
model <- gum.fit(r, ydat=time, mul=1)$mle
mle<-dim(2)
mle[1] <- model[1] + model[2] * (n+1)
mle[2] <- model[3]
gnfit(r, "gum", pr = mle)