Skip to content

Instantly share code, notes, and snippets.

@leoniedu
Created April 9, 2010 02:10
Show Gist options
  • Save leoniedu/360802 to your computer and use it in GitHub Desktop.
Save leoniedu/360802 to your computer and use it in GitHub Desktop.
write('model {
for (i in 1:n.rows) {
y[i] ~ dnorm(y.hat[i], tau.y)
y.hat[i] <- b.0 + b.1 * x[i]
}
b.0 ~ dnorm (0, 1/(sdp^2))
b.1 ~ dnorm (0, 1/(sdp^2))
tau.y ~ dgamma(.0001, .0001)
sigma.y <- pow(tau.y, -(1/2))
}', file="model.bug")
library(rjags)
y <- rnorm(10)
y[1] <- NA
x <- rnorm(10)
n.rows <- 10
sdp <- 100
print(y[1])
## NA
m <- jags.model("model.bug")
ms <- jags.samples(m, n.iter=1000)
print(y[1])
## -1.797693e+308 instead of NA
## R version 2.10.1 (2009-12-14)
## x86_64-apple-darwin9.8.0
## sessionInfo()
## R version 2.10.1 (2009-12-14)
## x86_64-apple-darwin9.8.0
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
## attached base packages:
## [1] splines stats graphics grDevices utils datasets methods
## [8] base
## other attached packages:
## [1] survival_2.35-8 Zelig_3.4-8 boot_1.2-41 MASS_7.3-5
## [5] R2jags_0.02-02 rjags_1.0.3-13 R2WinBUGS_2.1-16 coda_0.13-4
## [9] lattice_0.18-3
## loaded via a namespace (and not attached):
## [1] grid_2.10.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment