Skip to content

Commit

Permalink
Merge pull request #153 from stan-dev/develop
Browse files Browse the repository at this point in the history
v2.4.0
  • Loading branch information
jgabry authored Aug 2, 2017
2 parents e30c816 + e8a2e38 commit aa3d334
Show file tree
Hide file tree
Showing 44 changed files with 528 additions and 468 deletions.
23 changes: 12 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: shinystan
Title: Interactive Visual and Numerical Diagnostics and Posterior Analysis for
Bayesian Models
Version: 2.3.0
Date: 2017-01-31
Version: 2.4.0
Date: 2017-08-01
Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"),
email = "[email protected]"),
person(family = "Stan Development Team", role = "ctb"),
Expand All @@ -18,18 +18,19 @@ Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"),
Maintainer: Jonah Gabry <[email protected]>
Description: A graphical user interface for interactive Markov chain Monte
Carlo (MCMC) diagnostics and plots and tables helpful for analyzing a
posterior sample. The interface is powered by RStudio's Shiny web
application framework and works with the output of MCMC programs written
in any programming language (and has extended functionality for Stan models
fit using the rstan and rstanarm packages).
URL: https://github.com/stan-dev/shinystan/, http://mc-stan.org/
posterior sample. The interface is powered by the 'Shiny' web
application framework from 'RStudio' and works with the output of MCMC
programs written in any programming language (and has extended
functionality for 'Stan' models fit using the 'rstan' and 'rstanarm'
packages).
URL: http://mc-stan.org/, http://discourse.mc-stan.org
BugReports: https://github.com/stan-dev/shinystan/issues/
License: GPL (>=3)
Depends:
R (>= 3.1.0),
shiny (>= 0.12.1)
shiny (>= 1.0.3)
Imports:
bayesplot (>= 1.1.0),
bayesplot (>= 1.2.0),
colourpicker,
DT (>= 0.2),
dygraphs (>= 1.1.1.2),
Expand All @@ -52,8 +53,8 @@ Suggests:
coda,
knitr (>= 1.9),
rmarkdown (>= 0.8.1),
rstanarm (>= 2.14.1),
rstanarm (>= 2.15.3),
testthat
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 5.0.1
RoxygenNote: 6.0.1
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method(launch_shinystan,default)
S3method(launch_shinystan,shinystan)
export(as.shinystan)
export(deploy_shinystan)
export(drop_parameters)
Expand Down
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
### Version 2.4.0

* `launch_shinystan` is now an S3 generic with methods. This allows developers
of packages that use __shinystan__ to create their own `launch_shinystan`
methods instead of using a different function name or creating a naming
conflict.

### Version 2.3.0

#### Fixes
Expand Down
10 changes: 5 additions & 5 deletions R/deploy_shinystan.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
# this program; if not, see <http://www.gnu.org/licenses/>.


#' Deploy a ShinyStan app on the web using shinyapps.io by RStudio
#' Deploy a 'ShinyStan' app on the web using 'shinyapps.io' by 'RStudio'
#'
#' Requires a (free or paid) ShinyApps account. Visit
#' Requires a (free or paid) 'ShinyApps' account. Visit
#' \url{http://www.shinyapps.io/} to sign up.
#'
#' @export
Expand Down Expand Up @@ -46,13 +46,13 @@
#' @seealso The example in the \emph{Deploying to shinyapps.io} vignette that
#' comes with this package.
#'
#' \url{http://www.shinyapps.io/} to sign up for a free or paid ShinyApps
#' \url{http://www.shinyapps.io/} to sign up for a free or paid 'ShinyApps'
#' account and for details on how to configure your account on your local
#' system using RStudio's \pkg{\link[rsconnect]{rsconnect}} package.
#' system using the \pkg{\link[rsconnect]{rsconnect}} package from 'RStudio'.
#'
#' @examples
#' \dontrun{
#' # For this example assume sso is the name of the shinystan object for
#' # For this example assume sso is the name of the \code{shinystan} object for
#' # the model you want to use. Assume also that you want to name your app
#' # 'my-model' and that your shinyapps.io username is 'username'.
#'
Expand Down
13 changes: 7 additions & 6 deletions R/drop_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
# this program; if not, see <http://www.gnu.org/licenses/>.


#' Drop parameters from a shinystan object
#' Drop parameters from a \code{shinystan} object
#'
#' Remove selected parameters from a shinystan object. This is useful if you
#' have a very large shinystan object when you only want to look at a subset of
#' parameters. With a smaller shinystan object, \code{\link{launch_shinystan}}
#' will be faster and you should experience better performance (responsiveness)
#' after launching when using the ShinyStan app.
#' Remove selected parameters from a \code{shinystan} object. This is useful if
#' you have a very large \code{shinystan} object when you only want to look at a
#' subset of parameters. With a smaller \code{shinystan} object,
#' \code{\link{launch_shinystan}} will be faster and you should experience
#' better performance (responsiveness) after launching when using the
#' 'ShinyStan' app.
#'
#' @export
#' @template args-sso
Expand Down
2 changes: 1 addition & 1 deletion R/generate_quantity.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#' @param fun Function to call, i.e. \code{function(param1)} or
#' \code{function(param1,param2)}. See Examples, below.
#' @param param1 Name of first parameter as character string.
#' @param param2 Optional. Name of second paramter as character string.
#' @param param2 Optional. Name of second parameter as character string.
#' @param new_name Name for the new parameter as character string.
#'
#' @return sso, updated. See Examples.
Expand Down
80 changes: 48 additions & 32 deletions R/launch_shinystan.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,26 @@
# this program; if not, see <http://www.gnu.org/licenses/>.


#' Launch the ShinyStan app
#' Launch the 'ShinyStan' app
#'
#' Launch the ShinyStan app in the default web browser. RStudio users also have
#' the option of launching the app in RStudio's pop-up Viewer.
#' Launch the 'ShinyStan' app in the default web browser. 'RStudio' users also
#' have the option of launching the app in the pop-up Viewer.
#'
#' @export
#' @param object An object of class shinystan, stanfit, or stanreg. To use other
#' types of objects first create a shinystan object using
#' @param object The object to use. For the default method this can be an object
#' of class \code{"shinystan"}, \code{"stanfit"}, or \code{"stanreg"}. To use
#' other types of objects first create a shinystan object using
#' \code{\link{as.shinystan}}.
#' @param rstudio Only relevant for RStudio users. The default (\code{FALSE}) is
#' to launch the app in the user's default web browser rather than RStudio's
#' pop-up Viewer. Users can change the default to \code{TRUE} by setting the
#' global option \code{options(shinystan.rstudio = TRUE)}.
#' @param rstudio Only relevant for 'RStudio' users. The default (\code{FALSE})
#' is to launch the app in the user's default web browser rather than the
#' pop-up Viewer provided by 'RStudio'. Users can change the default to
#' \code{TRUE} by setting the global option \code{options(shinystan.rstudio =
#' TRUE)}.
#' @param ... Optional arguments passed to \code{\link[shiny]{runApp}}.
#'
#' @return The \code{launch_shinystan} function is used for the side effect of
#' starting the ShinyStan app, but it also returns a shinystan object, an
#' instance of S4 class \code{"shinystan"}.
#' starting the 'ShinyStan' app, but it also returns a \code{shinystan}
#' object, an instance of S4 class \code{"shinystan"}.
#'
#' @template seealso-as.shinystan
#' @template seealso-update_sso
Expand Down Expand Up @@ -69,31 +71,45 @@
#' # Example 3: 'fit' is an mcmc.list, array or list of matrices
#' #######################################
#'
#' # First create shinystan object (see ?as.shinystan for full details)
#' fit_sso <- as.shinystan(fit, model_name = "Example")
#'
#' # Now fit_sso is a shinystan object and so Example 1 (above) applies.
#' # First create shinystan object (see ?as.shinystan) for full details)
#' }
#'
launch_shinystan <- function(object,
rstudio = getOption("shinystan.rstudio"),
...) {
if (is.shinystan(object)) {
sso_check(object)
} else if (is.stanreg(object) || is.stanfit(object)) {
message("\nCreating shinystan object...")
launch_shinystan <- function(object, ...) {
UseMethod("launch_shinystan")
}

#' @rdname launch_shinystan
#' @export
launch_shinystan.default <-
function(object,
...,
rstudio = getOption("shinystan.rstudio")) {
if (!is.shinystan(object) &&
!is.stanfit(object) &&
!is.stanreg(object)) {
stop("object not compatible with 'launch_shinystan'. ",
"Try converting to a shinystan object first using 'as.shinystan'.")
}
object <- as.shinystan(object)
message("\nLaunching ShinyStan interface... ",
"for large models this may take some time.")
invisible(launch(object, rstudio, ...))
}

#' @rdname launch_shinystan
#' @export
launch_shinystan.shinystan <-
function(object,
...,
rstudio = getOption("shinystan.rstudio")) {
sso_check(object)
message("\nLaunching ShinyStan interface... ",
"for large models this may take some time.")
invisible(launch(object, rstudio, ...))
}
if (!is.shinystan(object))
stop("'object' is not a valid input. See help('launch_shinystan').")

message("\nLaunching ShinyStan interface... ",
"for large models this may take some time.")
invisible(launch(object, rstudio, ...))
}


#' ShinyStan demo
#' 'ShinyStan' demo
#'
#' @aliases eight_schools
#' @export
Expand All @@ -102,8 +118,8 @@ launch_shinystan <- function(object,
#' the only option, but additional demos may be available in future releases.
#' \describe{
#' \item{\code{eight_schools}}{Hierarchical meta-analysis model. See
#' \emph{Meta Analysis} chapter of the Stan manual (chapter 11.2 in version
#' 2.9), \url{http://mc-stan.org/documentation/}.}
#' \emph{Meta Analysis} chapter of the 'Stan' manual
#' \url{http://mc-stan.org/users/documentation/}.}
#' }
#' @return An S4 shinystan object.
#'
Expand Down
6 changes: 3 additions & 3 deletions R/retrieve.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
#' include/exclude warmup iterations (the default is \code{FALSE}). See
#' Details, below.
#'
#' @details The argument \code{what} can take on the values below. Args:
#' \code{arg} means that \code{arg} can be specified in \code{...} for this
#' @details The argument \code{what} can take on the values below. 'Args:
#' \code{arg}' means that \code{arg} can be specified in \code{...} for this
#' value of \code{what}.
#' \describe{
#' \item{\code{"rhat"}, \code{"Rhat"}, \code{"r_hat"}, or \code{"R_hat"}}{returns: Rhat statistics. Args: \code{pars}}
#' \item{\code{"N_eff"}, \code{"n_eff"}, \code{"neff"}, \code{"Neff"}, \code{"ess"}, or \code{"ESS"}}{returns: Effective sample sizes. Args: \code{pars}}
#' \item{\code{"mean"}}{returns: Posterior means. Args: \code{pars}}
#' \item{\code{"sd"}}{returns: Posterior standard deviations. Args: \code{pars}}
#' \item{\code{"se_mean"} or \code{"mcse"}}{returns: Monte carlo standard error. Args: \code{pars}}
#' \item{\code{"se_mean"} or \code{"mcse"}}{returns: Monte Carlo standard error. Args: \code{pars}}
#' \item{\code{"median"}}{returns: Posterior medians. Args: \code{pars}.}
#' \item{\code{"quantiles"} or any string with \code{"quant"} in it (not case sensitive)}{returns: 2.5\%, 25\%, 50\%, 75\%, 97.5\% posterior quantiles. Args: \code{pars}.}
#' \item{\code{"avg_accept_stat"} or any string with \code{"accept"} in it (not case sensitive)}{returns: Average value of "accept_stat" (which itself is the average acceptance probability over the NUTS subtree). Args: \code{inc_warmup}}
Expand Down
Loading

0 comments on commit aa3d334

Please sign in to comment.