Giter Club home page Giter Club logo

pttests's Introduction

Polya Tree independence tests (PTTests)

This R package accompanies the paper

'A Bayesian Nonparametric Conditional Two-sample Test with an Application to Local Causal Discovery' (Boeken and Mooij, 2021)

and the master thesis

'Conditional Independence Testing in Causal Discovery' (Boeken, 2020).

Installation

To install this R package, make sure you have R (version >= 3.5.0) and RStudio installed. Open PTTests.Rproj in RStudio and execute:

install.packages("devtools")
devtools::install_local("./")
library(PTTests)

Contents

This package implements the following Pólya tree-based hypothesis tests:

  • pt_d_sample_ci_test (Boeken and Mooij, 2021; Boeken, 2020)
  • pt_d_sample_test (Holmes et al., 2015)
  • pt_continuous_ci_test (Teymur and Filippi, 2019)
  • pt_continuous_independence_test (Filippi and Holmes, 2017).

These tests may be called through the wrapper method pt_ci_test.

The experiments from the paper can be reproduced by running the experiments.R script, or alternatively by executing the following functions:

  • experiment_lcd_compare_tests_roc(simulation = 'paper')
  • experiment_lcd_roc_curves(simulation = 'paper')
  • experiment_sachs_lcd()

The experiments from the master thesis (Boeken, 2020) can be reproduced by executing the method experiment_thesis().

The output is saved to the /output folder. You may provide a custom output folder using the path argument when invoking one of the above methods.

Graphviz dependency

In the experiment_sachs_lcd() method, we make use of graphviz to generate .pdf files from .dot files. To ensure this works correctly, make sure you have graphviz installed, and have the cli command dot working.

Python dependency

In the experiment_lcd_compare_tests_roc() method we don't invoke the CCIT test by default. If you wish to obtain results for this test, some steps have to be taken. We run the CCIT test using the provided python package, and approach this python package in R using reticulate. For this to work, it is required to have Python 3 installed, and have the cli command python working. To install the CCIT package, run pip install CCIT == 0.4 or sudo -H pip install CCIT == 0.4.

Then uncomment from experiment_lcd_compare_tests:

  ccit = get_results(data, .ccit_wrapper),

and reinstall the package by running from an R console:

devtools::install_local("./", force = TRUE)

References

Boeken, P. A. (2020). Conditional independence testing in causal inference. University of Amsterdam, Master Thesis.

Boeken, P. A. and Mooij, J. M. (2021). A Bayesian nonparametric conditional two-sample test with an application to Local Causal Discovery. Proceedings of the Thirty-Seventh Conference on Uncertainty in Artificial Intelligence, in Proceedings of Machine Learning Research 161:1565-1575. Available from https://proceedings.mlr.press/v161/boeken21a.html.

Filippi, S. and Holmes, C. C. (2017). A Bayesian nonparametric approach to testing for dependence between random variables. Bayesian Analysis, 12(4):919–938.

Holmes, C. C., Caron, F., Griffin, J. E., and Stephens, D. A. (2015). Two-sample Bayesian nonparametric hypothesis testing. Bayesian Analysis, 10(2):297–320.

Teymur, O. and Filippi, S. (2019). A Bayesian nonparametric test for conditional independence. Foundations of Data Science, 2(2):155–172.

pttests's People

Contributors

philipboeken avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

vcabeli

pttests's Issues

Can not locate 'PTTests.Rproj'

Hi,

This is a very efficient method, so I want to try it on my own data. I was trying to install the package follow the README, but I couldn't find 'PTTests.Rproj'. I searched every folder, there is no Rproj file. Would you help? Thank you.

Error in `cor_test_bayesian` due to bug in invgamma library

Hi, there is currently a bug in the implementation of cor_test_bayesian.
On line 38 we have invgamma::dinvgamma(g, shape = .5, scale = n / 2)).
Unfortunately, due to a bug in invgamma dkahle/invgamma#1, this actually computes the inverse gamma density for rate n/2, instead of scale.

This resulted in a situation where cor_test_bayesian always resulted in a Bayes factor of 1, even for large amounts of completely uncorrelated data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.