suyusung / R2jags

R2jags: Using R to Run 'JAGS'
8 stars 3 forks source link

Error computing summaries if DIC is FALSE #7

Closed wlandau closed 3 years ago

wlandau commented 3 years ago

Reproducible example:

model <- "model {
  for (i in 1:n) {
    y[i] ~ dnorm(x[i] * beta, 1)
  }
  beta ~ dnorm(0, 1)
}"
tmp <- tempfile()
writeLines(model, tmp)
data <- list(
  n = 10,
  x = rnorm(10),
  y = rnorm(10)
)

library(coda)
out <- capture.output(
  R2jags::jags(
    data,
    parameters.to.save = "beta",
    model.file = tmp,
    n.chains = 4,
    DIC = FALSE
  )
)
#> module glm loaded
#> module dic loaded
#> Error in apply(sims.matrix, 2, mean): dim(X) must have a positive length

Created on 2020-12-21 by the reprex package (v0.3.0)

wlandau-lilly commented 3 years ago

Seems to be caused by sims.matrix = sims[, rank.long] as opposed to sims.matrix = sims[, rank.long, drop = FALSE]. My guess is this only happens for one-parameter models.