Difference between extract and extract_log_lik?

Dear experts,
I just realized that the log-likelihood matrix of the stan fit varies if I use the following two ways to extract:

  1. my_loglik <- extract(fit, pars = “log_lik”) (from “rstan” package)

  2. my_loglik <- extract_log_lik(fit$fit,parameter_name = “log_lik”) (from “loo” package)

    In theory, the value should not be affected by the way to extract. I don’t know why. I hope someone can explain this to me. Thanks a lot for your help and have a nice day!


1 Like

My guess it has to do with the fact that the former is permuted by default and the latter is unpermuted. Try extract with permute = FALSE.

Hi Ben,
Thanks for your quick reply. It is exactly the reason you pointed out.