Loo with k_threshold error for stan_polr()

Thanks. For my focal problem, of which the published code and data above are subsets, it wasn’t a big deal to restructure the order of calculations to get it to work once I figured out that loo has to follow immediately after stan_polr, so it seems to be working now. But it’s not always convenient to set things up that way, and it would be great to be certain that there isn’t something fishy happening under the hood. Again, thanks for looking into it. Let me know if you want me to test-run something.

1 Like

Ok so I made a bit of progress. I found why this is messing it up but not yet how to fix it fully. But there should be another work around: it should avoid this error if you don’t use the same name (moddef) for the formula for both models. If you use moddef2 for the second one then I think that should avoid this error. It should work either way, but I haven’t totaly fixed it yet.

Ok I think it’s actually fixed now on GitHub. We needed to make sure moddef the symbol was evaluated and converted to the actual formula before calling the update() method. Some weirdness related to nested environments and lazy evaluation.

If you reinstall from GitHub it shouldn’t matter anymore what order you run the models and the calls to loo().

Thanks for your persistence with this, it helped me track down a tricky bug. Let me know if you still think there’s something broken.

Thanks jonah, that all seems to work fine now.

1 Like