extract_log_lik(stanfit, parameter_name = "log_lik")
stanfit
object (rstan package). For example, the following is the generated quantities
block for
computing and saving the log-likelihood for a linear regression model with
N
data points, outcome y
, predictor matrix X
,
coefficients beta
, and standard deviation sigma
:
vector[N] log_lik;
for (n in 1:N) log_lik[n] = normal_lpdf(y[n] | X[n] * beta, sigma);
Stan Development Team (2016). RStan: the R interface to Stan, Version 2.10.1. http://mc-stan.org/interfaces/rstan.html