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

Changes for cran 226 #1087

Merged
merged 3 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45,440 changes: 22,860 additions & 22,580 deletions StanHeaders/inst/stanc.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions rstan/rstan/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Package: rstan
Type: Package
Title: R Interface to Stan
Version: 2.26.22
Version: 2.26.23
Authors@R: c(person("Jiqiang", "Guo", email = "[email protected]", role = "aut"),
person("Jonah", "Gabry", email = "[email protected]", role = "aut"),
person("Ben", "Goodrich", email = "[email protected]", role = c("cre", "aut")),
person("Andrew", "Johnson", email = "[email protected]", role = "aut"),
person("Sebastian", "Weber", email = "[email protected]", role = "aut"),
person("Daniel", "Lee", role = "ctb"),
person("Krzysztof", "Sakrejda", role = "ctb"),
Expand Down Expand Up @@ -62,7 +63,9 @@ Suggests:
rstantools,
rstudioapi,
Matrix,
knitr
knitr,
rstanarm,
coda
URL: https://mc-stan.org/rstan/, https://discourse.mc-stan.org
BugReports: https://github.com/stan-dev/rstan/issues/
VignetteBuilder: knitr
Expand Down
2 changes: 1 addition & 1 deletion rstan/rstan/inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
citHeader("To cite RStan in publications use:")

citEntry(entry = "Misc",
bibentry(bibtype = "Misc",
title = "{RStan}: the {R} interface to {Stan}",
author = person(given = "Stan Development Team"),
note = paste("R package version", meta$Version),
Expand Down
68 changes: 34 additions & 34 deletions rstan/rstan/man/rstan.Rd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

\name{rstan-package}
\alias{rstan-package}
\alias{rstan}
\alias{rstan}
\docType{package}
\title{RStan --- the \R interface to Stan}
\description{
Expand All @@ -13,47 +13,47 @@
RStan is the \R interface to the \href{https://mc-stan.org/}{Stan} C++ package.
The RStan interface (\pkg{rstan} \R package) provides:
\itemize{
\item Full Bayesian inference using the No-U-Turn sampler (NUTS),
\item Full Bayesian inference using the No-U-Turn sampler (NUTS),
a variant of Hamiltonian Monte Carlo (HMC)
\item Approximate Bayesian inference using automatic differentiation
\item Approximate Bayesian inference using automatic differentiation
variational inference (ADVI)
\item Penalized maximum likelihood estimation using L-BFGS optimization
}

For documentation on Stan itself, including the manual and user guide
for the modeling language, case studies and worked examples, and other
tutorial information visit the Users section of the Stan website:

\itemize{
\item \href{https://mc-stan.org/users/documentation/}{mc-stan.org/users/documentation}
}

}
\section{Other \R packages from the Stan Development Team}{
Various related \R packages are also available from the Stan Development Team including these and more:
\tabular{llll}{
\strong{Package} \tab \strong{Description} \tab \strong{Doc} \tab \strong{Website} \cr
\pkg{bayesplot}
\tab ggplot-based plotting of parameter estimates, diagnostics, and posterior predictive checks.
\pkg{bayesplot}
\tab ggplot-based plotting of parameter estimates, diagnostics, and posterior predictive checks.
\tab \link[bayesplot]{bayesplot-package}
\tab \href{https://mc-stan.org/bayesplot/}{mc-stan.org/bayesplot}
\cr
\pkg{shinystan}
\tab Interactive GUI for exploring MCMC output.
\pkg{shinystan}
\tab Interactive GUI for exploring MCMC output.
\tab \link[shinystan]{shinystan-package}
\tab \href{https://mc-stan.org/shinystan/}{mc-stan.org/shinystan}
\cr
\pkg{loo}
\pkg{loo}
\tab Out-of-sample predictive performance estimates and model comparison.
\tab \link[loo]{loo-package}
\tab \link[loo]{loo-package}
\tab \href{https://mc-stan.org/loo/}{mc-stan.org/loo}
\cr
\pkg{rstanarm}
\tab \R formula interface for applied regression modeling.
\pkg{rstanarm}
\tab \R formula interface for applied regression modeling.
\tab \link[rstanarm]{rstanarm-package}
\tab \href{https://mc-stan.org/rstanarm/}{mc-stan.org/rstanarm}
\cr
\pkg{rstantools}
\cr
\pkg{rstantools}
\tab Tools for developers of \R packages interfacing with Stan.
\tab \link[rstantools]{rstantools-package}
\tab \href{https://mc-stan.org/rstantools/}{mc-stan.org/rstantools}
Expand All @@ -64,22 +64,22 @@
\tabular{ll}{
Jonah Gabry (author)\tab <[email protected]> \cr
Ben Goodrich (maintainer, author)\tab <[email protected]> \cr
Jiqiang Guo (author)\tab <[email protected]> \cr
Jiqiang Guo (author)\tab <[email protected]> \cr
}

There are also many other important contributors to RStan
(\href{https://github.com/stan-dev/rstan}{github.com/rstan}).
Please use 'Stan Development Team' whenever citing the R interface to Stan.
There are also many other important contributors to RStan
(\href{https://github.com/stan-dev/rstan}{github.com/rstan}).
Please use 'Stan Development Team' whenever citing the R interface to Stan.
A BibTex entry is available from \url{https://mc-stan.org/rstan/authors}
or \code{citation("rstan")}.
}

\seealso{
\itemize{
\item The RStan vignettes: \url{https://mc-stan.org/rstan/articles/}.
\item \code{\link{stan}} for details on fitting models and
\item \code{\link{stan}} for details on fitting models and
\code{\linkS4class{stanfit}} for information on the fitted model objects.
\item The \code{\link{lookup}} for finding a function in the Stan language
\item The \code{\link{lookup}} for finding a function in the Stan language
that corresponds to a \R function or name.
\item \url{https://github.com/stan-dev/rstan/issues/} to submit a bug
report or feature request.
Expand All @@ -88,40 +88,40 @@
}
}

\examples{\dontrun{
\examples{\dontrun{

stanmodelcode <- "
data {
int<lower=0> N;
real y[N];
}
}

parameters {
real mu;
}
}

model {
target += normal_lpdf(mu | 0, 10);
target += normal_lpdf(y | mu, 1);
}
}
"

y <- rnorm(20)
dat <- list(N = 20, y = y);
fit <- stan(model_code = stanmodelcode, model_name = "example",
y <- rnorm(20)
dat <- list(N = 20, y = y);
fit <- stan(model_code = stanmodelcode, model_name = "example",
data = dat, iter = 2012, chains = 3, verbose = TRUE,
sample_file = file.path(tempdir(), 'norm.csv'))
sample_file = file.path(tempdir(), 'norm.csv'))
print(fit)

# extract samples
e <- extract(fit, permuted = FALSE) # return a list of arrays
# extract samples
e <- extract(fit, permuted = FALSE) # return a list of arrays
str(e)

arr <- as.array(fit) # return an array
arr <- as.array(fit) # return an array
str(arr)

mat <- as.matrix(fit) # return a matrix
str(mat)
}}
\keyword{rstan}
\keyword{rstan}
\keyword{package}
42 changes: 21 additions & 21 deletions rstan/rstan/man/sbc.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\alias{plot.sbc}
\title{Simulation Based Calibration (sbc)}
\description{
\if{html}{\figure{stanlogo.png}{options: width="25px" alt="https://mc-stan.org/about/logo/"}}
\if{html}{\figure{stanlogo.png}{options: width="25" alt="https://mc-stan.org/about/logo/"}}
Check whether a model is well-calibrated with respect to the
prior distribution and hence possibly amenable to obtaining
a posterior distribution conditional on observed data.
Expand All @@ -19,8 +19,8 @@ a posterior distribution conditional on observed data.
\item{stanmodel}{
An object of \code{\link{stanmodel-class}} that is first created by
calling the \code{\link{stan_model}} function}
\item{data}{A named \code{list} or \code{environment} providing the data for
the model, or a character vector for all the names of objects to use as data.
\item{data}{A named \code{list} or \code{environment} providing the data for
the model, or a character vector for all the names of objects to use as data.
This is the same format as in \code{\link{stan}} or \code{\link{sampling}}.}
\item{M}{
The number of times to condition on draws from the prior predictive
Expand All @@ -38,7 +38,7 @@ a posterior distribution conditional on observed data.
whatever runs have been saved to disk and ignore argument \code{M}.}
}
\details{
This function assumes adherence to the following conventions in the
This function assumes adherence to the following conventions in the
underlying Stan program:
\enumerate{
\item Realizations of the unknown parameters are drawn in the \code{transformed data}
Expand All @@ -53,22 +53,22 @@ a posterior distribution conditional on observed data.
a trailing underscore.
\item The realizations of the unknown parameters should be copied into a \code{vector}
in the \code{generated quantities} block named \code{pars_}.
\item The realizations from the prior predictive distribution should be copied
\item The realizations from the prior predictive distribution should be copied
into an object (of the same type) in the \code{generated quantities} block
named \code{y_}. Technically, this step is optional and could be omitted
to conserve RAM, but inspecting the realizations from the prior predictive distribution
is a good way to judge whether the priors are reasonable.
\item The \code{generated quantities} block must contain an integer array named
\code{ranks_} whose only values are zero or one, depending on whether the realization of a
parameter from the posterior distribution exceeds the corresponding \dQuote{true}
\item The \code{generated quantities} block must contain an integer array named
\code{ranks_} whose only values are zero or one, depending on whether the realization of a
parameter from the posterior distribution exceeds the corresponding \dQuote{true}
realization, such as \code{theta > theta_;}. These are not actually "ranks"
but can be used afterwards to reconstruct (thinned) ranks.
\item The \code{generated quantities} block may contain a vector named \code{log_lik}
whose values are the contribution to the log-likelihood by each observation. This
is optional but facilitates calculating Pareto k shape parameters to judge whether
the posterior distribution is sensitive to particular observations.
}

Although the user can pass additional arguments to \code{\link{sampling}} through the \dots,
the following arguments are hard-coded and should not be passed through the \dots:
\enumerate{
Expand All @@ -82,40 +82,40 @@ a posterior distribution conditional on observed data.
finished, as is done by the \code{thin} argument to the \code{plot} method in order to
make the histograms consist of approximately independent realizations
}
Other arguments will take the default values used by \code{\link{sampling}} unless
Other arguments will take the default values used by \code{\link{sampling}} unless
passed through the \dots. Specifying \code{refresh = 0} is recommended to avoid printing
a lot of intermediate progress reports to the screen. It may be necessary to pass a
a lot of intermediate progress reports to the screen. It may be necessary to pass a
list to the \code{control} argument of \code{\link{sampling}} with elements \code{adapt_delta}
and / or \code{max_treedepth} in order to obtain adequate results.

Ideally, users would want to see the absence of divergent transitions (which is shown
by the \code{print} method) and other warnings, plus an approximately uniform histogram
of the ranks for each parameter (which are shown by the \code{plot} method). See the
by the \code{print} method) and other warnings, plus an approximately uniform histogram
of the ranks for each parameter (which are shown by the \code{plot} method). See the
vignette for more details.
}
\value{
The \code{sbc} function outputs a list of S3 class \code{"sbc"}, which contains the
following elements:
\enumerate{
\item \code{ranks} A list of \code{M} matrices, each with number of
rows equal to the number of saved iterations and number of columns equal to
\item \code{ranks} A list of \code{M} matrices, each with number of
rows equal to the number of saved iterations and number of columns equal to
the number of unknown parameters. These matrices contain the realizations
of the \code{ranks_} object from the \code{generated quantities} block of the
Stan program.
\item \code{Y} If present, a matrix of realizations from the prior predictive
distribution whose rows are equal to the number of observations and whose columns
are equal to \code{M}, which are taken from the \code{y_} object in the
are equal to \code{M}, which are taken from the \code{y_} object in the
\code{generated quantities} block of the Stan program.
\item \code{pars} A matrix of realizations from the prior distribution whose rows
are equal to the number of parameters and whose columns are equal to \code{M},
are equal to the number of parameters and whose columns are equal to \code{M},
which are taken from the \code{pars_} object in the \code{generated quantities}
block of the Stan program.
\item \code{pareto_k} A matrix of Pareto k shape parameter estimates or \code{NULL}
if there is no \code{log_lik} symbol in the \code{generated quantities} block
of the Stan program
\item \code{sampler_params} A three-dimensional array that results from combining
calls to \code{\link{get_sampler_params}} for each of
the \code{M} runs. The resulting matrix has rows equal to the number of
the \code{M} runs. The resulting matrix has rows equal to the number of
post-warmup iterations, columns equal to six, and \code{M} floors. The columns
are named \code{"accept_stat__"}, \code{"stepsize__"}, \code{"treedepth__"},
\code{"n_leapfrog__"}, \code{"divergent__"}, and \code{"energy__"}. The most
Expand All @@ -132,8 +132,8 @@ a posterior distribution conditional on observed data.


\references{
The Stan Development Team
\emph{Stan Modeling Language User's Guide and Reference Manual}.
The Stan Development Team
\emph{Stan Modeling Language User's Guide and Reference Manual}.
\url{https://mc-stan.org}.

Talts, S., Betancourt, M., Simpson, D., Vehtari, A., and Gelman, A. (2018).
Expand Down
Loading
Loading