最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

r - Error with sigma_shape & sigma_rate when running stable isotope mixing model (simmr) with priors - Stack Overflow

programmeradmin6浏览0评论

I am currently trying to run a stable isotope mixing model in R using my own prior distributions. I am using the package simmr. I am getting the following error when I try to run the model with the priors:

Compiling model graph
   Resolving undeclared variables
   Allocating nodes
Deleting model

Error in jags.model(model.file, data = data, inits = init.values, n.chains = n.chains,  : 
  RUNTIME ERROR:
Compilation error on line 13.
Unknown variable sigma_shape
Either supply values for this variable with the data
or define it  on the left hand side of a relation.

From what I understand, both sigma_shape and sigma_rate (which represent the prior distribution on the residual standard deviation) should be able to run as the default values, but the error is suggesting that it doesn’t recognize that variable. I was thinking I could manually set sigma_shape and sigma_rate to their default values, but I have not been able to find what these values are.

I am running the simmr model using mcmc, and have had no issues up until this point (the model runs successfully without the priors added). This problem persists for me even when running the example code from the package:

library(simmr)

mix <- matrix(c(
  -10.13, -10.72, -11.39, -11.18, -10.81, -10.7, -10.54,
  -10.48, -9.93, -9.37, 11.59, 11.01, 10.59, 10.97, 11.52, 11.89,
  11.73, 10.89, 11.05, 12.3
), ncol = 2, nrow = 10)
colnames(mix) <- c("d13C", "d15N")
s_names <- c("Zostera", "Grass", "U.lactuca", "Enteromorpha")
s_means <- matrix(c(-14, -15.1, -11.03, -14.44, 3.06, 7.05, 13.72, 5.96), ncol = 2, nrow = 4)
s_sds <- matrix(c(0.48, 0.38, 0.48, 0.43, 0.46, 0.39, 0.42, 0.48), ncol = 2, nrow = 4)
c_means <- matrix(c(2.63, 1.59, 3.41, 3.04, 3.28, 2.34, 2.14, 2.36), ncol = 2, nrow = 4)
c_sds <- matrix(c(0.41, 0.44, 0.34, 0.46, 0.46, 0.48, 0.46, 0.66), ncol = 2, nrow = 4)

simmr_in <- simmr_load(
  mixtures = mix,
  source_names = s_names,
  source_means = s_means,
  source_sds = s_sds,
  correction_means = c_means,
  correction_sds = c_sds,
)

proportion_means <- c(0.4, 0.3, 0.2, 0.1)
proportion_sds <- c(0.08, 0.02, 0.01, 0.02)
prior <- simmr_elicit(
  4, proportion_means,
  proportion_sds
)

simmr_out_informative <- simmr_mcmc(simmr_in,
                                    prior_control =
                                      list(
                                        means = prior$mean,
                                        sd = prior$sd))

Any suggestions on how to resolve this would be greatly appreciated :) Thanks!

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论