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_log(y[n], X[n] * beta, sigma);
Stan Development Team (2016). RStan, version 2.9. http://mc-stan.org/interfaces/rstan.html.