stan-dev / stan-dev/rstan

stan_ac issue when ggplot2 not loaded

Open
#1,049 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary:

The stan_ac function doesn't work properly if the ggplot2 package isn't loaded.

Reproducible Steps:

Reproducible example:

library(rstan)
scode <- "
parameters {
  real y[2]; 
} 
model {
  y[1] ~ normal(0, 1);
  y[2] ~ double_exponential(0, 2);
} 
"
fit1 <- stan(model_code = scode, iter = 100, verbose = FALSE) 
stan_ac(fit1)
Current Output:
> stan_ac(fit1)
Warning messages:
1: Computation failed in `stat_summary()`
Caused by error in `get()`:
! object 'mean_se' of mode 'function' was not found 
2: Computation failed in `stat_summary()`
Caused by error in `get()`:
! object 'mean_se' of mode 'function' was not found 

Plot is produced but empty.

Running the following code produces the expected result

library(ggplot2)
stan_ac(fit1)

Changing line 20 (?) of the function's code to dots$fun.data <- ggplot2::mean_se seems to correct the issue.

RStan Version:

The version of RStan you are running (e.g., from packageVersion("rstan"))

2.26.15

R Version:

4.2.2 (2022-10-31 ucrt)

Operating System:

Windows 10 x64 (build 19044)

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 running the reproducible R example without loading ggplot2, then inspect the stan_ac entry point and the code assigning dots$fun.data. Confirm that using ggplot2::mean_se removes the warning and produces a populated plot, and run the relevant existing checks if you find them.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.