diff --git a/DESCRIPTION b/DESCRIPTION index 9ae18011..9ee13668 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: bayesplot Type: Package Title: Plotting for Bayesian Models Version: 1.8.0 -Date: 2021-01-06 +Date: 2021-01-07 Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"), email = "jsg2201@columbia.edu"), person("Tristan", "Mahr", role = "aut"), person("Paul-Christian", "Bürkner", role = "ctb"), @@ -22,7 +22,7 @@ Description: Plotting functions for posterior analysis, MCMC diagnostics, particularly (but not exclusively) packages interfacing with 'Stan'. License: GPL (>= 3) LazyData: TRUE -URL: https://mc-stan.org/bayesplot +URL: https://mc-stan.org/bayesplot/ BugReports: https://github.com/stan-dev/bayesplot/issues/ SystemRequirements: pandoc (>= 1.12.3), pandoc-citeproc Depends: diff --git a/NEWS.md b/NEWS.md index 6fa18586..a62a1bed 100644 --- a/NEWS.md +++ b/NEWS.md @@ -81,7 +81,7 @@ matrices also inheriting from "array" in R 4.0. * Added `mcmc_trace_data()`, which returns the data used for plotting the trace plots and rank histograms. (Advances #97) -* [ColorBrewer](http://colorbrewer2.org) palettes are now available as color +* [ColorBrewer](https://colorbrewer2.org/) palettes are now available as color schemes via [`color_scheme_set()`](https://mc-stan.org/bayesplot/reference/bayesplot-colors.html). For example, `color_scheme_set("brewer-Spectral")` will use the Spectral diff --git a/R/bayesplot-package.R b/R/bayesplot-package.R index a886f7c0..999bb27e 100644 --- a/R/bayesplot-package.R +++ b/R/bayesplot-package.R @@ -44,7 +44,7 @@ #' #' @section Resources: #' * __Online documentation and vignettes__: Visit the __bayesplot__ website at -#' +#' #' * __Bug reports and feature requests__: If you would like to request a new #' feature or if you have noticed a bug that needs to be fixed please let us #' know at the **bayesplot** issue tracker at diff --git a/R/ppc-censoring.R b/R/ppc-censoring.R index d7c3ecae..c3720d9d 100644 --- a/R/ppc-censoring.R +++ b/R/ppc-censoring.R @@ -5,12 +5,11 @@ #' predictive distribution. See the **Plot Descriptions** section, below, for #' details. #' -#' Although some of the other plots can be used with censored data, -#' `ppc_km_overlay()` is currently the only plotting function designed +#' Although some of the other \pkg{bayesplot} plots can be used with censored +#' data, `ppc_km_overlay()` is currently the only plotting function designed #' *specifically* for censored data. We encourage you to suggest or contribute -#' additional plots at [https://github.com/stan-dev/bayesplot](github.com/stan-dev/bayesplot). -#' -#' +#' additional plots at +#' [https://github.com/stan-dev/bayesplot](github.com/stan-dev/bayesplot). #' #' @name PPC-censoring #' @family PPCs @@ -26,10 +25,10 @@ #' \describe{ #' \item{`ppc_km_overlay()`}{ #' Empirical CCDF estimates of each dataset (row) in `yrep` are overlaid, -#' with the Kaplan-Meier estimate (Kaplan and Meier, 1958) for `y` itself -#' on top (and in a darker shade). This is a PPC suitable for -#' right-censored `y`. Note that the replicated data from `yrep` is assumed -#' to be uncensored. +#' with the Kaplan-Meier estimate (Kaplan and Meier, 1958) for `y` itself on +#' top (and in a darker shade). This is a PPC suitable for right-censored +#' `y`. Note that the replicated data from `yrep` is assumed to be +#' uncensored. #' } #' } #' @@ -74,11 +73,9 @@ ppc_km_overlay <- abort("Package 'ggfortify' required.") } - # Checks for 'status_y': stopifnot(is.numeric(status_y)) stopifnot(all(status_y %in% c(0, 1))) - # Create basic PPC dataset: data <- ppc_data(y, yrep, group = status_y) # Modify the status indicator: @@ -93,23 +90,20 @@ ppc_km_overlay <- as.numeric(as.character(.data$group)), 1)) - # Create 'survfit' object and 'fortify' it sf <- survival::survfit( survival::Surv(value, group) ~ rep_label, data = data ) fsf <- fortify(sf) - # Add variables specifying color, size, and alpha: fsf$is_y_color <- as.factor(sub("\\[rep\\] \\(.*$", "rep", sub("^italic\\(y\\)", "y", fsf$strata))) fsf$is_y_size <- ifelse(fsf$is_y_color == "yrep", size, 1) fsf$is_y_alpha <- ifelse(fsf$is_y_color == "yrep", alpha, 1) # Ensure that the observed data gets plotted last by reordering the - # levels of the factor "strata": + # levels of the factor "strata" fsf$strata <- factor(fsf$strata, levels = rev(levels(fsf$strata))) - # Plot: ggplot(data = fsf, mapping = aes_(x = ~ time, y = ~ surv, diff --git a/inst/CITATION b/inst/CITATION index bcd59795..51bb98c6 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -8,7 +8,7 @@ bibentry(bibtype = "Misc", ), year = year, note = note, - url = c("https://mc-stan.org/bayesplot"), + url = c("https://mc-stan.org/bayesplot/"), header = "To cite the bayesplot R package:" ) diff --git a/man-roxygen/reference-loo.R b/man-roxygen/reference-loo.R index d26497d6..a1f4d5d8 100644 --- a/man-roxygen/reference-loo.R +++ b/man-roxygen/reference-loo.R @@ -2,4 +2,4 @@ #' Bayesian model evaluation using leave-one-out cross-validation and WAIC. #' *Statistics and Computing*. 27(5), 1413--1432. #' doi:10.1007/s11222-016-9696-4. arXiv preprint: -#' +#' diff --git a/man/PPC-censoring.Rd b/man/PPC-censoring.Rd index fdec5202..a68d8e01 100644 --- a/man/PPC-censoring.Rd +++ b/man/PPC-censoring.Rd @@ -35,20 +35,21 @@ distributions of simulated/replicated data \code{yrep} from the posterior predictive distribution. See the \strong{Plot Descriptions} section, below, for details. -Although some of the other plots can be used with censored data, -\code{ppc_km_overlay()} is currently the only plotting function designed +Although some of the other \pkg{bayesplot} plots can be used with censored +data, \code{ppc_km_overlay()} is currently the only plotting function designed \emph{specifically} for censored data. We encourage you to suggest or contribute -additional plots at \href{github.com/stan-dev/bayesplot}{https://github.com/stan-dev/bayesplot}. +additional plots at +\href{github.com/stan-dev/bayesplot}{https://github.com/stan-dev/bayesplot}. } \section{Plot Descriptions}{ \describe{ \item{\code{ppc_km_overlay()}}{ Empirical CCDF estimates of each dataset (row) in \code{yrep} are overlaid, -with the Kaplan-Meier estimate (Kaplan and Meier, 1958) for \code{y} itself -on top (and in a darker shade). This is a PPC suitable for -right-censored \code{y}. Note that the replicated data from \code{yrep} is assumed -to be uncensored. +with the Kaplan-Meier estimate (Kaplan and Meier, 1958) for \code{y} itself on +top (and in a darker shade). This is a PPC suitable for right-censored +\code{y}. Note that the replicated data from \code{yrep} is assumed to be +uncensored. } } } diff --git a/man/PPC-loo.Rd b/man/PPC-loo.Rd index dbebd49d..dbfd64eb 100644 --- a/man/PPC-loo.Rd +++ b/man/PPC-loo.Rd @@ -281,7 +281,7 @@ Vehtari, A., Gelman, A., and Gabry, J. (2017). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. \emph{Statistics and Computing}. 27(5), 1413--1432. doi:10.1007/s11222-016-9696-4. arXiv preprint: -\url{https://arxiv.org/abs/1507.04544/} +\url{https://arxiv.org/abs/1507.04544} Boneva, L. I., Kendall, D., & Stefanov, I. (1971). Spline transformations: Three new diagnostic aids for the statistical diff --git a/man/bayesplot-package.Rd b/man/bayesplot-package.Rd index 36f19908..97d03ffd 100644 --- a/man/bayesplot-package.Rd +++ b/man/bayesplot-package.Rd @@ -48,7 +48,7 @@ forecasting/out-of-sample prediction and other inference-related tasks. \itemize{ \item \strong{Online documentation and vignettes}: Visit the \strong{bayesplot} website at -\url{https://mc-stan.org/bayesplot} +\url{https://mc-stan.org/bayesplot/} \item \strong{Bug reports and feature requests}: If you would like to request a new feature or if you have noticed a bug that needs to be fixed please let us know at the \strong{bayesplot} issue tracker at diff --git a/vignettes/graphical-ppcs.Rmd b/vignettes/graphical-ppcs.Rmd index 3c89f48b..5e866dd4 100644 --- a/vignettes/graphical-ppcs.Rmd +++ b/vignettes/graphical-ppcs.Rmd @@ -392,7 +392,7 @@ version 1.7.0. https://CRAN.R-project.org/package=brms Gabry, J., and Goodrich, B. (2017). rstanarm: Bayesian Applied Regression Modeling via Stan. R package version 2.15.3. -https://mc-stan.org/rstanarm, https://CRAN.R-project.org/package=rstanarm +https://mc-stan.org/rstanarm/, https://CRAN.R-project.org/package=rstanarm Gabry, J. , Simpson, D. , Vehtari, A. , Betancourt, M. and Gelman, A. (2019), Visualization in Bayesian workflow. _J. R. Stat. Soc. A_, 182: 389-402. diff --git a/vignettes/plotting-mcmc-draws.Rmd b/vignettes/plotting-mcmc-draws.Rmd index 30caebb9..387ed5bf 100644 --- a/vignettes/plotting-mcmc-draws.Rmd +++ b/vignettes/plotting-mcmc-draws.Rmd @@ -370,7 +370,7 @@ mcmc_trace_highlight(posterior, pars = "sigma", highlight = 3) Gabry, J., and Goodrich, B. (2017). rstanarm: Bayesian Applied Regression Modeling via Stan. R package version 2.15.3. -https://mc-stan.org/rstanarm, https://CRAN.R-project.org/package=rstanarm +https://mc-stan.org/rstanarm/, https://CRAN.R-project.org/package=rstanarm Gabry, J., Simpson, D., Vehtari, A., Betancourt, M. and Gelman, A. (2019), Visualization in Bayesian workflow. _J. R. Stat. Soc. A_, 182: 389-402. diff --git a/vignettes/visual-mcmc-diagnostics.Rmd b/vignettes/visual-mcmc-diagnostics.Rmd index 3ae65e88..d570128a 100644 --- a/vignettes/visual-mcmc-diagnostics.Rmd +++ b/vignettes/visual-mcmc-diagnostics.Rmd @@ -448,7 +448,7 @@ us diagnose divergences. We may however zoom in to investigate, using the ```{r echo=FALSE} #A check that the chosen window still relevant -n_divergent_in_window <- np_cp %>% filter(Parameter == "divergent__" & Value == 1 & Iteration >= 700 & Iteration <= 900) %>% nrow() +n_divergent_in_window <- np_cp %>% filter(Parameter == "divergent__" & Value == 1 & Iteration >= 300 & Iteration <= 500) %>% nrow() if(n_divergent_in_window < 6) { divergences <- np_cp %>% filter(Parameter == "divergent__" & Value == 1) %>% select(Iteration) %>% get("Iteration", .) %>% sort() %>% paste(collapse = ",") @@ -457,7 +457,7 @@ if(n_divergent_in_window < 6) { ``` ```{r mcmc_trace_zoom} -mcmc_trace(posterior_cp, pars = "tau", np = np_cp, window = c(700,900)) + +mcmc_trace(posterior_cp, pars = "tau", np = np_cp, window = c(300,500)) + xlab("Post-warmup iteration") ``` @@ -783,7 +783,7 @@ models. https://arxiv.org/abs/1312.0906 Gabry, J., and Goodrich, B. (2018). rstanarm: Bayesian Applied Regression Modeling via Stan. R package version 2.17.4. -https://mc-stan.org/rstanarm +https://mc-stan.org/rstanarm/ Gabry, J., Simpson, D., Vehtari, A., Betancourt, M. and Gelman, A. (2019), Visualization in Bayesian workflow. _J. R. Stat. Soc. A_, 182: 389-402. @@ -810,4 +810,4 @@ Stan Development Team. _Stan Modeling Language Users Guide and Reference Manual_. https://mc-stan.org/users/documentation/ Stan Development Team. (2018). RStan: the R interface to Stan. R package version 2.17.3. -https://mc-stan.org/rstan +https://mc-stan.org/rstan/