Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f44a5f2
commit eab26b5
Showing
5 changed files
with
92 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.