LHS indexing for a multivariate random draw can only use sequential blocks (via ':') -error in a multievent model

21 views
Skip to first unread message

Antti Piironen

unread,
May 9, 2025, 8:14:56 AM5/9/25
to nimble-users
Hi all

I'm developing a multievent model for a study population of common kestrel, which is a part of a large model (IPM). We are interested in sex-specific temporal changes in survival and site fidelity, but the weakness in the data is that the sex is imperfectly identified especially for juveniles. Hence, the multievent approach. The data includes ~ 10k individuals captured and banded from nest boxes and encountered in the following 29 years by recapturing them in and outside the study area and recovering dead birds throughout their range.

As the data is somewhat big and the number of states (events) gets large, there is a need to marginalize over the latent states and pool the encounter histories for efficient sampling (and parallelize sampling, of course). I tried implementing the marginalization using distributions from the nimbleEcology package but faced an error I couldn't figure out. The error comes when compiling the model, and the error message is:

Error: LHS indexing for a multivariate random draw can only use sequential blocks (via ':').
 This occurred for: model_y[getNodeFunctionIndexedInfo(ARG1_INDEXEDNODEINFO__,1), (Interm_28:29)]
 This was part of the call:  model_y[getNodeFunctionIndexedInfo(ARG1_INDEXEDNODEINFO__,1), (Interm_28:29)] <<- rcFun_nimbleEcology55(n=1,init=Interm_24,probObs=Interm_25,probTrans=Interm_26,len=Interm_27,checkRowSums=1)

I attached a heavily reduced reprex using a fraction of the data. Note that I reduced the model for the example a lot (switched from dDHMMo to dHMMo, removed time-depencies, random structures etc.). The problem is likely in the model code, but I couldn't figure out where. I'm unsure whether the dHMMo can properly handle the four-dimensional observation array. However, I got the same error with a three-dimensional observation array (which should be ok) which indicates that the problem is somewhere else.

Any help/thoughts will be highly appreciated.

Thanks in advance,

-Antti
multievent-dHMMo-problem-reprex.R

Chris Paciorek

unread,
May 9, 2025, 8:50:17 PM5/9/25
to Antti Piironen, nimble-users
Ok, I think you ran into a shortcoming in the compilation processing. It looks like the parentheses in "(first[i]:nyear)" are not expected by the processing of the R code to C++.

I think if you remove those parentheses things will be ok.

I will file an issue for us to look into this more deeply and hopefully handle it.

As a side note, instead of the tedious setting of constant values of 0 and 1 in various variables, you can omit all those from the model code and set via inits (or for simplicity just remove all the lines setting values to 0 and set all elements to 0 in the inits). It will reduce the model code length and reduce the amount of calculation done by the model. And I think it will reduce the time for model building and compilation by a lot (more than I expected when I just tried it).

-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 visit https://groups.google.com/d/msgid/nimble-users/CAH-w-5oFi%3DJS8NYGk9n3YULKM065N85aK7JxY_Ow0F83zKHLnw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages