| Title: | Khmaladze Martingale Transformation Goodness-of-Fit Test |
|---|---|
| Description: | Consider a goodness-of-fit problem of testing whether a random sample comes from one sample location-scale model where location and scale parameters are unknown. It is well known that Khmaladze-martingale-transformation method proposed by Khmaladze (1981) <doi:10.1137/1126027> provides asymptotic distribution free test. This package provides test statistic and critical value of the test for normal, Cauchy, and logistic distributions. This package used the main algorithm proposed by Kim (2020) <doi:10.1007/s00180-020-00971-7> and tests for other distributions will be available at the later version. |
| Authors: | Jiwoong Kim [aut, cre] |
| Maintainer: | Jiwoong Kim <[email protected]> |
| License: | GPL-2 |
| Version: | 1.0.0 |
| Built: | 2026-05-25 17:12:07 UTC |
| Source: | https://github.com/cran/KMT |
Run the Anderson-Darling (AD) test.
AD(Z, Distr)AD(Z, Distr)
Z |
a normalized random sample of n observations. |
Distr |
a null distribution of the GOF test. It should be one of "Normal", "Logistic", "Cauchy", or "Gumbel |
A test statistic of the AD test.
n=10 mu=2 sigma=1 X = rnorm(n, mu, sigma) muhat = mean(X) sighat = sd(X) Z = (X-muhat)/sighat null_distr="Normal" AD_teststat = AD(Z, null_distr) AD_teststatn=10 mu=2 sigma=1 X = rnorm(n, mu, sigma) muhat = mean(X) sighat = sd(X) Z = (X-muhat)/sighat null_distr="Normal" AD_teststat = AD(Z, null_distr) AD_teststat
Get a d-dimension Brownian motion B(t) and its graph
BM(x = 0, t = 1, n = 10, d = 1)BM(x = 0, t = 1, n = 10, d = 1)
x |
a starting point of the Brownian motion, B(0). |
t |
end of time, that is, |
n |
the last index of the time, that is, |
d |
a dimension of the Brownian motion: 1 or 2. |
A list of
a vector of the Brownian motion ()
a vector of the Brownian motion ()
#### Generate an 2-dimensional Brownian motion and its graph x0=c(0,0) lst = BM(x=x0, t=1, n=10, d=2)#### Generate an 2-dimensional Brownian motion and its graph x0=c(0,0) lst = BM(x=x0, t=1, n=10, d=2)
Run the Cramer-von Mises (CvM) and Watson tests.
CvM(Z, Distr)CvM(Z, Distr)
Z |
a normalized random sample of n observations. |
Distr |
a null distribution of the GOF test. It should be one of "Normal", "Logistic", "Cauchy", or "Gumbel |
A vector of the CvM and Watson test statistics.
n=10 mu=2 sigma=1 X = rnorm(n, mu, sigma) muhat = mean(X) sighat = sd(X) Z = (X-muhat)/sighat null_distr="Normal" Vec = CvM(Z, null_distr) CvM_teststat = Vec[1] Watson_teststat = Vec[2] CvM_teststat;Watson_teststatn=10 mu=2 sigma=1 X = rnorm(n, mu, sigma) muhat = mean(X) sighat = sd(X) Z = (X-muhat)/sighat null_distr="Normal" Vec = CvM(Z, null_distr) CvM_teststat = Vec[1] Watson_teststat = Vec[2] CvM_teststat;Watson_teststat
Obtain all details regarding the null distribution such as c1(x).
Distr_Information(x, strDistr)Distr_Information(x, strDistr)
x |
a real number |
strDistr |
a null distribution: "Normal", "Logistic", "Cauchy" |
a list of the following values:
f(x)
F(x)
r(x). Logistic only
R(x). Logistic only
data(Normal_table) x = 1.2 lst= Distr_Information(x, "Normal") phix = lst$phix phix c0 = lst$c0 c0data(Normal_table) x = 1.2 lst= Distr_Information(x, "Normal") phix = lst$phix phix c0 = lst$c0 c0
Draw the graph of ||.
DrawUnz( X, strDistr, type = "l", lty = 1, lwd = 1.5, col = "red", xlim = c(NA, NA), ylim = c(NA, NA), margin_x = 0.1, margin_y = 0.5, dGap = 0.01, b_abline = FALSE )DrawUnz( X, strDistr, type = "l", lty = 1, lwd = 1.5, col = "red", xlim = c(NA, NA), ylim = c(NA, NA), margin_x = 0.1, margin_y = 0.5, dGap = 0.01, b_abline = FALSE )
X |
a random sample of n observations |
strDistr |
a null distribution for the hypothesis test: Normal, Cauchy, Logistic, or Gumbel. |
type |
a type of plot. A default is a line. |
lty |
a line type. The default value is a solid. |
lwd |
a line width. |
col |
a line color. |
xlim |
a limit for the x-axis. |
ylim |
a limit for the y-axis. |
margin_x |
a margin of graph in the x-axis. |
margin_y |
a margin of graph in the y-axis. |
dGap |
a length of subintervals of the x-axis. |
b_abline |
a logical value for drawing vertical lines where the discontinuities of the graph happen. |
A list of the following values:
plot of the graph of the supremand of the KMT test statistic, that is, ||
[1] Khmaladze, E.V., Koul, H.L. (2004). Martingale transforms goodness-of-fit tests in regression models. Ann. Statist., 32. 995-1034
[2] E.V. Khmaladze, H.L. Koul (2009). Goodness-of-fit problem for errors in nonparametric regression: distribution free approach. Ann. Statist., 37(6A) 3165-3185.
[3] Kim, Jiwoong (2020). Implementation of a goodness-of-fit test through Khmaladze martingale transformation. Comp. Stat., 35(4): 1993-2017
#################### n=20 mu0=2 sigma0=1 X = rnorm(n, mu0, sigma0) strDistr="Normal" DrawUnz(X, strDistr, type="l", lty=1, lwd=1.5, col="red", xlim = c(-5,5), ylim = c(NA,NA), margin_x=0.1, margin_y=0.5, dGap=0.01, b_abline=TRUE)#################### n=20 mu0=2 sigma0=1 X = rnorm(n, mu0, sigma0) strDistr="Normal" DrawUnz(X, strDistr, type="l", lty=1, lwd=1.5, col="red", xlim = c(-5,5), ylim = c(NA,NA), margin_x=0.1, margin_y=0.5, dGap=0.01, b_abline=TRUE)
Run the Kolmogorov-Smirnov (KS) and Kuiper tests.
KS(Z, Distr)KS(Z, Distr)
Z |
a normalized random sample of n observations. |
Distr |
a null distribution of the GOF test. It should be one of "Normal", "Logistic", "Cauchy", or "Gumbel |
A vector of the KS and Kuiper test statistics.
n=10 mu=2 sigma=1 X = rnorm(n, mu, sigma) muhat = mean(X) sighat = sd(X) Z = (X-muhat)/sighat null_distr="Normal" Vec = KS(Z, null_distr) KS_teststat = Vec[1] Kuiper_teststat = Vec[2] KS_teststat;Kuiper_teststatn=10 mu=2 sigma=1 X = rnorm(n, mu, sigma) muhat = mean(X) sighat = sd(X) Z = (X-muhat)/sighat null_distr="Normal" Vec = KS(Z, null_distr) KS_teststat = Vec[1] Kuiper_teststat = Vec[2] KS_teststat;Kuiper_teststat
Performs goodness-of-fit test through Khmaladze matringale transformation
Run_KMT( X, strDistr = "Normal", bEstimation = FALSE, bFast_Estimation = FALSE, bParallel = FALSE, nThreads = 16 )Run_KMT( X, strDistr = "Normal", bEstimation = FALSE, bFast_Estimation = FALSE, bParallel = FALSE, nThreads = 16 )
X |
a random sample of n observations |
strDistr |
a null distribution for the hypothesis test: Normal, Cauchy, Logistic, or Gumbel. |
bEstimation |
a logical value which specifies whether or not to estimate parameters. The default value is TRUE. For FALSE, ( |
bFast_Estimation |
a logical value which specifies whether or not to use the maximum likelihood estimator ( |
bParallel |
a logical value which specifies whether or not to use the parallel computing. The default value is FALSE. |
nThreads |
the number of threads when bParallel is TRUE. The default value is 16. |
A list of the following values:
opt.x is the value of x where the optimum of the objective function - which is also the test statistic - occurs.
test.stat is the test statistic obtained through Khmaladze martingale transformation.
the point estimate for the location parameter mu
the point estimate for the scale parameter sigma
[1] Khmaladze, E.V., Koul, H.L. (2004). Martingale transforms goodness-of-fit tests in regression models. Ann. Statist., 32. 995-1034
[2] E.V. Khmaladze, H.L. Koul (2009). Goodness-of-fit problem for errors in nonparametric regression: distribution free approach. Ann. Statist., 37(6A) 3165-3185.
[3] Kim, Jiwoong (2020). Implementation of a goodness-of-fit test through Khmaladze martingale transformation. Comp. Stat., 35(4): 1993-2017
#################### n=20 mu0=2; sigma0=1 X = rnorm(n, mu0, sigma0) Run_KMT(X, strDistr="Normal")#################### n=20 mu0=2; sigma0=1 X = rnorm(n, mu0, sigma0) Run_KMT(X, strDistr="Normal")