# Diagnostic plot subset

**URL:** <https://discourse.mc-stan.org/t/diagnostic-plot-subset/17575>\
**Category:** General\
**Created:** [August 20, 2020, 5:49pm UTC](https://discourse.mc-stan.org/t/diagnostic-plot-subset/17575 "2020-08-20T17:49:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rstanlearner](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@Rstanlearner](https://discourse.mc-stan.org/u/Rstanlearner)\
**Post date:** [August 20, 2020, 5:49pm UTC](https://discourse.mc-stan.org/t/diagnostic-plot-subset/17575/1 "2020-08-20T17:49:42Z")

</div>

Hi I have a question about plotting. Is there a way to plot only a subset of each estimated parameter? I have around 100-400 number of estimates for each parameter category. If plotting too many at once, the plots are not clear enough, so I was wondering if there is a way to plot a subset of each one every time. Thanks!

---

<div class="post-metadata">

**Author:** ![Stephen\_Martin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stephen_martin/32/7879_2.png) [@Stephen\_Martin](https://discourse.mc-stan.org/u/Stephen_Martin)\
**Post date:** [August 21, 2020, 8:05pm UTC](https://discourse.mc-stan.org/t/diagnostic-plot-subset/17575/2 "2020-08-21T20:05:13Z")

</div>

In rstan, there’s a ‘pars’ argument. e.g., `stan_hist(fit, pars = "beta")`

---

<div class="post-metadata">

**Author:** ![Rstanlearner](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@Rstanlearner](https://discourse.mc-stan.org/u/Rstanlearner)\
**Post date:** [August 21, 2020, 8:07pm UTC](https://discourse.mc-stan.org/t/diagnostic-plot-subset/17575/3 "2020-08-21T20:07:17Z")

</div>

Thanks for your reply! Is there a argument I can use to plot a subset of the parameter? e.g., pars= a subset of beta

---

<div class="post-metadata">

**Author:** ![Stephen\_Martin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stephen_martin/32/7879_2.png) [@Stephen\_Martin](https://discourse.mc-stan.org/u/Stephen_Martin)\
**Post date:** [August 21, 2020, 8:14pm UTC](https://discourse.mc-stan.org/t/diagnostic-plot-subset/17575/4 "2020-08-21T20:14:20Z")

</div>

It takes a character vector, so if you want betas 1-4, you could do: `stan_hist(fit, pars = paste0("beta[",1:4,"]"))`

Also, bayesplot supports regex\_pars, so you can specify by regex.

---

<div class="post-metadata">

**Author:** ![Rstanlearner](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@Rstanlearner](https://discourse.mc-stan.org/u/Rstanlearner)\
**Post date:** [August 21, 2020, 8:25pm UTC](https://discourse.mc-stan.org/t/diagnostic-plot-subset/17575/5 "2020-08-21T20:25:24Z")

</div>

Thanks! That is exactly what I need. But would you mind explaining what is regex\_par? haven’t tried bayesplot yet.

---

<div class="post-metadata">

**Author:** ![Stephen\_Martin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/stephen_martin/32/7879_2.png) [@Stephen\_Martin](https://discourse.mc-stan.org/u/Stephen_Martin)\
**Post date:** [August 21, 2020, 9:43pm UTC](https://discourse.mc-stan.org/t/diagnostic-plot-subset/17575/6 "2020-08-21T21:43:32Z")

</div>

Try it first, and read the docs. The gist is - You can use regular expressions (e.g., “beta[([:digit:])+,\1]” to get all beta[1,1], beta[2,2], beta[3,3], etc) for extracting values, rather than selecting them via string pasting.

---

<div class="post-metadata">

**Author:** ![Rstanlearner](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@Rstanlearner](https://discourse.mc-stan.org/u/Rstanlearner)\
**Post date:** [August 22, 2020, 1:14pm UTC](https://discourse.mc-stan.org/t/diagnostic-plot-subset/17575/7 "2020-08-22T13:14:03Z")

</div>

ok! thank you so much!
