Sunday, May 7, 2017

Using rjags and rstan in Ubuntu

Doing Bayesian data analysis you probably will need to use JAGS and/or STAN to proceed MCMC in R. These can be done using packages rjas and rstan. If you are using Linux (Ubuntu) you can follow the instructions below:

Install Jags in Ubuntu
(open terminal)

sudo add-apt-repository ppa:marutter/rrutter
sudo apt-get update
sudo apt-get install r-cran-rjags

more details on
http://mikemeredith.net/blog/201512/R_and_JAGS_Ubuntu.htm

Install Stan in Ubuntu
(open terminal)

sudo apt-get install r-cran-rcpp r-cran-inline r-cran-rcpp
options(repos = c(getOption("repos"), rstan = "http://wiki.stan.googlecode.com/git/R"))
install.packages('rstan', type = 'source')install.packages('rstan', type = 'source')
install.packages('rstan', type = 'source')

Check the installation
> fx  <-  inline::cxxfunction( signature(x = "integer", y = "numeric" ) , 'return ScalarReal( INTEGER(x)[0] * REAL(y)[0] ) ;' )
> fx( 2L, 5 ) # should be 10

more details on
http://sites.psu.edu/theubunturblog/2012/09/03/installing-rstan-in-ubuntu/

No comments:

Post a Comment

eBook

eBook
New