extract_ypred: Extract the sample of the observation variable drawn from the...

Description Usage Arguments Value See Also

Description

Extract the sample of the observation variable drawn from the posterior predictive density (ypred).

Usage

1
extract_ypred(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, T, R]: number of iterations N, number of chains M, length of the time series T, the dimension of the observation vector R. If the argument chain was set, the chain dimension is dropped and the function returns a three-dimensional numeric array [N, T, R]. If the argument reduce was set to a function returning a vector of size n, the returned array has dimension [n, M, T, R]. 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, T, R].

See Also

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_ysim, extract_y, extract_zpred, extract_zsim, extract_zstar, extract


luisdamiano/BayesHMM documentation built on May 20, 2019, 2:59 p.m.