Giter Site home page Giter Site logo

bayesvl's Introduction

BayesVL

CRAN_Status_Badge Downloads

The R package for visually learning the graphical structures of Bayesian networks, and performing Hamiltonian Markov chain Monte Carlo (MCMC) with 'Stan'.

Features:

* Creating the (starting) graphical structure of Bayesian networks
* Creating one or more random Bayesian networks learned from dataset with customized constraints
* Generating Stan code for structures of Bayesian networks for sampling and parameter learning
* Plotting the Bayesian network graphs 
* Performing Markov chain Monte Carlo (MCMC) simulations and plotting various graphs for posteriors check
* Compatibility with R 3.4 or newer versions

Here is the CHANGELOG

Resources

  • User guide (user manual, case studies, and more)
  • Open an issue (GitHub issues for bug reports, feature requests)
  • Example code (example code snippets referenced in user manual)

Get started

Installation

Prerequisites

You'll need to install rstan first. Stan’s website http://mc-stan.org provides up-to-date information, follow the instructions for your platform. For instructions on installing a C++ compiler for use with RStan see https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started are quite thorough.

Latest Release

Getting started and installing the latest snapshot, type in the R console:

install.packages(c("coda","devtools","loo","ggplot2"))
devtools::install_github("sshpa/bayesvl")

Example

Create appropriate Bayesian network structures

Creating a node for each variable in the proposed network

dag <- bayesvl()
dag <- bvl_addNode(dag, "Burden", "norm")
dag <- bvl_addNode(dag, "Res", "norm")
dag <- bvl_addNode(dag, "Insured", "norm")

Starting to add arcs between variables (nodes) using the survey data

dag <- bvl_addArc(dag, "Res", "Burden", "slope")
dag <- bvl_addArc(dag, "Insured", "Burden", "slope")

Generate 'Stan' code

Generating the 'Stan' code required for building structures of the Bayesian networks required for sampling and parameter learning

stan_code <- bvl_model2Stan(dag)
cat(stan_code)

Getting the model's parameters

params <- bvl_stanParams(dag)
params

Preparing the data

In this example, we used the data1042 data set that is built-in to the package.

# load data
data( data1042 )

Sample and fit the 'Stan' model

Sampling the predefined 'Stan' model

stan_fit <- bvl_modelFit(dag, data1042, iter=5000 , warmup=2000 , chains=4 , cores=4)
summary(stan_fit)

bayesvl's People

Contributors

sshpa avatar vuongulb avatar

Stargazers

 avatar Fumeng Yang avatar Ahmed T. Hammad avatar  avatar  avatar HarryZhu avatar Gibs avatar Cameron Smith avatar Bruno Nicenboim avatar Pavel Logacev avatar  avatar Titus von der Malsburg avatar Fri avatar Josh Duncan avatar Brian W Bush avatar Jo Kroese avatar  avatar Chuanji Gao avatar Leo Lee avatar Xiangyun Huang avatar

bayesvl's Issues

Error in MCMC Sampling

Error in bvl_modelFit(model, data, warmup = 10, iter = 50, chains = 2, : Invalid model to estimate!

image

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.