help with marginal WAIC w/ grouping

141 views
Skip to first unread message

Max Rubino

unread,
Mar 1, 2024, 10:55:18 AM3/1/24
to nimble-users
Hi Nimble Community,

I am struggling with calculating WAIC for a integrated model. The model has a multi-state component, where I am using marginal likelihood to avoid estimating the true latent states (z). The likelihood component for this portion is 

 for(i in 1:marked){
    y[i,f[i]:l[i]] ~ dHMM(probInit = TLM[spz[i],fs[i],1:15],
                          probObs = OPM[R[i],1:15,1:17],
                          probTrans = TPM[spz[i],f[i]:(l[i]-1),1:15,1:15],
                          len=length(f[i]:l[i]))

  }

where y is the observed state of fish i. I believe since I am using marginal likelihood, and since dHMM returns onee likelihood value for each fish's capture history I should use marginal WAIC for node y, and groups y[i,f[i]:l[i]]. Is this correct? My waic control arguments are 

for(i in 1:constants$marked){groups[i]<-paste0('y[',i,',',constants$f[i],':',constants$l[i],']')}
list(dataGroups=groups,MarginalizeNodes='y').

The second portion of the model is a multinomial glm. The likelihood is as follows

  for(i in 1:lrow){
    marr[i,1:175]~dmulti(pi[i,1:175],n[i])
  }

should I group nodes marr[i,1:175] as well since one likelihood value is calculated for each row in marr?

Thanks for all the help. I am very new to WAIC.

Best,
Max  

Chris Paciorek

unread,
Mar 6, 2024, 12:12:19 PM3/6/24
to Max Rubino, nimble-users
Hi Max,

In this case by virtue of each history being a (single) multivariate node, things are already grouped, with each multivariate node having a single likelihood value, and there should not be a need to specify groups (which is a way of combining *multiple* nodes and treating as a single contribution to WAIC). Also since `dHMM` has already marginalized over the latent states, one wouldn't explicitly ask for marginal WAIC. You're already getting a marginal WAIC based on your model specification.

As a side note, if instead one had a model in which `z` were explicitly in the model, one would have `z` (not `y` -- these are the observed nodes not the latent nodes) as the `marginalizeNodes`.  (and note "marginalizeNodes" not "MarginalizeNodes")

Similarly for `marr`, each row is a (single) multivariate node so already grouped and you shouldn't need to specify groups.

Let me know if that doesn't make sense or you have further questions.

-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 view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/b46e7af2-3718-4175-af65-cd1e4278837dn%40googlegroups.com.

Max Rubino

unread,
Mar 6, 2024, 2:10:26 PM3/6/24
to nimble-users
Hi Chris,

That makes sense, thanks so much for the explanation. I was hoping that the following warning message was a result of not having the nodes grouped, but following your explanation, I now know that it is an issue with the model. 

"There are 19 individual pWAIC values that are greater than 0.4. This may indicate that the WAIC estimate is unstable (Vehtari et al., 2017), at least in cases without grouping of data nodes or multivariate data nodes."

Thanks again for the detailed explanation. 

Max
Reply all
Reply to author
Forward
0 new messages