Hi Keith,
loo::loo or loo::waic is simply looking for an n_posterior_samples * n_observations (observation constituting whatever unit is germane to the likelihood) matrix of log (y|parameters), or n_posterior_samples_per_chain* n_observations*n_chains array. This can be generated within the nimble model itself using something like:
for (i in 1:n){
y[i]~dnorm(mu, sd=sigma)
loglike[i]<-dnorm(y[i], mu, sd=sigma, log=1)
}
...
where you'd trace "loglike". If you store all of the germane parameters (above, mu/sigma), you can also calculate this after the fact--a non-optimized example might have the following r loop:
loglike<-matrix(NA, nsamps, n)
for (i in 1:n){
for (s in 1:nrow(samps)){
loglike[s,i]<-dnorm(y[i], samps$mu[s], sd=samps$sigma[s], log=TRUE)
}
}
Could create and compile a nimble function that does something like the above, which could be useful for using varied existing nimble functions or distributions or speeding things up.
You can also pass a function (perhaps compiled) to loo::waic that itself calls the germane data and iterative parameters and generates a matrix of log likelihood values that the subsequent waic calculations employ. loo::waic(x=<function>) requires data and parameters to be formatted in a certain way.
John