hmsc-r / HMSC

GNU General Public License v3.0
103 stars 37 forks source link

Computing species associations and predictions with a spatial random effect model #58

Closed cabuelow closed 4 years ago

cabuelow commented 4 years ago

Hello,

I have an hmsc model (probit) with 149 sampling units, 50 species, 16 covariates, 1 spatial random level, and five latent factors. The hmsc model object is stored as 'm.spatial'.

When I try to compute species associations using the following:

OmegaCor <- computeAssociations(m.spatial)
I get the following error: 
Error in seq.default(start, length(chain), thin) : 
  wrong sign in 'by' argument

Similarly when I try to calculate predictions with the following:

predY <- predict(m.spatial, XData=Gradient$XDataNew, studyDesign=Gradient$studyDesignNew,
                ranLevels=Gradient$rLNew, expected=TRUE)

I get the same error as above. Is there any advice for trouble-shooting this error?

Many thanks, Christina

jarioksa commented 4 years ago

We need a reproducible example. It may also help if you show us your Hmsc and sampleMcmc commands.

jarioksa commented 4 years ago

Hello, I could have this exact error if I haven't run sampleMcmc. That is, you must first define your model with Hmsc(), then you must run sampleMcmc() to get the posterior samples. Functions like computeAssociations() and predict() use those posterior samples. Have you run sampleMcmc?

cabuelow commented 4 years ago

Hi Jari, I loaded the saved m.spatial model object mentioned above, and tried running the 'computeAssociations' and 'predict' functions again, and this time they worked perfectly and I did not receive the error messages I posted.

Apologies for taking your time on this, and thanks very much for your help - I'm enjoying using the HMSC package.

jarioksa commented 4 years ago

This seems to be settled down.