RetoSchmucki / rbms

A home for the latest rbms R package
https://retoschmucki.github.io/rbms/
Other
4 stars 4 forks source link

Error at line 59: lenghts of variables differ #22

Closed StefanoMasier closed 7 months ago

StefanoMasier commented 7 months ago

Hello, I was running the Get_Started_2 markdown file, and I encountered an error at line 59 while calculating the collated index:

co_index <- collated_index(data = sindex, s_sp = 2, sindex_value = "SINDEX", glm_weights = TRUE, rm_zero = TRUE)

Error in model.frame.default(weights = data_boot$weights, drop.unused.levels = TRUE, : variable lenghts differ (found for '(weights)')

Full traceback attached Immagine

What could be the reason? I get this error both with my data (not shown) and with the provided files.

Thank you for your help,

Stefano Masier

RetoSchmucki commented 7 months ago

Hi @StefanoMasier, This error vaguely rings a bell, but I must check what it refers to and how to solve it. Thank you for reporting.

RetoSchmucki commented 7 months ago

@StefanoMasier I reproduced the error that was generated from the glmmTMB package. I encountered and fixed this error in another script by patching the specific glmmTMB function. I will try to implement it in the rbms code, but I will need to do some further testing. In the meantime, the code works fine with the glm package, and I will use it as a quick fix until I get the glmmTMB to work smoothly with missing flight curve. glmmTMB has advantages that can be useful in the future.

Just reinstall the rbms package devtools::install_github("RetoSchmucki/rbms") you will have to start a new R session, and it should work now; the function now uses the glm package, with a poison distribution instead of the negative binomial that is available in the glmmTMB package.

I will post here once the glmmTMB is fixed.

StefanoMasier commented 7 months ago

Thank you, now it seems to work!

StefanoMasier commented 7 months ago

Hello again, @RetoSchmucki I have a question: I work for the eBMS project, Italian branch, and I used your package to calulate collated indexes for the species listed in the European Grassland Index using our data. My quesiton is: is it possible now to calculate a sort of "reduced index" using our data only? What would the procedure be?

If you have any documentation to point me towards, I'd be very grateful.

Bests,

Stefano Masier