WAIC and LOOCV for multivariate analysis with different distributions


I’m running a multivariate factor analysis for both a binary variable (with logit link) and a continuous variable (with lognormal distribution) using RStan. I’m wondering how to calculate log-likelihood for such data in the generated quantities block so that I can use loo package to get the modelfit criteria? Could you help me with this?

Thank you!


Hi @ZJL welcome to the Stan forums. Do you mean that your model has two outcomes, one binary and one continuous and you want to calculate the combined log-likelihood? If that’s the case then you should be able to just sum the log-likelihoods for the two outcomes. Let. me know if I misinterpreted your question though.

Hi, thank you for your reply. Yes that is what I mean. I’ve already written a function to calculate WAIC but just curious, in this case, would loo package still work? It seems that it only deals with uni-variate outcomes.

I think the loo package should work fine with multivariate outcomes. The log-likelihood matrix, array, or function that you pass to loo should just contain the total log-likelihood (the sum of the component log-likelihoods). It won’t let you pass in the log-likelihoods separately for the two outcomes but you can just sum them before passing the log-likelihood to loo.

1 Like

Got it. Thank you very much for your help!

No problem!

See also CV FAQ: 13. Is it a problem to mix discrete and continuous data types?

1 Like

Thank you! It’s very helpful.