rstan suppressing errors in rstudio
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 1.1k
- Forks
- 266
- Avg merge
- 2h 56m
- Merged PRs (30d)
- 1
Description
Summary:
Upon running a misspecified model in stan, I get no output and my RStudio no longer prints any error messages.
Description and Reproducible Steps:
I'm new to Stan (pivoting from JAGS), and trying to learn how get my syntax right.
For a toy example, let's look at the code below:
library(data.table)
library(rstan)
rm(list=ls())
chains <- 1
warm<-5000
iterations<-10000
example_data <- data.table(hh_size_mean=c(4.2, 4.1, 3.8, 3.5, 3.2),
hh_size_se=c(0.04, 0.09, 0.07, 0.04, 0.01),
n_llin_mean=c(0.001, 0.8, 0.5, 0.9, 1.2),
n_llin_se=c(0.0001, 0.04, 0.05, 0.02, 0.06),
population=c(33652565, 39624762, 40679006, 45085900, 46223996)
)
data_list <- c(as.list(example_data), list(N = nrow(example_data)))
survey_model_string <- "
data{
int N;
real<lower=0> hh_size_mean[N];
real<lower=0> hh_size_se[N];
real<lower=0> n_llin_mean[N];
real<lower=0> n_llin_se[N];
real population[N];
}
parameters{
real<lower=0> hh[N];
real<lower=0> avg_llin[N];
real<lower=0> llin_count[N];
}
model{
hh ~ normal(hh_size_mean, hh_size_se);
avg_llin ~ normal(n_llin_mean, n_llin_se);
for(i in 1:N){
llin_count[i] = avg_llin[i]*population[i]/hh[i];
}
}
"
survey_prep_model <- stan(model_code=survey_model_string,
warmup=warm,
data = data_list,
chains=chains,
iter=iterations,
verbose = T
)
I'm sure there's something wrong with my Stan code. What I would expect, upon running the stan() function, is to see an error message with some description of where things are going wrong.
Instead, my call to stan() prints the following, and no more:
TRANSLATING MODEL 'dabf8abd0c0011e93f78bc1b1c0419d1' FROM Stan CODE TO C++ CODE NOW.
Even though the stan call does not throw an error, no survey_prep_model object is saved to my environment. Strangely, all RStudio error messages are suppressed as well. Executing commands such as print(nonexistent_object) or nonexistent_function(4995) prints no error to the console. I have to quit and restart RStudio in order to see error messages again.
Running e.g. print("example_string") or packageVersion("rstan") works as expected, so it is only errors that are suppressed.
This bug may be related to this issue, but this model is very small so I wouldn't expect any memory issues.
RStan Version:
2.19.2
R Version:
3.6.0
Operating System:
10.15.1
As described here, I've already worked through the fixes associated with having Catalina installed.
Thanks for your help.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied stan() example in RStudio with RStan 2.19.2, R 3.6.0, and macOS Catalina, then compare the model-translation behavior with ordinary R errors such as print(nonexistent_object). Done means malformed Stan code and regular R errors are reported without requiring an RStudio restart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100