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

indexing off #69

Closed bgoodri closed 1 year ago

bgoodri commented 1 year ago

An issue was exposed when I was trying to upload a new major version of StanHeaders to CRAN, but actually the issue is present (albeit not being caught) with the ubms / StanHeaders on CRAN currently,

If you add lines to the effect of

  if (nb != cols(pars)) {
    print("pars = ");
    for (n in 1:rows(pars)) print(pars[n, ]);
    print ("dist = ", dist);
    print("beta = ");
    print(beta);
    print("idx = ", idx);
    print("nb = ", nb);
}

in the lp_priors function in ubms/inst/stan/include/functions_priors.stan , your examples and vignettes will run but output things like

pars = 
[0,1]
[1,1]
[0,0]
dist = [4,0,5]
beta = 
[-4.00449]
idx = 2
nb = 1

In other words, idx:nb evaluates to 2:1, which is not a valid index in the Stan language and is not correct logic for subsetting beta and pars anyways. The new StanHeaders catches this, but unfortunately this issue is one of the few things preventing the StanHeaders from making its way to CRAN.

If you could fix this as soon as possible, that would be great.

kenkellner commented 1 year ago

Very sorry to be holding things up.

I was able to replicate the issue with the new StanHeaders installed. I have a fix in 36a3cc2. Everything seems to be working now - if you are able to confirm on your end that would be great. I have to clean up a couple other small issues first but should be able to submit to CRAN in the next day or two.

bgoodri commented 1 year ago

CRAN went with the new StanHeaders so ubms is not working on CRAN at the moment, but ubms is fine with the latest commits.

kenkellner commented 1 year ago

ubms 1.2.3 is now on CRAN with the fix, thanks for your help with this.