stan-dev / stan-dev/rstan

schools.stan example crashing R GUI on macOS Catalina

Open
#789 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

Summary:

Attempting to run schools example in the R GUI cashes the GUI

Description:

Running the standard schools.stan example from the rstan vignette. Running it in RStudio works (though now producing the message)

sh: clang++ -mmacosx-version-min=10.13: command not found
The NEXT version of Stan will not be able to pre-process your Stan program.

referenced in https://github.com/stan-dev/rstan/issues/774

In trying to figure out what was up with that, I tried running the same example through the R GUI. After navigating to the correct directory and ensuring the code works in RStudio, running the below in R GUI results in the R GUI getting stuck indefinitely. The same thing happens if I try and run rstanarm with more than one core in the R GUI (GUI hangs indefinitely).

Actually, even if you force quite the R GUI, after this happens R keeps running in the background after the force quit, which I discovered from a very noisy fan.

schools <- "
data {
  int<lower=0> J;         // number of schools 
  real y[J];              // estimated treatment effects
  real<lower=0> sigma[J]; // standard error of effect estimates 
}
parameters {
  real mu;                // population treatment effect
  real<lower=0> tau;      // standard deviation in treatment effects
  vector[J] eta;          // unscaled deviation from mu by school
}
transformed parameters {
  vector[J] theta = mu + tau * eta;        // school treatment effects
}
model {
  target += normal_lpdf(eta | 0, 1);       // prior log-density
  target += normal_lpdf(y | theta, sigma); // log-likelihood
}

"

library(rstan)

schools_data <- list(
  J = 8,
  y = c(28,  8, -3,  7, -1,  1, 18, 12),
  sigma = c(15, 10, 16, 11,  9, 11, 10, 18)
)

library(rstan)
fit1 <- stan(
  model_code = schools,
  model_name = "schools",# Stan program
  data = schools_data,    # named list of data
  chains = 4,             # number of Markov chains
  warmup = 1000,          # number of warmup iterations per chain
  iter = 2000,            # total number of iterations per chain
  cores = 1,              # number of cores (could use one per chain)
  refresh = 100             
)
RStan Version:

2.21.1

R Version:

"R version 4.0.2 (2020-06-22)"

Operating System:

macOS 10.15.5

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the supplied schools example through the R GUI on macOS, comparing it with RStudio and with cores set to 1. Investigate the R GUI behavior around the stan(...) call and confirm that the GUI and R process finish normally without hanging after the run.

Written by the indexing model from the issue text.

Assessment

Tech stack
macos, r
Domain
desktop-dev, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.