Learn R Programming

bayesforecast (version 1.0.5)

log_lik.varstan: Extract posterior sample of the point wise log-likelihood from a varstan object.

Description

Convenience function for extracting the point wise log-likelihood matrix or array from a fitted Stan model.

Usage

# S3 method for varstan
log_lik(object, permuted = TRUE, ...)

Value

Usually, an S x N matrix containing the point wise log-likelihood samples, where S is the number of samples and N is the number of observations in the data. If permuted is FALSE, an S x N x R array is returned, where R is the number of fitted chains.

Arguments

object

a varstan object of the time series fitted model.

permuted

a logical scalar indicating whether the draws after the warmup period in each chain should be permuted and merged. If FALSE, the original order is kept. For each stanfit object, the permutation is fixed (i.e., extracting samples a second time will give the same sequence of iterations).

...

additional values need in log_lik methods.

References

Vehtari, A., Gelman, A., & Gabry J. (2016). Practical Bayesian model evaluation using leave-one-out cross-validation and WAIC. In Statistics and Computing, doi:10.1007/s11222-016-9696-4.

Gelman, A., Hwang, J., & Vehtari, A. (2014). Understanding predictive information criteria for Bayesian models. Statistics and Computing. 24, 997-1016.

Watanabe, S. (2010). Asymptotic equivalence of Bayes cross validation and widely applicable information criterion in singular learning theory. The Journal of Machine Learning Research. 11, 3571-3594.

Examples

Run this code

# \donttest{
 model = Sarima(birth,order = c(0,1,2),seasonal = c(1,1,1))
 fit1 = varstan(model,iter = 500,chains = 1)

 log1 = log_lik(fit1)
 log1
# }

Run the code above in your browser using DataLab