warning in MCMC: logProb of data node Counts[1]: logProb is -Inf.

11 views
Skip to first unread message

Agnieszka Tomczyk

unread,
May 28, 2026, 3:35:22 PMMay 28
to nimble-users
Hi Guys,

I am getting a below error in my model:
warning: logProb of data node Counts[1]: logProb is -Inf.

What may be the reason?

Model details:
This is a spacial analysis. I am modelling the counts of events (var = Counts), with 2 explanatory variables (var1, var2) and one offset - population (var = Pop). No spacial random effects are added.

My code:
model <- nimbleCode({
  beta0 ~ dnorm(0, sd=100)                                                    
  beta1 ~ dnorm(0, sd=100)                                                    
  beta2 ~ dnorm(0, sd=100)                                                    

  for(i in 1:N){                                                                
    log(mu[i]) <- log(Pop[i]) + beta0 + (beta1*Var1[i]) + (beta2*Var2[i])
    Counts[i] ~ dpois(mu[i])                                                  
   }                                                                            
 
})

Data_Nimble <- select(data, Counts, Pop, Var1, Var2) %>%          
  st_drop_geometry() %>%                                                        
  as.list()                                                                    

Constants1 <- list(N = nrow(data))                                                

Inits1 <- list(beta0 = 3,                                    
              beta1 = 3,                                    
              beta2 = 3)                                                                    

model.nimble <- nimbleMCMC(model, data=Data_Nimble,                                      
                         constants=Constants1,                                    
                         niter = 1000,                                          
                         inits = Inits1,                                          
                         samplesAsCodaMCMC = TRUE, summary=TRUE,                
                         monitors=c("beta0","beta1","beta2"),          
                         setSeed = 1994)

Thanks for your help!

Daniel Turek

unread,
Jun 11, 2026, 7:20:33 AM (11 days ago) Jun 11
to Agnieszka Tomczyk, nimble-users
Following up on-list, for the benefit of anyone else.

Agnieszka, thanks for your question. Without a fully reproducible
script it's hard to say exactly what the problem is. Are you able to
provide the "data" object, or sending it directly (off-list) if you
prefer?

Short of that, the message "warning: logProb of data node Counts[1]:
logProb is -Inf." means the log-density for the node Counts[1] is
-Inf. This would be stemming from an invalid (or missing) value of
mu[1], which in turn is coming from the definition of mu[1]. I see
you're providing valid initial values for beta0, beta1, and beta2, so
none of those should be the problem. Therefore, it must be coming
from one of log(Pop[1]), or Var1[1]), or Var2[1] -- or, perhaps all of
these indeed have values, but the combination of them produces a
negative value (or identically 0) for mu[1], which would give the -Inf
log-density for Counts[1]. This is as far as I can help diagnose,
without more information about the data, or ideally a reproducible
script.

Good luck,
Daniel
> --
> 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 visit https://groups.google.com/d/msgid/nimble-users/38f49d9b-a2c2-4aef-b20e-efce2e51cf1an%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages