GithubHelp home page GithubHelp logo

rjbgoudie / structmcmc Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 0.0 1.07 MB

A set of tools for performing structural inference for Bayesian Networks using MCMC in R

License: Other

R 99.26% C 0.74%

structmcmc's People

Contributors

rjbgoudie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

structmcmc's Issues

Error when calling posterior

I'm trying to get this script working. After executing line 14, the following error is thrown.

Error in if (nrow(arcs) == 0) return(TRUE) : argument is of length zero

minimal example

install.packages("devtools")
library(devtools)

install_github("rjbgoudie/parental")
install_github("rjbgoudie/structmcmc")
library(structmcmc)

# Setup data frame
x1 <- factor(c("a", "a", "g", "c", "c", "a", "g", "a", "a"))
x2 <- factor(c(2, 2, 4, 3, 1, 4, 4, 4, 1))
x3 <- factor(c(FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE))
x <- data.frame(x1 = x1, x2 = x2, x3 = x3)

# Draw samples from the posterior using MC^3.
set.seed(1234)
initial <- bn(c(), c(), c())
priorgraph <- bn(c(), c(1), c(2))
prior <- priorGraph(priorgraph, 0.5)
mcmc <- posterior(data = x, method = "mc3", prior = prior,
                  nSamples = 10000, nBurnin = 1000, initial = initial)

environment

platform x86_64-apple-darwin15.6.0
arch x86_64
os darwin15.6.0
system x86_64, darwin15.6.0
status
major 3
minor 4.0
year 2017
month 04
day 21
svn rev 72570
language R
version.string R version 3.4.0 (2017-04-21)

gibbs

I get the popup window "R session aborted. R encountered a fatal error. The session was terminated." when I try to run the examples from the README file with the argument method = "gibbs". Do I need to change the other arguments when methods = "gibbs"?

I am running R version 3.5.0

Demo script error

Hi, when executing the demo script for discrete data from the Readme, I get the following error

> mcmc <- posterior(data = x, method = "mc3", prior = prior,
+                   nSamples = 10000, nBurnin = 1000, initial = initial)
Error in logScoreOfflineFUN(x = currentNetwork[[1]], logScoreParameters = logScoreParameters,  : 
  class(logScoreParameters$data) == "matrix" are not all TRUE
Called from: logScoreOfflineFUN(x = currentNetwork[[1]], logScoreParameters = logScoreParameters,  cache = cache)

I get this error after running:

x1 <- factor(c("a", "a", "g", "c", "c", "a", "g", "a", "a"))
x2 <- factor(c(2, 2, 4, 3, 1, 4, 4, 4, 1))
x3 <- factor(c(FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE))
x <- data.frame(x1 = x1, x2 = x2, x3 = x3)
set.seed(1234)
initial <- bn(c(), c(), c())
priorgraph <- bn(c(), c(1), c(2))
prior <- priorGraph(priorgraph, 0.5)
mcmc <- posterior(data = x, method = "mc3", prior = prior,
                  nSamples = 10000, nBurnin = 1000, initial = initial)

Any ideas how to fix this? I am just exploring the package and would like to debug a walkthrough of a few examples to see how it works.

Thanks!

browser() called from priorGraph

The browser() function is called inside the priorGraph function, meaning that Rstudio breaks and won't continue until enter is pressed. As this function is called many times I've not been able to run the example code given here

Section of code is below:

  difference <- setdiff(x, graph[[i]])
  difference <- length(difference)
  browser()
  exp(-lambda * difference)

RStudio Version 1.1.419

Installation dependencies

Just FYI, I also had to install the following packages, in addition to parental:

install.packages(c("bit", "fastmatch", "testthat"))

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.