Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divergences for mcmc_scatter #112

Merged
merged 7 commits into from
Sep 8, 2017
Merged

Divergences for mcmc_scatter #112

merged 7 commits into from
Sep 8, 2017

Conversation

jgabry
Copy link
Member

@jgabry jgabry commented Sep 8, 2017

This PR adds an np and np_style arguments to mcmc_scatter so that divergences can be highlighted in the plot. It also adds the scatter_style_np function to use when specifying np_style.

(It's a little bit annoying to have a bunch of functions (e.g. scatter_style_np, pairs_style_np, trace_style_np, parcoord_style_np) that are used to specify the np_style argument depending on the plotting function. It would be nice just to have one function for that, but I tried playing around with that and it's even more annoying because it makes it more confusing to have different defaults for the shape, style, alpha, arguments depending on the plotting function. With different functions the default values can be made more explicit.)

Example usage

library(rstan)
fit <- stan_demo("eight_schools")
posterior <- as.matrix(fit)

color_scheme_set("darkgray")
mcmc_scatter(
  posterior, 
  pars = c("tau", "theta[1]"), 
  np = nuts_params(fit), 
  np_style = scatter_style_np(div_color = "green", div_alpha = 0.8)
)

scatter-with-divs

@jgabry
Copy link
Member Author

jgabry commented Sep 8, 2017

(Running R CMD CHECK now, will report back with the results)

@jgabry
Copy link
Member Author

jgabry commented Sep 8, 2017

Passes R CMD CHECK

[ci skip]
@jgabry jgabry added the feature label Sep 8, 2017
@jgabry jgabry mentioned this pull request Sep 8, 2017
7 tasks
@jgabry jgabry requested a review from tjmahr September 8, 2017 17:36
Copy link
Collaborator

@tjmahr tjmahr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. We'll probably need a vignette to show off all these _np functions.

@jgabry
Copy link
Member Author

jgabry commented Sep 8, 2017

Cool. I just added a quick example of using mcmc_scatter with the np argument in the visual-mcmc-diagnostics.Rmd vignette. In the previous PR for mcmc_parcoord I also added an example of that to the same vignette. Eventually it will probably make sense to break up the current vignettes into smaller ones if/when they get too long.

@jgabry jgabry merged commit 4241f2c into master Sep 8, 2017
@jgabry jgabry deleted the divergences-for-mcmc_scatter branch September 8, 2017 18:42
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants