This query arise from something I was wondering in another thread ( Multiple outcomes hurdle model - exists? ), where at one stage I’m trying to make a multivariate lognormal model. Due to the change of variables involved I understand I need to make an adjustment to the model log density. However my confusion arises in how exactly to do this in the multivariate case. Which I realise in turn stems from my poor understanding of the structure of the model log density (i.e. is it simply a number, or because I have a multi-variate outcome it the model log density also multi-variate ??).
Full model herelinear_mvlognorm.stan (1.8 KB), but to put it into context, the salient parts of my model are:
data{
int<lower=0> NvarsY; // num dependent variables
....
vector[NvarsY] y [N]; // data for dependent vars
}
...
model{
....
//likelihood
log(y) ~ multi_normal_cholesky(mu, L_Sigma);
for (dv in 1:NvarsY)
target += -log(y[dv]);
}
What I’m unclear on is the last two lines - I don’t know if I’m adding the -log(y)
term correctly given that y is multivariate, and I don’t know what is the form of target+=
. Should I be looping over 1:N, or 1:dv as in the example, or is simply -log(y)
as a whole entity sufficient, or should I be summing things over y ?