Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stanmodel-class

Class representing model compiled from C++


Description

A stanmodel object represents the model compiled from C++ code. The sampling method defined in this class may be used to draw samples from the model and optimizing method is for obtaining a point estimate by maximizing the log-posterior.

Objects from the Class

Instances of stanmodel are usually created by calling function stan_model or function stan.

Slots

model_name:

The model name, an object of type character.

model_code:

The Stan model specification, an object of type character.

model_cpp:

Object of type list that includes the C++ code for the model.

mk_cppmodule:

A function to return a RCpp module. This function will be called in function sampling and optimzing with one argument (the instance of stanmodel itself).

dso:

Object of S4 class cxxdso. The container for the dynamic shared objects compiled from the C++ code of the model, returned from function cxxfunction in package inline.

Methods

show

signature(object = "stanmodel"): print the Stan model specification.

vb

signature(object = "stanmodel"): use the variational Bayes algorithms.

sampling

signature(object = "stanmodel"): draw samples for the model (see sampling).

optimizing

signature(object = "stanmodel"): obtain a point estimate by maximizing the posterior (see optimizing).

get_cppcode

signature(object = "stanmodel"): returns the C++ code for the model as a character string. This is part of the C++ code that is compiled to the dynamic shared object for the model.

get_stancode

signature(object = "stanmodel"): returns the Stan code for the model as a character string

get_cxxflags

signature(object = "stanmodel"): return the CXXFLAGS used for compiling the model. The returned string is like CXXFLAGS = -O3.

Note

Objects of class stanmodel can be saved for use across R sessions only if save_dso = TRUE is set during calling functions that create stanmodel objects (e.g., stan and stan_model).

Even if save_dso = TRUE, the model cannot be loaded on a platform (operating system, 32 bits or 64 bits, etc.) that differs from the one on which it was compiled.

See Also

Examples

showClass("stanmodel")

rstan

R Interface to Stan

v2.21.2
GPL (>= 3)
Authors
Jiqiang Guo [aut], Jonah Gabry [aut], Ben Goodrich [cre, aut], Sebastian Weber [aut], Daniel Lee [ctb], Krzysztof Sakrejda [ctb], Modrak Martin [ctb], Trustees of Columbia University [cph], Oleg Sklyar [cph] (R/cxxfunplus.R), The R Core Team [cph] (R/pairs.R, R/dynGet.R), Jens Oehlschlaegel-Akiyoshi [cph] (R/pairs.R), John Maddock [cph] (gamma.hpp), Paul Bristow [cph] (gamma.hpp), Nikhar Agrawal [cph] (gamma.hpp), Christopher Kormanyos [cph] (gamma.hpp), Bronder Steve [ctb]
Initial release
2020-07-27

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.