Title: | Khmaladze Martingale Transformation Goodness-of-Fit Test |
---|---|
Description: | Consider a goodness-of-fit (GOF) 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 - which was proposed by Khmaladze (1981) <DOI:10.1137/1126027> - provides asymptotic distribution free test for the GOF problem. This package contains one function: KhmaladzeTrans(). In this version, KhmaladzeTrans() provides test statistic and critical value of GOF 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 <jwboys26 at gmail.com> |
Maintainer: | Jiwoong Kim <[email protected]> |
License: | GPL-2 |
Version: | 2.2.0 |
Built: | 2024-11-25 06:45:02 UTC |
Source: | CRAN |
Obtain critical values of the Khmaladze martingale transformation test for various significane levels and sample sizes
GetCV(strDist, Modified)
GetCV(strDist, Modified)
strDist |
the name of the null distribution for the hypothesis test: Normal, Cauchy, or Logistic. Other distributions such as Gumbel, Weibull and Frechet will be available in later versions. |
Modified |
a logical value which specifies whether or not to use the modeifed version of the test: False calls the original version while True calls the modified version. |
A 10-by-6 table of critical values for various significance levles (0.1, 0.075, 0.05, 0.025, 0.01) and sample sizes (10,20,...,100).
KhmaladzeTrans()
### Critical values of the original test for a normal distribution strDist = "Normal" Modified=FALSE CritValue = GetCV(strDist, Modified) ## Critical values of the modified test for the logistic distribution strDist = "Logistic" Modified=TRUE CritValue = GetCV(strDist, Modified) ##Critical values of the modified test for the Cauchy distribution strDist = "Cauchy" Modified=TRUE CritValue = GetCV(strDist, Modified)
### Critical values of the original test for a normal distribution strDist = "Normal" Modified=FALSE CritValue = GetCV(strDist, Modified) ## Critical values of the modified test for the logistic distribution strDist = "Logistic" Modified=TRUE CritValue = GetCV(strDist, Modified) ##Critical values of the modified test for the Cauchy distribution strDist = "Cauchy" Modified=TRUE CritValue = GetCV(strDist, Modified)
Performs goodness-of-fit test through Khmaladze matringale transformation
KhmaladzeTrans(X, Modified = FALSE, strDist, bGraph = FALSE, nNum = 10)
KhmaladzeTrans(X, Modified = FALSE, strDist, bGraph = FALSE, nNum = 10)
X |
a random sample of n observations |
Modified |
a logical value which specifies whether or not to use the modeifed version of the test: False calls the original version while True calls the modified version. |
strDist |
the name of the null distribution for the hypothesis test: Normal, Cauchy, or Logistic. Other distributions such as Gumbel, Weibull and Frechet will be available in later versions. |
bGraph |
a logical value which specifies whether or not to get the graph of the objective function of the martingale transformation. |
nNum |
the number of ticks on each segmented interval when drawing the graph of the objective function. The default is 10. Bigger value will result in a smoother graph. |
A list of the following values:
When Modified is False, opt.x is the value of x where the optimum of the objective function - which is also the test statistic - occurs.
When Modified is True, opt.x is the vector of the value of x's where the infimum and supremum of occur.
When Modified is False, test.stat is the test statistic obtained through Khmaladze martingale transformation.
When Modified is True, test.stat is the vector of the supremum of , the infimum of
, and the difference of them.
a data frame which includes the information of the objective function.
a ggplot object which includes the graph of the objective function.
a list of segmented intervals over which the graph of the objective function is defined.
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 = 10 X = rnorm(n, 1,3) # Generate a random sample of n observations from N(1,3) strDist = "Normal" Modified=FALSE lResult = KhmaladzeTrans(X, Modified, strDist, bGraph=TRUE, nNum=10) KMT_OptimalX = lResult$opt.x KMT_TestStat = lResult$test.stat KMT_DM = lResult$graph.data KMT_Graph = lResult$graph #### Draw the graph of the objective function KMT_Graph KMT_Intervals = lResult$intervals KMT_Muhat = lResult$mu KMT_Sigmahat = lResult$sigma ##################### ##################### n = 10 X = rlogis(n, 1,2) # Generate a random sample of n observations from the logistic distribution strDist = "Logistic" Modified=TRUE lResult = KhmaladzeTrans(X, Modified, strDist, bGraph=TRUE, nNum=10) KMT_Optimal_Positive_X = lResult$opt.x[1] KMT_Optimal_Negative_X = lResult$opt.x[2] KMT_Postive_TestStat = lResult$test.stat[1] KMT_Negative_TestStat = lResult$test.stat[2] KMT_TestStat = lResult$test.stat[3] KMT_DM = lResult$graph.data KMT_Graph = lResult$graph #### Draw the graph of the objective function KMT_Graph KMT_Intervals = lResult$intervals KMT_Muhat = lResult$mu KMT_Sigmahat = lResult$sigma ##################### ##################### n = 10 X = rcauchy(n, 0,1) # Generate a random sample of n observations from Cauchy distribution strDist = "Cauchy" Modified=FALSE lResult = KhmaladzeTrans(X, Modified, strDist, bGraph=TRUE, nNum=10) KMT_OptimalX = lResult$opt.x KMT_TestStat = lResult$test.stat KMT_DM = lResult$graph.data KMT_Graph = lResult$graph #### Draw the graph of the objective function KMT_Graph KMT_Intervals = lResult$intervals KMT_Muhat = lResult$mu KMT_Sigmahat = lResult$sigma #####################
#################### n = 10 X = rnorm(n, 1,3) # Generate a random sample of n observations from N(1,3) strDist = "Normal" Modified=FALSE lResult = KhmaladzeTrans(X, Modified, strDist, bGraph=TRUE, nNum=10) KMT_OptimalX = lResult$opt.x KMT_TestStat = lResult$test.stat KMT_DM = lResult$graph.data KMT_Graph = lResult$graph #### Draw the graph of the objective function KMT_Graph KMT_Intervals = lResult$intervals KMT_Muhat = lResult$mu KMT_Sigmahat = lResult$sigma ##################### ##################### n = 10 X = rlogis(n, 1,2) # Generate a random sample of n observations from the logistic distribution strDist = "Logistic" Modified=TRUE lResult = KhmaladzeTrans(X, Modified, strDist, bGraph=TRUE, nNum=10) KMT_Optimal_Positive_X = lResult$opt.x[1] KMT_Optimal_Negative_X = lResult$opt.x[2] KMT_Postive_TestStat = lResult$test.stat[1] KMT_Negative_TestStat = lResult$test.stat[2] KMT_TestStat = lResult$test.stat[3] KMT_DM = lResult$graph.data KMT_Graph = lResult$graph #### Draw the graph of the objective function KMT_Graph KMT_Intervals = lResult$intervals KMT_Muhat = lResult$mu KMT_Sigmahat = lResult$sigma ##################### ##################### n = 10 X = rcauchy(n, 0,1) # Generate a random sample of n observations from Cauchy distribution strDist = "Cauchy" Modified=FALSE lResult = KhmaladzeTrans(X, Modified, strDist, bGraph=TRUE, nNum=10) KMT_OptimalX = lResult$opt.x KMT_TestStat = lResult$test.stat KMT_DM = lResult$graph.data KMT_Graph = lResult$graph #### Draw the graph of the objective function KMT_Graph KMT_Intervals = lResult$intervals KMT_Muhat = lResult$mu KMT_Sigmahat = lResult$sigma #####################
A dataset containing integration values used for fast computation and critical values for hypothesis test
data(Tables)
data(Tables)
#'@format A list containing tables of integrations and critical values for normal, logistic and Cauchy distributions:
2561-by-3 table for a normal distribution
1281-by-3 table for the logistic distribution
1281-by-1 table for the logistic distribution
2561-by-3 table for the Cauchy distribution
100-by-6 table of critical values of the original test for a normal distribution
100-by-6 table of critical values of the modified test for a normal distribution
100-by-6 table of critical values of the original test for the logistic distribution
100-by-6 table of critical values of the modified test for the logistic distribution
100-by-6 table of critical values of the original test for the Cauchy distribution
100-by-6 table of critical values of the modified test for the Cauchy distribution