Hi, I'm not too sure what your original question was - in general for
a joint likelihood you would write the likelihoods for each component
using BUGS code (if they factorize in some helpful way) or write a
joint likelihood using a single (multivariate) distribution, either
one that NIMBLE provides or a user-defined distribution.
With regard to your error, it appears that the output of functions
like prod() and sum() are treated as 1-length vectors internally, but
your returnType specifies the output as a scalar. The simple fix is to
do something like this:
return(ll[1])
as that forces the output to be treated as a scalar, which is then
consistent with the returnType being specified as a scalar.
A few other comments;
- In general, prod() is not numerically stable, so you would want to do:
sum(log(lambda[1:N]))
- I'm not fully following the details of what your calculations are
doing without looking more carefully, but note that you may want to
move some of the calculations into your llFun run code rather than
defining the computations in BUGS code. For example, you could
probably move all of the deterministic calculations into the llFun
(see below). That will remove a bunch of nodes from the model graph
and allow NIMBLE to set up the model more quickly and do the
calculations during the MCMC more quickly.
## all this could probably be done in llFun
for (i in 1:100){
for (j in 1:100){
lambda_D[i,j]<-lambda0*exp(beta1*0.01*i+beta2*0.01*j)
}
}
s_ll<-mean(lambda_D[1:100,1:100])
for (i in 1:N){
lambda[i]<-lambda0*exp(beta1*x[i]+beta2*y[i])
mark_mean[i]<-alpha1*lambda[i]/100+alpha2*z1[i]+alpha3*z2[i]
logmark[i]<--0.5*log(2*3.14)-0.5*log(1/tau2)-tau2/2*pow((mark[i]-mark_mean[i]),
2)
}
ll_m<-sum(logmark[1:N])
log_ll<-log(prod(lambda[1:N]))
-chris
> --
> You received this message because you are subscribed to the Google Groups
> "nimble-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
nimble-users...@googlegroups.com.
> To post to this group, send email to
nimble...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/nimble-users/2f1ad3c1-1af7-4520-80c9-a9623ed7405a%40googlegroups.com.
>
> For more options, visit
https://groups.google.com/d/optout.