Extract the estimates of the smoothed probability (gamma).

extract_gamma(fit, reduce = NULL, combine = NULL, chain = "all", ...)

Arguments

fit

An object returned by either draw_samples or optimizing.

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 (do.call). Useful when all the elements of the list have the same dimension, possibly because it is used in conjunction with the chain and reduce arguments.

chain

Either "all" or any integer number between 1 and the number of chains M.

...

Arguments to be passed to rstan's extract if the object fit was returned by fit or draw_samples.

Value

A numeric array with four dimensions [N, M, K, T]: number of iterations N, number of chains M, number of hidden states K, length of the time series T. If the argument chain was set, the chain dimension is dropped and the function returns a three-dimensional numeric array [N, K, T]. If the argument reduce was set to a function returning a vector of size n, the returned array has dimension [n, M, K, T]. When n is simply one (e.g. median), the number-of-iterations dimension is dropped and the function returns a three-dimensional numeric array [M, K, T].

See also