copent

R package for estimating copula entropy (mutual information), transfer entropy (conditional mutual information), and the statistic for multivariate normality test and two-sample test

https://github.com/majianthu/copent

Science Score: 36.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.2%) to scientific vocabulary

Keywords

causal-discovery causality change-point-detection conditional-independence-test conditional-mutual-information copula copula-entropy correlation entropy granger-causality information-theory mutual-information mutualinf normality-test r transfer-entropy two-sample-test variable-selection
Last synced: 6 months ago · JSON representation

Repository

R package for estimating copula entropy (mutual information), transfer entropy (conditional mutual information), and the statistic for multivariate normality test and two-sample test

Basic Info
Statistics
  • Stars: 42
  • Watchers: 2
  • Forks: 10
  • Open Issues: 0
  • Releases: 0
Topics
causal-discovery causality change-point-detection conditional-independence-test conditional-mutual-information copula copula-entropy correlation entropy granger-causality information-theory mutual-information mutualinf normality-test r transfer-entropy two-sample-test variable-selection
Created almost 6 years ago · Last pushed over 1 year ago
Metadata Files
Readme

README.md

CRAN

copent

R package for Estimating Copula Entropy and Transfer Entropy

Introduction

This package implements the methods for estimating copula entropy, transfer entropy, and the statistics for multivariate normality test and two-sample test based on copula entropy.

Copula Entropy is a mathematical concept for statistical independence measurement [1]. In bivariate case, Copula Entropy is proved to be equivalent to Mutual Information. Different from Pearson Correlation Coefficient, Copula Entropy is defined for non-linear, high-order and multivariate cases, which makes it universally applicable.

It enjoys wide applications, including but not limited to: * Structure Learning; * Variable Selection [2]; * Causal Discovery (Estimating Transfer Entropy) [3]; * Multivariate Normality Test [5]. * Two-Sample Test [6]. * Change Point Detection [7]

The nonparametric methods for estimating copula entropy and transfer entropy are implemented. The method for estimating copula entropy composes of two simple steps: estimating empirical copula by rank statistic and estimating copula entropy with kth-Nearest-Neighbour method.

The method for estimating transfer entropy composes of two steps: estimating three copula entropy terms and then calculate transfer entropy from the estimated copula entropy terms.

The method for estimating the statistic for testing multivariate normality composes of two steps: estimating the copula entropy of random variables and calculating the copula entropy of the Gaussian variables with same covariance with the estimated covariance. The statistic is then derived as the difference between these two copula entropies.

The method for estimating the statistic for two-sample test is also implemented. The test statistic is defined as the difference between the copula entropies between the null hypothesis and the alternative of two-sample test. The method for multivariate change point detection with copula entropy based two-sample test is also implemented.

An preprint paper on the copent package is available on arXiv. For more information, please refer to [1-3]. For more information in Chinese, please follow this link.

Functions

  • copent -- estimating copula entropy;
  • constructempiricalcopula -- the first step of the algorithm, which estimates empirical copula for data by rank statistics;
  • entknn -- the second step of the algorithm, which estimates copula entropy from empirical copula with kNN method.
  • ci -- conditional independence testing based on copula entropy
  • transent -- estimating transfer entropy via copula entropy
  • mvnt -- estimating the statistic for testing multivariate normality based on copula entropy
  • tst -- estimating the statistic for non-parametric multivariate two-sample test based on copula entropy
  • cpd -- single change point detection with copula entropy based two-sample test
  • mcpd -- multiple change point detection with copula entropy based two-sample test

Usage

Install the package

The package can be installed from CRAN directly: install.packages("copent") The package can be installed from Github with install_github function in the devtools package: devtools::install_github("majianthu/copent")

Code Examples
Example 1. Estimating copula entropy of bivariate Gaussian rvs.

```r

Example for library "copent"

library(mnormt) library(copent) rho = 0.5 sigma = matrix(c(1,rho,rho,1),2,2) x = rmnorm(500,c(0,0),sigma) ce1 = copent(x) ```

Example 2. Estimating transfer entropy.

The data used in this example is the UCI Beijing PM2.5 data which include the PM2.5 and meterological factors obeservations in Beijing. The aim of the example is to infere the casuality from meterological factor (pressure) to PM2.5 from this obeservational data by estimating transfer entropy. Here transfer entropy is estimated via three copula entropy terms. More information on this example, please refer to [4]. r library(copent) dir = "https://archive.ics.uci.edu/ml/machine-learning-databases/00381/" data = read.csv(paste(dir,"PRSA_data_2010.1.1-2014.12.31.csv",sep="")) pm25 = data[2200:2700, 6] pressure = data[2200:2700, 9] te1 = 0 for (lag in 1:24){ te1[lag] = transent(pm25,pressure,lag) } x11() plot(te1, xlab = "lag (hours)", ylab = "Transfer Entropy", main = "Pressure") lines(te1)

Example 3. Multivariate Normality Test.

r library(copent) library(mnormt) rho <- 0.5 sigma <- matrix(c(1,rho,rho,1),2,2) x <- rmnorm(1000,c(0,0),sigma) mvnt(x)

Example 4. Two-Sample Test.

r library(copent) library(mnormt) rho <- 0.5 sigma <- matrix(c(1,rho,rho,1),2,2) s0 <- rmnorm(600,c(0,0),sigma) s1 <- rmnorm(500,c(5,5),sigma) tst(s0,s1)

Example 5. Change Point Detection.

r library(copent) library(mnormt) rho1 = 0.2; n1 = 20 x1 = rmnorm(n1,c(0,0),matrix(c(1,rho1,rho1,1),2,2)) x2 = rmnorm(n1,c(10,10),matrix(c(1,rho1,rho1,1),2,2)) x3 = rmnorm(n1,c(5,5),matrix(c(1,rho1,rho1,1),2,2)) x4 = rmnorm(n1,c(1,0),matrix(c(1,rho1,rho1,1),2,2)) x = rbind(x1,x2,x3,x4) mcpd(x,n=15)

References

  1. Ma, Jian, Sun Zengqi. Mutual information is copula entropy. Tsinghua Science & Technology, 2011, 16(1): 51-54. See also arXiv preprint, arXiv:0808.0845, 2008.
  2. Ma, Jian. Variable Selection with Copula Entropy. arXiv preprint arXiv:1910.12389, 2019.
  3. Ma, Jian. Estimating Transfer Entropy via Copula Entropy. arXiv preprint arXiv:1910.04375, 2019.
  4. Ma, Jian. copent: Estimating Copula Entropy in R. arXiv preprint arXiv:2005.14025, 2020.
  5. Ma, Jian. Multivariate Normality Test with Copula Entropy. arXiv preprint arXiv:2206.05956, 2022.
  6. Ma, Jian. Two-Sample Test with Copula Entropy. arXiv preprint arXiv:2307.07247, 2023.
  7. Ma, Jian. Change Point Detection with Copula Entropy based Two-Sample Test. arXiv preprint arXiv:2403.07892, 2024. #### License GPL (>=2)

Owner

  • Name: MA Jian
  • Login: majianthu
  • Kind: user
  • Location: Beijing

PhD, Tsinghua University

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 50
  • Total Committers: 2
  • Avg Commits per committer: 25.0
  • Development Distribution Score (DDS): 0.38
Top Committers
Name Email Commits
MA Jian 6****u@u****m 31
MA Jian m****9@q****m 19
Committer Domains (Top 20 + Academic)
qq.com: 1

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 386 last-month
  • Total docker downloads: 21,613
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 5
  • Total maintainers: 1
cran.r-project.org: copent

Estimating Copula Entropy and Transfer Entropy

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 386 Last month
  • Docker Downloads: 21,613
Rankings
Forks count: 7.7%
Stargazers count: 8.9%
Average: 24.5%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Downloads: 40.6%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 2.7.0 depends
  • stats * imports
  • mnormt * suggests