# Shinystan launch error: Unused Argument

**URL:** <https://discourse.mc-stan.org/t/shinystan-launch-error-unused-argument/33721>\
**Category:** Modeling\
**Tags:** shinystan\
**Created:** [January 4, 2024, 3:21pm UTC](https://discourse.mc-stan.org/t/shinystan-launch-error-unused-argument/33721 "2024-01-04T15:21:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ormvi](https://avatars.discourse-cdn.com/v4/letter/o/bb73d2/32.png) [@ormvi](https://discourse.mc-stan.org/u/ormvi)\
**Post date:** [January 4, 2024, 3:21pm UTC](https://discourse.mc-stan.org/t/shinystan-launch-error-unused-argument/33721/1 "2024-01-04T15:21:01Z")

</div>

Hello,

I am new to shinystan so apologies if I don’t provide enough info/format wrong or something, I can fix as required.

I am having a problem when launching shinystan for my model & after some forum searching I found nothing definite that would help.

After training model  
`by_segment_model_dated <- brm(…)`

I attempt to launch shinystan:  
`  
Launching ShinyStan interface… for large models this may take some time.

Listening on [http://127.0.0.1:6690](http://127.0.0.1:6690)  
Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.  
ℹ Please use the `linewidth` argument instead.  
This warning is displayed once every 8 hours.  
Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.  
Warning: The select input “diagnostic\_param” contains a large number of options; consider using server-side selectize for massively improved performance. See the Details section of the ?selectizeInput help topic.  
Warning: The select input “ac\_params” contains a large number of options; consider using server-side selectize for massively improved performance. See the Details section of the ?selectizeInput help topic.  
Warning in .approxfun(x, y, v, method, yleft, yright, f, na.rm) :  
NAs introduced by coercion  
Warning in .approxfun(x, y, v, method, yleft, yright, f, na.rm) :  
NAs introduced by coercion  
Warning in .approxfun(x, y, v, method, yleft, yright, f, na.rm) :  
NAs introduced by coercion  
Warning: Error in p: unused argument (em(“posterior predictive distribution”))  
125: dots\_list  
124: div  
103: source\_ui [ui\_utils.R#2]  
86: source\_ui [ui\_utils.R#2]  
6: shiny::runApp  
5: launch  
4: launch\_shinystan.shinystan  
2: launch\_shinystan.brmsfit  
1: launch\_shinystan  
`

The shinystan window opens with the below error message:

**unused argument(en(“posterior predictive distribution”))**

Shinystan used to launch for my colleague with these models so I don’t think the problem lies in model code.

I don’t really know where to start looking, so any suggestions would be welcome!

Here’s my R session info (didn’t bother including loaded via a namespace):

```no-highlight
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8    

attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base     

other attached packages:
 [1] viridis_0.6.3 viridisLite_0.4.2 forcats_1.0.0 purrr_1.0.1 readr_2.1.4          
 [6] tibble_3.2.1 tidyverse_2.0.0 tidyr_1.3.0 tidybayes_3.0.4 stringr_1.5.0        
[11] skimr_2.1.5 shinystan_2.6.0 shiny_1.7.4 rstanarm_2.21.4 rstan_2.21.8         
[16] StanHeaders_2.21.0-7 RODBC_1.3-20 rjson_0.2.21 rAzureBatch_0.7.0 pracma_2.4.2         
[21] plotly_4.10.1 patchwork_1.1.2 Microsoft365R_2.3.4 microbenchmark_1.4.10 mice_3.15.0          
[26] magrittr_2.0.3 lubridate_1.9.3 htmlwidgets_1.6.2 Hmisc_5.0-1 gtExtras_0.4.5       
[31] gt_0.9.0 ggplot2_3.4.2 dplyr_1.1.2 doParallel_1.0.17 iterators_1.0.14     
[36] foreach_1.5.2 devtools_2.4.5 usethis_2.1.6 data.table_1.14.8 conflicted_1.2.0     
[41] cmdstanr_0.5.3 brms_2.19.0 Rcpp_1.0.10 blastula_0.3.3 bayesplot_1.10.0     
[46] AzureStor_3.7.0 arrow_11.0.0.3

```

---

<div class="post-metadata">

**Author:** ![ormvi](https://avatars.discourse-cdn.com/v4/letter/o/bb73d2/32.png) [@ormvi](https://discourse.mc-stan.org/u/ormvi)\
**Post date:** [January 11, 2024, 2:22pm UTC](https://discourse.mc-stan.org/t/shinystan-launch-error-unused-argument/33721/2 "2024-01-11T14:22:15Z")

</div>

OK after a brute-force investigation the culprit turned out to be a piece of code in the process which assigns ecdf() to a variable named p:

> p ← ecdf(k)

Clearly somewhere in stan process there is a variable named p, which this reassigns, during the shinystan launch.

Once the variable named p is removed from the session environment (I renamed it for the ecdf() assignment) shinystan launches as expected.

---

<div class="post-metadata">

**Author:** ![aurelien2024](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@aurelien2024](https://discourse.mc-stan.org/u/aurelien2024)\
**Post date:** [June 11, 2024, 1:30pm UTC](https://discourse.mc-stan.org/t/shinystan-launch-error-unused-argument/33721/3 "2024-06-11T13:30:42Z")

</div>

Thanks for your messages. I got the same error and I could resolved it thanks to you. Such a random error. : )

---

<div class="post-metadata">

**Author:** ![ormvi](https://avatars.discourse-cdn.com/v4/letter/o/bb73d2/32.png) [@ormvi](https://discourse.mc-stan.org/u/ormvi)\
**Post date:** [June 11, 2024, 3:39pm UTC](https://discourse.mc-stan.org/t/shinystan-launch-error-unused-argument/33721/4 "2024-06-11T15:39:11Z")

</div>

Thanks! It’s really nice to know this was helpful.
