Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sampleMcmc Error in checkForRemoteErrors(val) : one node produced an error: NA/NaN/Inf in foreign function call #176

Open
amybauer opened this issue Jan 16, 2024 · 2 comments

Comments

@amybauer
Copy link

Hi,

I am struggling with a recurring error occurring occurring in the abundance model I am trying to run on my university's HPC for a hurdle approach. The model runs fine for the presence-absence matrix, as well as for a lower number of iterations for the abundances (thin 10, 100), but once it gets to a greater number of iterations the error occurs (both times, after running for about 3 days).

From my understanding, this error is not so much an issue of Hmsc, but rather of glm (?) but it has me seriously stuck, and I would greatly appreciate any guidance on how to resolve the problem:

This is the error I received:

Error in checkForRemoteErrors(val) : 
  one node produced an error: NA/NaN/Inf in foreign function call (arg 3)
Calls: sampleMcmc ... clusterApplyLB -> dynamicClusterApply -> checkForRemoteErrors

Notes on the underlying data:
As I said, I am trying to run the abundance model part for a hurdle approach.
Overall, data were collected over one year (52 weeks) and 109 sampling sites, although the sampling effort varies across sites, with most sites being sampled ~ April-October. I decided to include only those species that occurred in at least 5 of the sampling events across the year, and I also excluded any species of which less than 20 specimens were recorded over the entire year (based on insights from the discussion in #45 ).

I made sure all columns in the Y matrix contain integer values, with individual species ranging between 1 and max(sp).
I will say that in the first and last weeks, some sites had only one single species recorded for a given sampling event - could that be the cause of the problem?

Here is how I defined the model:

> m.ABUNDa = Hmsc(Y=Y, 
         XData = XData_a, XFormula = XFormula_a, # XScale = T, default
         TrData = Tr, TrFormula = TrFormula, # TScale = T, default
         phyloTree =  phy,
         studyDesign = SD, ranLevels={list("ref" = ref, "loc_ID"= rL_S, "Julian_week"=rL_T)},
         distr="lognormal poisson")

> models$m.ABUNDa         
Hmsc object with 2262 sampling units, 39 species, 9 covariates, 3 traits and 3 random levels
No posterior samples

This dropbox folder contains the unfitted model.

Here is how I tried to fit the model:

m = sampleMcmc(m, samples = samples, thin=thin,
               adaptNf=rep(ceiling(0.4*samples*thin),m$nr), 
               transient = ceiling(0.5*samples*thin),
               nChains = nChains,
               nParallel = nParallel) 

I had not set initPar = "fixed effects", which seems to be the right choice after reading through similar reported issues here as I saw that this could cause a problem. However, I just realized I did not fit the model with useSocket = FALSE as advised in the documentation, though I do not think that this is where the problem comes in?

I checked for similar issues here on github (#45 #123 #174 ), but as far as I can tell, none of them addresses quite the problem I am facing.

Again, any feedback and insight is much appreciated!
Amy 🦟

@Baremarc
Copy link

Baremarc commented May 1, 2024

I have collided with the same Problem! After running the for some time the error occurs. It seems to be related to HMM where it tries to initiate propabilites of extreme values.

@nereydafl
Copy link

I have the same problem. Please let me know if you fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants