stan_fit_convert {tsnet} | R Documentation |
Convert Stan Fit to Array of Samples
Description
This function converts a Stan fit object into an array of samples for the temporal coefficients and the innovation covariance or partial correlation matrices. It supports rstan as a backend. It can be used to convert models fit using [stan_gvar()] into 3D arrays, which is the standard data structure used in 'tsnet'. The function allows to select which parameters should be returned.
Usage
stan_fit_convert(stan_fit, return_params = c("beta", "sigma", "pcor"))
Arguments
stan_fit |
A Stan fit object obtained from rstan or a tsnet_fit object from [stan_gvar()]. |
return_params |
A character vector specifying which parameters to return. Options are "beta" (temporal network), "sigma" (innovation covariance), and "pcor" (partial correlations). Default is c("beta","sigma", "pcor"). |
Value
A list containing 3D arrays for the selected parameters. Each array represents the posterior samples for a parameter, and each slice of the array represents a single iteration.
Examples
data(ts_data)
example_data <- ts_data[1:100,1:3]
fit <- stan_gvar(data = example_data,
n_chains = 2,
n_cores = 1)
samples <- stan_fit_convert(fit, return_params = c("beta", "pcor"))