with_mcmc_iter: Evaluate expression within a Stan iteration

Description Usage Arguments Value

View source: R/with_mcmc_iter.R

Description

Evaluate an expression on each iteration of Stan output. This makes it easier to post-process Stan output because the expression is evaluated with the parameters having the same dimensions as they do in the model.

Usage

1
2
3
4
5
6
7
8
with_mcmc_iter(object, ...)

## S3 method for class 'stanfit'
with_mcmc_iter(object, expr, inc_warmup = FALSE,
  data = list(), env = rlang::base_env(), ...)

## S3 method for class 'stanreg'
with_mcmc_iter(object, ...)

Arguments

object

An object.

...

Passed to other methods

expr

An expression to evaluate. This uses eval_tidy to evaluate the expression with the contents of data and the current iteration's parameters as a data mask.

inc_warmup

A logical scalar indicating whether to include the warmup draws. This argument is only relevant if permuted is FALSE.

data

A list or environment with additional data to have in scope when evaluating expr.

env

The environment in which to evaluate expr. This environment is always ignored when evaluating quosures. Quosures are evaluated in their own environment.

Value

A list with the output of expr evaluated with each expression.


jrnold/bayz documentation built on May 5, 2019, 5:52 p.m.