cedadev / jasmin_scivm

9 stars 0 forks source link

build JAGS and rjags (R interface to JAGS) #84

Closed alaniwi closed 7 years ago

alaniwi commented 7 years ago

per user request

alaniwi commented 7 years ago

http://mcmc-jags.sourceforge.net/

alaniwi commented 7 years ago

Built coda (dependency), and jags and rjags.

Testing it using code based on example at http://www.johnmyleswhite.com/notebook/2010/08/20/using-jags-in-r-with-the-rjags-package/ (but tweaked to use a mean of 100 because unclear to me what "close to 0" means). The following code should give numbers close to 100 and close to 0.04:

N <- 1000
x <- rnorm(N, 100, 5)

library('rjags')

jags <- jags.model('example1.bug',
                   data = list('x' = x,
                               'N' = N),
                   n.chains = 4,
                   n.adapt = 100)

update(jags, 1000)

jags.samples(jags,
             c('mu', 'tau'),
             1000)

and we get

$mu
mcarray:
[1] 99.70884

Marginalizing over: iteration(1000),chain(4) 

$tau
mcarray:
[1] 0.03979601

Marginalizing over: iteration(1000),chain(4)