Code Monkey home page Code Monkey logo

causality's Introduction

causality

causality is still in early development, but there are a few useful things you do with the R package. You can agregrate graphs into order to access the stabiliity of algorithms, you can convert dags to patterns and patterns to dags, and you can employ causality's (BETA) implementation of greedy equivalence search (GES) to learn bayesian networks. ges current contains support for continuous BIC, discrete BIC, and BDeu scoring.

Installation

You can install casuality via the R package devtools

# install.packages("devtools")
devtools::install_github("tzimiskes/causality", build_opts = c())

You will need a C compiler that supports C99. This can be accomplished by installing Rtools on Windows and Xcode on MacOS.

If you have any feedback ( suggestions, bugs, feature requests), let me know so I can address it!

causality's People

Contributors

tzimiskes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

causality's Issues

meek bug

say the dag

X1 --> X2
X2 --> X3
X3 --> X4

when converted into the pdag
X1 --> X2
X2 --> X3
X3 --- X4

meek is fine

but
X1 --> X2
X2 --> X3
X4 --- X3

makes meek not halt

heap testing

I also need to figure out how to make deletions fast.

as.pattern can cause grief

When an object is converted into a cgraph, it must be cast first to a dag before being cast to a pattern. Should fix

Unrecognized edge type o--.

Running a bootstrapped tetradrunner FCI with a high enough alpha value (0.1) will sometimes throw the error:

Error in cgraph(graph$nodes, new_edges) : Unrecognized edge type o--.

Printing the graph's edge lists doesn't show that edge type in the list, and running it again will sometimes not throw the error and proceed normally.

is.cylic is bugged

currently, is.cylic only really works when the edge set of the input is directed.

doing meek rules may help with this situation, but I suspect the topological sort algorithm may need need a slight rethink/

test case:
the edge list:
X1 X2 ---
X2 X3 ---
X3 X1 ---

should (need to check) be incorrectly labeled as "cyclic"

MacOS installation instructions

(from @tk27182)
I was able to install causality on MacOS Mojave 10.14.5 by doing the following:

Opening up a terminal, then running the command open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg. If you've already installed that, you can ignore this step. This package wasn't automatically installed for me.

Since causality uses gcc to compile, you can (re)install gcc by typing brew install gcc in the terminal and make sure it's added to the /usr/local/bin/ path. You can check by using the which gcc command. For me, brew installed gcc-9 and that's the version I used.

Next edit the R Makevars file, which on Mac is found in the /Library/Frameworks/R.framework/Resources/etc folder and is called Makeconf. I used vim Makeconf.

Open the file and the variables CC, CXX, and CXX11. They should be

CC=/usr/local/bin/gcc-9
CXX=/usr/local/bin/g++-9 -std=gnu++11
CXX11=/usr/local/bin/g++-9

or whatever version of gcc you're using.

From there you can open up an R console and install the package like you would install any package from Github. I did library(devtools); install_github('causality')

as.cgraph breaks if graph has no edges

Very rarely, bootstrapping a real data set may result in a data set whose correlations are weak enough that no edges are identified. When this happens, Tetrad outputs a graph object that contains nodes but whose list of edges is empty. When this happens as.cgraph throws an error, exiting whatever loop it's inside of. Ideally, as.cgraph should just convert this to a cgraph with the same nodes but no edges.

Scoring

need a function that returns the actual Delta BIC for adding an edge, that just takes in the dataset ,and an edge.

delta_score := BIC( y+z,x) - BIC(y,x)

meek3 bug

  1. X2 --- X3
  2. X2 --- X4
  3. X2 --- X5
  4. X3 --> X5
  5. X4 --> X5

is not oriented according to meek3.

unclear on whether or not this is related to possible unoriented edge problemos

a wierd thing

according to meek rules, this pdag, A

1 --> 2
2 --> 3
3 --> 4
4 --- 1

should be oriented to the
1 --> 2
2 --> 3
3 --> 4
4 --> 1

which is not a pdag.

I'm guessing this has to do with the fact that changing the below DAG to A destroys an unshielded collider,
1 --> 2
2 --> 3
3 --> 4
1 --> 4

My question is: why isn't A a PDAG?

This paper (referenced in Pearl) contains a definition
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.74.5538&rep=rep1&type=pdf

various helper functions

summary.causality.graph -- give global stats on connectedness etc
equivalent -- test whether or not two causality.graphs are observationally equivalent.
identical (probably different name needed). test if two graphs are EXACTLY THE SAME.

possible dag to pattern bug

X1 --> X2
X2 --> X3
X3 --- X4

results in

X1 --> X2
X2 --> X3
X3 --> X4

X1 --> X2
X2 --> X3
X4 --- X3

results in

X1 --> X2
X2 --> X3
X4 --> X3

is this good?

solution to is maximally orient pdag? aka meek?
but, #3 is present so this can't be tested

meek 4 bug

Graph Nodes:
X2,X3,X4,X5

Graph Edges:

  1. X2 --- X3
  2. X2 --- X4
  3. X2 --- X5
  4. X5 --> X3
  5. X4 --> X5

doesn't orient X2 --> X3

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.