extract_log_lik(stanfit, parameter_name = "log_lik")
stanfit
object ( 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 (2015). RStan, version 2.6.
log_lik <- extract_log_lik(stanfit, "log_lik")
Run the code above in your browser using DataLab