Skip to content

Instantly share code, notes, and snippets.

@rmcelreath
Created March 31, 2017 15:36
Show Gist options
  • Save rmcelreath/ad708c5806f714a6a3a5fc45e3c961ff to your computer and use it in GitHub Desktop.
Save rmcelreath/ad708c5806f714a6a3a5fc45e3c961ff to your computer and use it in GitHub Desktop.
RStan error passing issue with parallel chains
library(rstan)
# simple model with a bug
model_code <- "
parameters{
real a;
}
model{
a ~ normal(0,1);
}
generated quantities{
real buggy; // undefined, so will throw an error after sampling
}
"
# running with parallel cores hides undefined variable message
# instead get crypted message about slot "mode"
m1 <- stan( model_code=model_code , chains=2 , cores=2 )
# now run with 1 chain (or 1 core) to see problem with buggy variable
m2 <- stan( model_code=model_code , chains=1 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment