Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncated Error Messages #24

Closed
itsdfish opened this issue Oct 3, 2019 · 2 comments
Closed

Truncated Error Messages #24

itsdfish opened this issue Oct 3, 2019 · 2 comments

Comments

@itsdfish
Copy link
Collaborator

itsdfish commented Oct 3, 2019

Hi Rob-

I noticed that Jags.jl sometimes truncates the error messages. For example, I had a model with a vector of parameters and inadvertently supplied a single value for initialization. I recieved the following message:

RUNTIME ERROR:
Dimension mismatch in values supplied for mu

I couldn't figure out the error so I ran the model through R, which provide more information and I was able to quickly identify the problem. Here is the full error message:

Error in setParameters(init.values[[i]], i) : RUNTIME ERROR:
Dimension mismatch in values supplied for mu

Here is a MWE:

ENV["JAGS_HOME"] = "usr/bin/jags" #your path here
using Jags, StatsPlots, Random, Distributions
cd(@__DIR__)
ProjDir = pwd()
Random.seed!(3431)

y = rand(Normal(0,1),50)

Model = "
model {
      for (i in 1:length(y)) {
            y[i] ~ dnorm(mu[i],sigma);
      }
      for(i in 1:length(y)){
            mu[i]  ~ dnorm(0, 1/sqrt(10));
        }

      sigma  ~ dt(0,1,1) T(0, );
  }
"

monitors = Dict(
  "mu" => true,
  "sigma" => true,
  )

inits = [
  Dict("mu"=>.0,"sigma"=>1.0)
]


jagsmodel = Jagsmodel(
  name="Gaussian",
  model=Model ,
  monitor=monitors,
  ncommands=4, nchains=1,
  #deviance=true, dic=true, popt=true,
  pdir=ProjDir
  )

println("\nJagsmodel that will be used:")
jagsmodel |> display

data = Dict{String, Any}(
  "y" => y,
)

inits = [
  Dict("mu" => 0.0,"sigma" => 1.0,
  ".RNG.name" => "base::Mersenne-Twister")
]

println("Input observed data dictionary:")
data |> display
println("\nInput initial values dictionary:")
inits |> display
println()
#######################################################################################
#                                 Estimate Parameters
#######################################################################################
sim = jags(jagsmodel, data, inits, ProjDir)
sim = sim[5001:end,:,:]
@goedman
Copy link
Collaborator

goedman commented Oct 4, 2019

Hi Chris, yes, I see the problem as well. Once back in CO I’ll take a look at this and the other issue ( #23 ). It’s difficult right now, while traveling, to set aside 2 days or so to fix both issues. I expect to be back early November.

@itsdfish
Copy link
Collaborator Author

itsdfish commented Oct 5, 2019

Thanks Rob. Have a good trip!

@goedman goedman closed this as completed Oct 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants