The extract_* family of methods returns elements from a fit object (including fixed and estimated quantities, as well as internal elements of the fit object).
fit | An object returned by either |
---|---|
reduce | A function to be applied to all the samples generated by one chain for each parameters (i.e. "within chain"). Useful if only one or more summary measures of the generated samples is needed (e.g. the median of the generated sample). The function may return one of more elements. In the former case, the dimension is dropped in the returned object (read the Value section below). Note that the user needs to supply a function as an argument, and not a character string with the name of the function. |
combine | A function applied to all the extracted quantities as an ensemble. In other words, instead of returning a named list where each element is one quantity, it returns the value returned by the function applied to the whole list ( |
chain | Either "all" or any integer number between 1 and the number of chains M. |
... | Arguments to be passed to rstan's |
The extract_* family is the safest way to access the generated samples (filtered probability alpha, smoothed probability gamma, most likely hidden path zstar, observation samples from the posterior predictive density ypred, hidden path samples from the posterior predictive density zpred, simulated observations ysim), the fixed pre-specified quantities (observations y, time series length T, number of hidden states K, dimension of the observation vector R), Markov-chain Monte Carlo specific information (convergence and posterior predictive diagnostics diagnostics, number of chains n_chains, total iterations n_iterations, warm-up iterations n_warmup, thinning n_thin, sample size sample_size), and other internal elements stored in a fit object (Specification
object spec, dataset in list format data, date date, time elapsed for fitting time, seed seed, path to the underlying Stan file filename). Except for MCMC-specific functions, these all work interchangeably with both Markov-chain Monte Carlo samples returned by draw_samples
and maximum a posteriori estimates returned by optimizing
.
The arguments reduce, combine, and chain are very convenient tools to minimize the amount of data management in your code. See extract_quantity
for an in-depth explanation on how these work.
Other extract: extract_K
,
extract_R
, extract_T
,
extract_alpha
, extract_data
,
extract_filename
,
extract_gamma
, extract_model
,
extract_obs_parameters
,
extract_parameters
,
extract_spec
, extract_ypred
,
extract_ysim
, extract_y
,
extract_zpred
, extract_zsim
,
extract_zstar