0

I am getting and error message that I can't understand when running the code below in R

I have the following example dataset of plots x species abundances

dput(fern[1:5,c(1,3:5)])

structure(c("plot1", "plot2", "plot3", "plot4", "plot5", " 1", 
" 7", " 8", " 10", " 0", "5", "3", "2", "1", "4", " 18", " 13", 
" 0", " 9", " 10"), .Dim = 5:4, .Dimnames = list(NULL, c("plot", 
"Actin_penn", "Actin_subt", "Adian_adia")))

and environmental data

dput(env2[1:5,-c(2)])

structure(c("plot1", "plot2", "plot3", "plot4", "plot5", "2902", 
"3047", "2797", "2752", "2832", "1303", "1355", "1252", "1230", 
"1272", "468", "488", "445", "444", "449", "2958", "2962", "3874", 
"3874", "3782", "127", "129", "145", "147", "148"), .Dim = 5:6, .Dimnames = list(
    NULL, c("plot", "Band4median15", "Band5median15", "Band7median15", 
    "Chelsa450bio12", "SRTM90")))

I first run the model

XData=as.data.frame(env2)
m = Hmsc(Y = fern,
         XData = XData,
         distr = "lognormal poisson")

and seems ok, at least no error messages.

Then I try the sample

thin = 1
samples = 500
nChains = 1
set.seed(1)
m = sampleMcmc(m, samples = samples, thin = thin,
               adaptNf = rep(ceiling(0.4*samples*thin),1),
               transient = ceiling(0.5*samples*thin),
               nChains = nChains, nParallel = nChains)

And get

Error in checkForRemoteErrors(val) : 
  4 nodes produced errors; first error: non-numeric argument to binary operator

Any ideas of what is wrong?

  • It would be easier to help with a [minimal, reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) that allows to reproduce your error (see also [link](https://stackoverflow.com/help/mcve)). – hplieninger Feb 06 '20 at 11:45
  • edited the question, hope it is more clear now. Thanks for warning me @hplieninger – Gabriela Zuquim Feb 06 '20 at 12:12
  • Much better. You may try the [reprex](https://reprex.tidyverse.org/) package for a fully self-contained MVE. For example, `samples` is not defined in your question. – hplieninger Feb 06 '20 at 12:26
  • thanks for the tip. I edited (again!) the question. @hplieninger – Gabriela Zuquim Feb 06 '20 at 12:46
  • There is still `library("Hmsc")` missing. I don't know much about the package, but I guess `fern` should contain numeric rather than character data ...? – hplieninger Feb 06 '20 at 14:25
  • yes, looks like removing the column with plot names is indeed making the trick, thanks. I am getting another error now, I will update here if it is something related. – Gabriela Zuquim Feb 06 '20 at 20:36

0 Answers0