Skip to content

Commit

Permalink
version 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Grose authored and cran-robot committed Aug 23, 2018
1 parent f44a5f2 commit eab26b5
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 6 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: IndepTest
Type: Package
Title: Nonparametric Independence Tests Based on Entropy Estimation
Version: 0.1.1
Date: 2018-04-26
Version: 0.2.0
Date: 2018-08-23
Author: Thomas B. Berrett <t.berrett@statslab.cam.ac.uk> [aut], Daniel J. Grose <dan.grose@lancaster.ac.uk> [cre,ctb], Richard J. Samworth <r.samworth@statslab.cam.ac.uk> [aut]
Maintainer: Daniel Grose <dan.grose@lancaster.ac.uk>
Description: Implementations of the weighted Kozachenko-Leonenko entropy estimator and independence tests based on this estimator, (Kozachenko and Leonenko (1987) <http://mi.mathnet.ru/eng/ppi797>). Also includes a goodness-of-fit test for a linear model which is an independence test between covariates and errors.
Expand All @@ -12,6 +12,6 @@ RdMacros: Rdpack
License: GPL
RoxygenNote: 6.0.1
NeedsCompilation: no
Packaged: 2018-04-26 14:38:28 UTC; grosedj1
Packaged: 2018-08-23 13:01:19 UTC; grosedj1
Repository: CRAN
Date/Publication: 2018-04-26 15:15:27 UTC
Date/Publication: 2018-08-23 14:04:28 UTC
6 changes: 4 additions & 2 deletions MD5
@@ -1,16 +1,18 @@
63c213f971f80ae3264cfc2d28c10918 *DESCRIPTION
eceb8237a0cd85b0e7283f81644a19ca *DESCRIPTION
6e1ea53b207b1a480a478e7ae1fb7375 *NAMESPACE
e052258d1e20dd0515655b92beff6ae4 *R/KLentropy.R
f79a8b7be97b5cb6cce2f6fba2555dc2 *R/L2OptW.R
4be7a06cf0b1adc58f3f27804cd4c2fe *R/MINTauto.R
9b15b46c315b1bedda378673514c1f6c *R/MINTav.R
c800140b90fa8701840694e4773de0b5 *R/MINTknown.R
ccb92fe1ffa10dadd53152da0ae9d51e *R/MINTperm.R
bbbf1dce9dd08b615ce389154f862db2 *R/MINTregression.R
d511eddee597e2a980107e9c7156c474 *build/partial.rdb
f33a52d2d2c4ab194eeb948514323d84 *build/partial.rdb
e36df4dbddf67301c05bd95b7e7065c3 *inst/REFERENCES.bib
d2a874d4cfce6938bb458a5ffdd34cbd *man/KLentropy.Rd
046e192333f0dfd2b4e2dc748744cc57 *man/L2OptW.Rd
958d0f855ca9581074b81f973a77129e *man/MINTauto.Rd
2cf80ae63ec0b54b3ef4325dee45fdc2 *man/MINTav.Rd
00d667df0f40baefccfda78afa304d3b *man/MINTknown.Rd
ea2ab244a336bce98c07e8be02f66819 *man/MINTperm.Rd
d9e40f831e89809ea3183ed2336e69bb *man/MINTregression.Rd
42 changes: 42 additions & 0 deletions R/MINTav.R
@@ -0,0 +1,42 @@

#' MINTav
#'
#' Performs an independence test without knowledge of either marginal distribution using permutations and averaging over a range of values of \eqn{k}.
#'
#' @param x The \eqn{n \times d_{X}} data matrix of the \eqn{X} values.
#' @param y The \eqn{n \times d_{Y}} data matrix of the \eqn{Y} values.
#' @param K The vector of values of \eqn{k} to be considered for estimation of the joint entropy \eqn{H(X,Y)}.
#' @param B The number of permutations to use for the test, set at 1000 by default.
#'
#' @return The \eqn{p}-value corresponding the independence test carried out.
#'
#' @examples
#' \donttest{
#' # Independent univariate normal data
#' x=rnorm(1000); y=rnorm(1000);
#' MINTav(x,y,K=1:200,B=100)
#' # Dependent univariate normal data
#' library(mvtnorm);
#' data=rmvnorm(1000,sigma=matrix(c(1,0.5,0.5,1),ncol=2))
#' MINTav(data[,1],data[,2],K=1:200,B=100)
#' # Dependent multivariate normal data
#' Sigma=matrix(c(1,0,0,0,0,1,0,0,0,0,1,0.5,0,0,0.5,1),ncol=4);
#' data=rmvnorm(1000,sigma=Sigma)
#' MINTav(data[,1:3],data[,4],K=1:50,B=100)
#'}
#'
#' @references \insertRef{2017arXiv171106642B}{IndepTest}
#'
#' @export
MINTav=function(x,y,K,B=1000){
data=cbind(x,y); n=dim(data)[1]
H=KLentropy(data,k=max(K),weights=F)[[1]][K]
Hp=matrix(rep(0,B*length(K)),nrow=B)
for(b in 1:B){
yp=as.matrix(y)[sample(n),]; datap=cbind(x,yp)
Hp[b,]=KLentropy(datap,k=max(K),weights=F)[[1]][K]
}
teststat=sum(H); nullstats=apply(Hp,1,sum)
p=(1+sum(nullstats<=teststat))/(B+1)
return(p)
}
Binary file modified build/partial.rdb
Binary file not shown.
42 changes: 42 additions & 0 deletions man/MINTav.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eab26b5

Please sign in to comment.