Skip to content

Commit aa3d334

Browse files
authored
Merge pull request #153 from stan-dev/develop
v2.4.0
2 parents e30c816 + e8a2e38 commit aa3d334

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+528
-468
lines changed

DESCRIPTION

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: shinystan
22
Title: Interactive Visual and Numerical Diagnostics and Posterior Analysis for
33
Bayesian Models
4-
Version: 2.3.0
5-
Date: 2017-01-31
4+
Version: 2.4.0
5+
Date: 2017-08-01
66
Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"),
77
email = "[email protected]"),
88
person(family = "Stan Development Team", role = "ctb"),
@@ -18,18 +18,19 @@ Authors@R: c(person("Jonah", "Gabry", role = c("aut", "cre"),
1818
Maintainer: Jonah Gabry <[email protected]>
1919
Description: A graphical user interface for interactive Markov chain Monte
2020
Carlo (MCMC) diagnostics and plots and tables helpful for analyzing a
21-
posterior sample. The interface is powered by RStudio's Shiny web
22-
application framework and works with the output of MCMC programs written
23-
in any programming language (and has extended functionality for Stan models
24-
fit using the rstan and rstanarm packages).
25-
URL: https://github.com/stan-dev/shinystan/, http://mc-stan.org/
21+
posterior sample. The interface is powered by the 'Shiny' web
22+
application framework from 'RStudio' and works with the output of MCMC
23+
programs written in any programming language (and has extended
24+
functionality for 'Stan' models fit using the 'rstan' and 'rstanarm'
25+
packages).
26+
URL: http://mc-stan.org/, http://discourse.mc-stan.org
2627
BugReports: https://github.com/stan-dev/shinystan/issues/
2728
License: GPL (>=3)
2829
Depends:
2930
R (>= 3.1.0),
30-
shiny (>= 0.12.1)
31+
shiny (>= 1.0.3)
3132
Imports:
32-
bayesplot (>= 1.1.0),
33+
bayesplot (>= 1.2.0),
3334
colourpicker,
3435
DT (>= 0.2),
3536
dygraphs (>= 1.1.1.2),
@@ -52,8 +53,8 @@ Suggests:
5253
coda,
5354
knitr (>= 1.9),
5455
rmarkdown (>= 0.8.1),
55-
rstanarm (>= 2.14.1),
56+
rstanarm (>= 2.15.3),
5657
testthat
5758
LazyData: true
5859
VignetteBuilder: knitr
59-
RoxygenNote: 5.0.1
60+
RoxygenNote: 6.0.1

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Generated by roxygen2: do not edit by hand
22

3+
S3method(launch_shinystan,default)
4+
S3method(launch_shinystan,shinystan)
35
export(as.shinystan)
46
export(deploy_shinystan)
57
export(drop_parameters)

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### Version 2.4.0
2+
3+
* `launch_shinystan` is now an S3 generic with methods. This allows developers
4+
of packages that use __shinystan__ to create their own `launch_shinystan`
5+
methods instead of using a different function name or creating a naming
6+
conflict.
7+
18
### Version 2.3.0
29

310
#### Fixes

R/deploy_shinystan.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
# this program; if not, see <http://www.gnu.org/licenses/>.
1212

1313

14-
#' Deploy a ShinyStan app on the web using shinyapps.io by RStudio
14+
#' Deploy a 'ShinyStan' app on the web using 'shinyapps.io' by 'RStudio'
1515
#'
16-
#' Requires a (free or paid) ShinyApps account. Visit
16+
#' Requires a (free or paid) 'ShinyApps' account. Visit
1717
#' \url{http://www.shinyapps.io/} to sign up.
1818
#'
1919
#' @export
@@ -46,13 +46,13 @@
4646
#' @seealso The example in the \emph{Deploying to shinyapps.io} vignette that
4747
#' comes with this package.
4848
#'
49-
#' \url{http://www.shinyapps.io/} to sign up for a free or paid ShinyApps
49+
#' \url{http://www.shinyapps.io/} to sign up for a free or paid 'ShinyApps'
5050
#' account and for details on how to configure your account on your local
51-
#' system using RStudio's \pkg{\link[rsconnect]{rsconnect}} package.
51+
#' system using the \pkg{\link[rsconnect]{rsconnect}} package from 'RStudio'.
5252
#'
5353
#' @examples
5454
#' \dontrun{
55-
#' # For this example assume sso is the name of the shinystan object for
55+
#' # For this example assume sso is the name of the \code{shinystan} object for
5656
#' # the model you want to use. Assume also that you want to name your app
5757
#' # 'my-model' and that your shinyapps.io username is 'username'.
5858
#'

R/drop_parameters.R

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
# this program; if not, see <http://www.gnu.org/licenses/>.
1212

1313

14-
#' Drop parameters from a shinystan object
14+
#' Drop parameters from a \code{shinystan} object
1515
#'
16-
#' Remove selected parameters from a shinystan object. This is useful if you
17-
#' have a very large shinystan object when you only want to look at a subset of
18-
#' parameters. With a smaller shinystan object, \code{\link{launch_shinystan}}
19-
#' will be faster and you should experience better performance (responsiveness)
20-
#' after launching when using the ShinyStan app.
16+
#' Remove selected parameters from a \code{shinystan} object. This is useful if
17+
#' you have a very large \code{shinystan} object when you only want to look at a
18+
#' subset of parameters. With a smaller \code{shinystan} object,
19+
#' \code{\link{launch_shinystan}} will be faster and you should experience
20+
#' better performance (responsiveness) after launching when using the
21+
#' 'ShinyStan' app.
2122
#'
2223
#' @export
2324
#' @template args-sso

R/generate_quantity.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#' @param fun Function to call, i.e. \code{function(param1)} or
2222
#' \code{function(param1,param2)}. See Examples, below.
2323
#' @param param1 Name of first parameter as character string.
24-
#' @param param2 Optional. Name of second paramter as character string.
24+
#' @param param2 Optional. Name of second parameter as character string.
2525
#' @param new_name Name for the new parameter as character string.
2626
#'
2727
#' @return sso, updated. See Examples.

R/launch_shinystan.R

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,26 @@
1111
# this program; if not, see <http://www.gnu.org/licenses/>.
1212

1313

14-
#' Launch the ShinyStan app
14+
#' Launch the 'ShinyStan' app
1515
#'
16-
#' Launch the ShinyStan app in the default web browser. RStudio users also have
17-
#' the option of launching the app in RStudio's pop-up Viewer.
16+
#' Launch the 'ShinyStan' app in the default web browser. 'RStudio' users also
17+
#' have the option of launching the app in the pop-up Viewer.
1818
#'
1919
#' @export
20-
#' @param object An object of class shinystan, stanfit, or stanreg. To use other
21-
#' types of objects first create a shinystan object using
20+
#' @param object The object to use. For the default method this can be an object
21+
#' of class \code{"shinystan"}, \code{"stanfit"}, or \code{"stanreg"}. To use
22+
#' other types of objects first create a shinystan object using
2223
#' \code{\link{as.shinystan}}.
23-
#' @param rstudio Only relevant for RStudio users. The default (\code{FALSE}) is
24-
#' to launch the app in the user's default web browser rather than RStudio's
25-
#' pop-up Viewer. Users can change the default to \code{TRUE} by setting the
26-
#' global option \code{options(shinystan.rstudio = TRUE)}.
24+
#' @param rstudio Only relevant for 'RStudio' users. The default (\code{FALSE})
25+
#' is to launch the app in the user's default web browser rather than the
26+
#' pop-up Viewer provided by 'RStudio'. Users can change the default to
27+
#' \code{TRUE} by setting the global option \code{options(shinystan.rstudio =
28+
#' TRUE)}.
2729
#' @param ... Optional arguments passed to \code{\link[shiny]{runApp}}.
2830
#'
2931
#' @return The \code{launch_shinystan} function is used for the side effect of
30-
#' starting the ShinyStan app, but it also returns a shinystan object, an
31-
#' instance of S4 class \code{"shinystan"}.
32+
#' starting the 'ShinyStan' app, but it also returns a \code{shinystan}
33+
#' object, an instance of S4 class \code{"shinystan"}.
3234
#'
3335
#' @template seealso-as.shinystan
3436
#' @template seealso-update_sso
@@ -69,31 +71,45 @@
6971
#' # Example 3: 'fit' is an mcmc.list, array or list of matrices
7072
#' #######################################
7173
#'
72-
#' # First create shinystan object (see ?as.shinystan for full details)
73-
#' fit_sso <- as.shinystan(fit, model_name = "Example")
74-
#'
75-
#' # Now fit_sso is a shinystan object and so Example 1 (above) applies.
74+
#' # First create shinystan object (see ?as.shinystan) for full details)
7675
#' }
7776
#'
78-
launch_shinystan <- function(object,
79-
rstudio = getOption("shinystan.rstudio"),
80-
...) {
81-
if (is.shinystan(object)) {
82-
sso_check(object)
83-
} else if (is.stanreg(object) || is.stanfit(object)) {
84-
message("\nCreating shinystan object...")
77+
launch_shinystan <- function(object, ...) {
78+
UseMethod("launch_shinystan")
79+
}
80+
81+
#' @rdname launch_shinystan
82+
#' @export
83+
launch_shinystan.default <-
84+
function(object,
85+
...,
86+
rstudio = getOption("shinystan.rstudio")) {
87+
if (!is.shinystan(object) &&
88+
!is.stanfit(object) &&
89+
!is.stanreg(object)) {
90+
stop("object not compatible with 'launch_shinystan'. ",
91+
"Try converting to a shinystan object first using 'as.shinystan'.")
92+
}
8593
object <- as.shinystan(object)
94+
message("\nLaunching ShinyStan interface... ",
95+
"for large models this may take some time.")
96+
invisible(launch(object, rstudio, ...))
97+
}
98+
99+
#' @rdname launch_shinystan
100+
#' @export
101+
launch_shinystan.shinystan <-
102+
function(object,
103+
...,
104+
rstudio = getOption("shinystan.rstudio")) {
105+
sso_check(object)
106+
message("\nLaunching ShinyStan interface... ",
107+
"for large models this may take some time.")
108+
invisible(launch(object, rstudio, ...))
86109
}
87-
if (!is.shinystan(object))
88-
stop("'object' is not a valid input. See help('launch_shinystan').")
89-
90-
message("\nLaunching ShinyStan interface... ",
91-
"for large models this may take some time.")
92-
invisible(launch(object, rstudio, ...))
93-
}
94110

95111

96-
#' ShinyStan demo
112+
#' 'ShinyStan' demo
97113
#'
98114
#' @aliases eight_schools
99115
#' @export
@@ -102,8 +118,8 @@ launch_shinystan <- function(object,
102118
#' the only option, but additional demos may be available in future releases.
103119
#' \describe{
104120
#' \item{\code{eight_schools}}{Hierarchical meta-analysis model. See
105-
#' \emph{Meta Analysis} chapter of the Stan manual (chapter 11.2 in version
106-
#' 2.9), \url{http://mc-stan.org/documentation/}.}
121+
#' \emph{Meta Analysis} chapter of the 'Stan' manual
122+
#' \url{http://mc-stan.org/users/documentation/}.}
107123
#' }
108124
#' @return An S4 shinystan object.
109125
#'

R/retrieve.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
#' include/exclude warmup iterations (the default is \code{FALSE}). See
2626
#' Details, below.
2727
#'
28-
#' @details The argument \code{what} can take on the values below. Args:
29-
#' \code{arg} means that \code{arg} can be specified in \code{...} for this
28+
#' @details The argument \code{what} can take on the values below. 'Args:
29+
#' \code{arg}' means that \code{arg} can be specified in \code{...} for this
3030
#' value of \code{what}.
3131
#' \describe{
3232
#' \item{\code{"rhat"}, \code{"Rhat"}, \code{"r_hat"}, or \code{"R_hat"}}{returns: Rhat statistics. Args: \code{pars}}
3333
#' \item{\code{"N_eff"}, \code{"n_eff"}, \code{"neff"}, \code{"Neff"}, \code{"ess"}, or \code{"ESS"}}{returns: Effective sample sizes. Args: \code{pars}}
3434
#' \item{\code{"mean"}}{returns: Posterior means. Args: \code{pars}}
3535
#' \item{\code{"sd"}}{returns: Posterior standard deviations. Args: \code{pars}}
36-
#' \item{\code{"se_mean"} or \code{"mcse"}}{returns: Monte carlo standard error. Args: \code{pars}}
36+
#' \item{\code{"se_mean"} or \code{"mcse"}}{returns: Monte Carlo standard error. Args: \code{pars}}
3737
#' \item{\code{"median"}}{returns: Posterior medians. Args: \code{pars}.}
3838
#' \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}.}
3939
#' \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}}

0 commit comments

Comments
 (0)