stan-classes: S7 classes for estimation specifications

stan-classesR Documentation

S7 classes for estimation specifications

Description

The constructors for Stan back-ends and methods are exported to support extensions to measr, for example converting other models to measrfit objects. We do not expect or recommend calling these functions directly unless you are converting objects, or creating new methods for measrfit objects.

Usage

rstan()

cmdstanr()

mcmc()

optim()

variational()

pathfinder()

gqs()

Details

Back-end classes

There are two classes for estimation backends, which define the package that should be used, or was used, to estimate a model. Both classes inherit from measr::stanbackend.

  • The rstan() class indicates use of the {rstan} package.

  • cmdstanr() indicates use of the {cmdstanr} package.

Method classes

The method classes define which estimation method should be used, or was used, for a model. All method classes inherit from measr::stanmethod.

  • The mcmc() class indicates the use of Markov chain Monte Carlo via rstan::sampling() when using {rstan} or the $sample() method of the CmdStanModel class when using {cmdstanr}.

  • The variational() class indicated the use of Stan's variational algorithm for approximate posterior sampling via rstan::vb() when using {rstan} or the $variational() method of the CmdStanModel class when using {cmdstanr}.

  • The pathfinder() class indicates the use of pathfinder variational inference algorithm via the $pathfinder() method of the CmdStanModel. This method is only available when using {cmdstanr}.

  • The optim() class indicates the use maximum-likelihood via rstan::optimizing() when using {rstan} or the $optimize() method of the CmdStanModel class when using {cmdstanr}.

  • Finally, there is a gqs() class for use when a model has previously been estimated and were are interested in calculating generated quantities (e.g., score(), loglik_array()). The gqs() class indicates the use of rstan::gqs() when using {rstan} and the $generate_quantities() method of the CmdStanModel class when using {cmdstanr}.

Value

An S7 object with the corresponding class.

Examples

rstan()

mcmc()

measr documentation built on Jan. 14, 2026, 5:08 p.m.