The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
This package provides a goodness-of-fit test of whether a given i.i.d. sample {xi} is drawn from a given distribution. It works for any distribution once its score function (the derivative of log-density) ∇xlog p(x) can be provided. This method is based on ``A Kernelized Stein Discrepancy for Goodness-of-fit Tests and Model Evaluation’’ by Liu, Lee, and Jordan, available at <arXiv:1602.03253>.
The main function of this package is KSD, which estimates Kernelized Stein Discrepancy. Parameters include :
Other methods are also in this package, including various demos and examples.
KSD requires user to provide a score function to be used for computation. For example usage and exploration, a gmm class is provided in the package, which allow test KSD using gaussian mixture model.
Consider the following examples :
# Pass in a dataset generated by Gaussian distribution,
# pass in computed score rather than score function
library(KSD)
library(pryr)
<- gmm()
model <- rgmm(model, n=100)
X = scorefunctiongmm(model=model, X=X)
score_function <- KSD(X,score_function=score_function)
result $p
result#> [1] 0.899
# Pass in a dataset generated by Gaussian distribution,
# use pryr package to pass in score function
library(KSD)
library(pryr)
<- gmm()
model <- rgmm(model, n=100)
X = pryr::partial(scorefunctiongmm, model=model)
score_function <- KSD(X,score_function=score_function)
result $p
result#> [1] 0.899
Premade demos include the following (Note that these demos require additional libraries)
demo_iris()
demo_normal_performance()
demo_simple_gaussian()
demo_simple_gamma()
demo_gmm()
demo_gmm_multi()
A sample run of demo_iris :
library(KSD)
library(datasets)
library(ggplot2)
library(gridExtra)
library(mclust)
library(pryr)
demo_iris()
#> [1] "Fitting GMM with 3 clusters"
#> fitting ...
#> | | | 0% | |======== | 7% | |=============== | 13% | |======================= | 20% | |=============================== | 27% | |====================================== | 33% | |============================================== | 40% | |====================================================== | 47% | |============================================================= | 53% | |===================================================================== | 60% | |============================================================================= | 67% | |==================================================================================== | 73% | |============================================================================================ | 80% | |==================================================================================================== | 87% | |=========================================================================================================== | 93% | |===================================================================================================================| 100%
#> fitting ...
#> | | | 0% | |======== | 7% | |=============== | 13% | |======================= | 20% | |=============================== | 27% | |====================================== | 33% | |============================================== | 40% | |====================================================== | 47% | |============================================================= | 53% | |===================================================================== | 60% | |============================================================================= | 67% | |==================================================================================== | 73% | |============================================================================================ | 80% | |==================================================================================================== | 87% | |=========================================================================================================== | 93% | |===================================================================================================================| 100%
#> fitting ...
#> | | | 0% | |======== | 7% | |=============== | 13% | |======================= | 20% | |=============================== | 27% | |====================================== | 33% | |============================================== | 40% | |====================================================== | 47% | |============================================================= | 53% | |===================================================================== | 60% | |============================================================================= | 67% | |==================================================================================== | 73% | |============================================================================================ | 80% | |==================================================================================================== | 87% | |=========================================================================================================== | 93% | |===================================================================================================================| 100%
#> fitting ...
#> | | | 0% | |======== | 7% | |=============== | 13% | |======================= | 20% | |=============================== | 27% | |====================================== | 33% | |============================================== | 40% | |====================================================== | 47% | |============================================================= | 53% | |===================================================================== | 60% | |============================================================================= | 67% | |==================================================================================== | 73% | |============================================================================================ | 80% | |==================================================================================================== | 87% | |=========================================================================================================== | 93% | |===================================================================================================================| 100%
#> fitting ...
#> | | | 0% | |======== | 7% | |=============== | 13% | |======================= | 20% | |=============================== | 27% | |====================================== | 33% | |============================================== | 40% | |====================================================== | 47% | |============================================================= | 53% | |===================================================================== | 60% | |============================================================================= | 67% | |==================================================================================== | 73% | |============================================================================================ | 80% | |==================================================================================================== | 87% | |=========================================================================================================== | 93% | |===================================================================================================================| 100%
#> [1] "Average p value : 0.218"
Currently, the code is available at https://github.com/MinHyung-Kang/KSD/ More download options will be available after CRAN submission.
Minhyung(dot)Daniel(dot)Kang(at)gmail(dot)com
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.