warning: logProb of data node: logProb is -Inf.

610 views
Skip to first unread message

Hanah

unread,
Sep 27, 2022, 9:18:51 AM9/27/22
to nimble-users
Hi all,

I am trying to fit a Leroux model using Nimble. However, I keep receiving warnings:
NAs were detected in model variables: s, logProb_s, theta, mu, logProb_O.
and
logProb of data node O[ ]: logProb is -Inf.

Could anyone advise what might be the issue? I attach a simulated dataset and the code I use.

Thank very much in advance!

Best regards,
Hanah.


data.rds
leroux_model.R

Wei Zhang

unread,
Sep 27, 2022, 10:00:33 AM9/27/22
to Hanah, nimble-users
Hi Hanah,

I had a quick run of your code and saw that some elements of O are not 0 but the corresponding means are 0 for the Poisson distribution used. This caused the -Inf log probability calculation. I did not change other parts of the code and used the following (I added initial value to s and removed E from data to constants) to build the model and tested it:

nb.data = list(
  O = data$dthsim    
)
nb.const <-list(
  N = N,
  Q = Q,
  R0=rep(0,N),
  RD=RD,
  E=data$dth2020  
)
# Initials
inits <- list(alpha=0.1, prec=2, rho = 0.7, s = rep(0, N))
model <- nimbleModel(LRfit, nb.const, nb.data, inits)
model$calculate("O[4]") # -Inf
model$O[4] # 1
model$mu[4] # 0


I am not sure about the model itself, but it might be worth paying attention to the zero mean issue. 

Best wishes,
Wei

--
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/8a9e6ad8-18be-4dec-8165-9db9e10f932dn%40googlegroups.com.

Hanah

unread,
Sep 28, 2022, 9:38:09 AM9/28/22
to nimble-users
Hi Wei,

Thanks much! I think the -Inf log probability indeed resulted from the zero mean issue. I tried again using different simulated dataset and it worked.
The note "NAs were detected in model variables" is still there, even though I don't have missing values. Do I need to be concerned about that?

Best regards,
Hanah.  

Hanah

unread,
Sep 28, 2022, 4:30:48 PM9/28/22
to nimble-users
Update: I have been able to run the analysis without the note  "NAs were detected in model variables".

Best regards,
Hanah

Wei Zhang

unread,
Sep 29, 2022, 4:39:22 AM9/29/22
to Hanah, nimble-users
Hi Hanah,

Good to know it works. The NA issue was because you did not initialize all the stochastic nodes (except for data nodes) in the model. In your case, you did not initialize s. As long as you provide eligible initial values to all stochastic excluding data nodes, you will be fine. 

Best wishes,
Wei

Reply all
Reply to author
Forward
0 new messages