biodiverse / ubms

Fit models to data from unmarked animals using Stan. Uses a similar interface to the R package 'unmarked', while providing the advantages of Bayesian inference and allowing estimation of random effects.
https://hmecology.github.io/ubms/
GNU General Public License v3.0
35 stars 8 forks source link

Allow lists as input for fitList? #60

Closed jniedballa closed 2 years ago

jniedballa commented 2 years ago

Hi Ken, would it please be possible to allow a named list of models as input for fitList, as in unmarked::fitList() via its "fits" argument? I believe it would allow for much easier (and automated) model comparison if one wouldn't have to manually add and name each model in the fitList.

# ... data preparation from github readme file

(fm <- stan_occu(~x2 ~x1 + (1|group), umf, chains=3, cores=3))

The following works as expected:

 fl1 <- fitList(mod1 = fm, 
                mod2 = fm)
  modSel(fl1)

Providing a list as input fails (and seems to use unmarked::fitList, despite asking for ubms::fitList):

modList <- list(modelname1 = fm, 
                modelname2 = fm)
fl2 <- ubms::fitList(modList)
Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘getData’ for signature ‘"ubmsFitOccu"’
In addition: Warning message:
In unmarked::fitList(...) :
  If supplying a list of fits, use fits = 'mylist'
kenkellner commented 2 years ago

Added in 95640cd.