Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when calling posterior #2

Closed
sempwn opened this issue Aug 13, 2018 · 2 comments
Closed

Error when calling posterior #2

sempwn opened this issue Aug 13, 2018 · 2 comments

Comments

@sempwn
Copy link

sempwn commented Aug 13, 2018

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)

@rjbgoudie
Copy link
Owner

This works for me, except install_github() didn't seem to install all required dependencies. Would you be able to try the following?

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

install.packages(c("bit", "fastmatch", "gRain", "zoo"))
install_github("rjbgoudie/parental", dependencies  = TRUE)
install_github("rjbgoudie/structmcmc", dependencies  = TRUE)
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)

@sempwn
Copy link
Author

sempwn commented Aug 13, 2018

@rjbgoudie Thanks so much! All working now.

@sempwn sempwn closed this as completed Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants