stan-dev / stan-dev/shinystan

Flickering when selecting parameters on page "ESTIMATE"

Open
#195 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
199
Forks
46
PR merge metrics
No merged PRs in 30d

Description

With shinystan v2.6.0, I get a strange bug when selecting parameters on page "ESTIMATE". The input field "Select or enter parameter names" as well as the plot start flickering heavily, making further use of that input field impossible (and the plot almost impossible to read).

Reproducible steps:

  1. Create file schools.stan with content (modified from https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started):
    // saved as schools.stan
    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 += student_t_lpdf(mu | 7, 0, 5);  // prior for mu
      target += student_t_lpdf(tau | 7, 0, 1);  // prior for tau
      target += normal_lpdf(eta | 0, 1);       // prior log-density
      target += normal_lpdf(y | theta, sigma); // log-likelihood
    }
    
  2. Run
    library(rstan)
    options(mc.cores = parallel::detectCores())
    rstan_options(auto_write = TRUE)
    
    schools_dat <- list(J = 8, 
                        y = c(28,  8, -3,  7, -1,  1, 18, 12),
                        sigma = c(15, 10, 16, 11,  9, 11, 10, 18))
    
    fit <- stan(file = "schools.stan", data = schools_dat, seed = 2098606L)
    
    library(shinystan)
    launch_shinystan(fit)
    
  3. In the shinystan app, switch to page "ESTIMATE".
  4. Select parameter mu.
  5. Now, I already get a mild version of the flickering described above.
  6. Enter theta in the "Add parameters by regex search" input field and click on "Search".
  7. Now, I get the heavy flickering described above. Interestingly, after switching the browser tab and switching back to shinystan, the flickering stops, but the "Select or enter parameter names" input field is still unusable. Only the regex input field works, but when using it, the flickering starts again.

Session info:

I observed this with two different browsers on Ubuntu 20.04.3 LTS: Firefox and Chromium. I also observed this on Windows 10, but there I only tested Firefox. For the R packages (reduced to the content I deemed more or less relevant; tell me if you need more):

> sessioninfo::session_info()
- Session info --------------------------------------------------------------------------------------------------------
 setting  value
 version  R version 4.1.3 (2022-03-10)
 [...]
 ui       RStudio
 [...]
 rstudio  1.4.1717 Juliet Rose (desktop)
 [...]

- Packages ------------------------------------------------------------------------------------------------------------
 ! package       * version    date (UTC) lib source
   [...]
   bayesplot       1.9.0      2022-03-10 [1] CRAN (R 4.1.3)
   [...]
   bslib           0.3.1      2021-10-06 [1] CRAN (R 4.1.1)
   [...]
   callr           3.7.0      2021-04-20 [1] CRAN (R 4.0.5)
   [...]
   fontawesome     0.2.2      2021-07-02 [1] CRAN (R 4.1.1)
   [...]
   ggplot2         3.3.5      2021-06-25 [1] CRAN (R 4.1.0)
   ggridges        0.5.3      2021-01-08 [1] CRAN (R 4.0.3)
   [...]
   htmltools       0.5.2      2021-08-25 [1] CRAN (R 4.1.1)
   htmlwidgets     1.5.4      2021-09-08 [1] CRAN (R 4.1.1)
   [...]
   jquerylib       0.1.4      2021-04-26 [1] CRAN (R 4.0.5)
   jsonlite        1.8.0      2022-02-22 [1] CRAN (R 4.1.2)
   [...]
   knitr           1.38       2022-03-25 [1] CRAN (R 4.1.3)
   [...]
   loo             2.5.1      2022-03-24 [1] CRAN (R 4.1.2)
   [...]
   markdown        1.1        2019-08-07 [1] CRAN (R 4.0.0)
   [...]
   rlang           1.0.2      2022-03-04 [1] CRAN (R 4.1.2)
   rmarkdown       2.13       2022-03-10 [1] CRAN (R 4.1.3)
   [...]
   rstan         * 2.26.6     2021-12-15 [1] local
   rstudioapi      0.13       2020-11-12 [1] CRAN (R 4.0.3)
   sass            0.4.1      2022-03-23 [1] CRAN (R 4.1.2)
   scales          1.1.1      2020-05-11 [1] CRAN (R 4.0.0)
   sessioninfo     1.2.2      2021-12-06 [1] CRAN (R 4.1.2)
   [...]
   shiny         * 1.7.1      2021-10-02 [1] CRAN (R 4.1.1)
   shinyjs         2.1.0      2021-12-23 [1] CRAN (R 4.1.2)
   shinystan     * 2.6.0      2022-03-03 [1] CRAN (R 4.1.2)
   shinythemes     1.2.0      2021-01-25 [1] CRAN (R 4.0.3)
   [...]
   StanHeaders   * 2.26.6     2021-12-15 [1] local
   [...]
   V8              4.1.0      2022-02-06 [1] CRAN (R 4.1.2)
   [...]
   withr           2.5.0      2022-03-03 [1] CRAN (R 4.1.2)
   [...]
   xtable          1.8-4      2019-04-21 [1] CRAN (R 4.0.0)
   [...]

 [...]
-----------------------------------------------------------------------------------------------------------------------

Packages rstan and StanHeaders are from https://mc-stan.org/r-packages/.

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

Reproduce the issue by creating schools.stan, launching shinystan with the supplied R code, and opening the ESTIMATE page. Investigate the parameter-selection and regex-search inputs after selecting mu and searching for theta; done means both inputs remain usable and the plot no longer flickers.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.