Strange traceplots–parameters not getting sampled?

28 views
Skip to first unread message

Matthijs Hollanders

unread,
May 19, 2021, 10:59:08 PMMay 19
to nimble-users
Hi everyone,

I realise I've posted a few threads on this forum already but I keep running into fresh issues. I'm running a multisite multistate CJS model which seems to be going well but some of my capture probabilities are showing strange traceplots, see attached. I can provide full code, but I'll just provide code for capture probabilities first to see if the problem can already be diagnosed. Surveys were conducted in the robust design so there's an extra j loop for secondary surveys:

for(m in 1:n.site){
    for(i in 1:n.ind[m]){
      for(t in 1:(n.primary-1)){
        for(j in 1:n.secondary){
          logit(pU[i,t,j,m]) <- p.x[1,m] + p.x[2,m]*sex[i,m] + p.t[t,m]
          logit(pI[i,t,j,m]) <- p.x[1,m] + p.x[2,m]*sex[i,m] + p.x[3,m] + p.t[t,m]
}
}
}
}

Capture probabilities are of uninfected (pU) and infected (pI) individuals. p.x[1:2,m] are site-specific intercepts and effects of sex, p.x[3,m] is the effect on capture probability of being infected, and p.t[t,m] is a random temporal effect. The priors for p.x are this:

for(m in 1:n.site){
    pU.0[m] <- ilogit(p.x[1,m]) # Intercept on the probability scale
    p.x[1,m] ~ dnorm(0, sd = 1.5)
    p.x[2,m] ~ dnorm(0, sd = 1.5)
    p.x[3,m] ~ dnorm(0, sd = 1.5)
}

Initial values for this parameter (the rest is omitted): 
function() list(p.x = array(runif(3*n.site,-1,1), c(3,n.site)))

The model runs fine and I don't get any error messages, but the traceplots look off. For some reason, p.x[1:3,3] are estimated just fine, but p.x[1:3,1:2] don't seem to sample (the screenshot only shows p.x[1:3,2], but p.x[1:3,1] is the same). I am also deriving the site-specific mean capture probability per primary occasion, and those estimates also look reasonable....

Any ideas?

Kind regards,
Matt
 
Screen Shot 2021-05-20 at 11.06.40.png
Screen Shot 2021-05-20 at 11.06.29.png

Matthijs Hollanders

unread,
May 20, 2021, 8:06:42 PMMay 20
to nimble-users
Just a quick update with some more info. If I specify the capture probabilities as random effects, the hyperparameters of each p.x is sampling fine, but still the site-specific values for sites 1 and 2 don't sample (but they do for 3).

Chris Paciorek

unread,
May 24, 2021, 11:10:38 AMMay 24
to Matthijs Hollanders, nimble-users
hi Matthijs,

I'm not seeing anything obviously wrong in terms of the code you are showing. The problematic trace plots are interesting because for some of the parameters, they do change value very occasionally, so it's not that they never change. Is there anything fundamentally different about the data for sites 1 and 2 compared to site 3? Also, after you build the model, are all parameters initialized to semi-reasonable values?

I think to do anything further, we would need a reproducible example (off-list is fine if you have data you don't want to make public).

-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/42cf8b72-966f-409b-ac01-b24b44a0dd62n%40googlegroups.com.

Matthijs Hollanders

unread,
May 25, 2021, 5:01:03 AMMay 25
to nimble-users
Hi Chris,

Thanks for your response. There's nothing really different between the three sites and site 3 actually has the fewest individuals. But the survival and state transition probabilities are getting sampled fine for all 3 sites. I think I'm setting reasonable initial values. I'm only initialising the hypermeans and standard deviations, with hypermeans getting intialised with rnorm(1,-1,1).

I was creating an reproducible R script but first reinstalled NIMBLE (for the second time already), and suddenly all p.x parameters were getting sampled. I took note of which initial values were created by my function and hopefully, if the issue recurs, I can use those initial values to make it run. Still, it's a bit worrisome... I've changed nothing in the code, but suddenly it works...

Kind regards,
Matt

Matthijs Hollanders

unread,
Jun 1, 2021, 9:31:59 PMJun 1
to nimble-users
Hi Chris,

Could you tell me if this is common behaviour for the indicator variables in RJMCMC? I've now analysed two separate datasets, one the multistate CJS above and another a multinomial mixture model, where some of the indicator variables are stuck on 1. The effective sample size of the MCMC is 0, and there's jumping around between 0 and 1 at all. Not all indicator variables show this behaviour–for the CJS, the indicator variables for survival and transition probabilities sample fine, but not for the capture probabilities. I'm just wondering if this is expected with RJMCMC...

Regards,
Matt

David Pleydell

unread,
Jun 2, 2021, 1:57:26 AMJun 2
to nimble-users
Hi Matt

Without a fully reproducable example it's not possibled to dig deep into the causes. There can be many reasons samplers may get stuck, so hard to diagnose from the limited information provided.

Best
David

Matthijs Hollanders

unread,
Jun 4, 2021, 3:54:21 AMJun 4
to nimble-users
Chris solved this issue for–turns out there wasn't really one. The indicator variables for coefficients with posterior densities far away from 0 were always included in the model, thus appearing to not get sampled properly because moves away from 1 were always rejected. Thanks, Chris, for taking the time to respond to me so quickly, and many thanks again for the whole NIMBLE team for the package and users forum!
Reply all
Reply to author
Forward
0 new messages