Closed jscamac closed 4 years ago
Thanks for reporting this. It's definitely a bug. I think what is going on is that the random
argument is different from the formula
argument (unlike for stan_glmer
where the random effects are coded as part of the main formula) but this distinction is not accounted for when we do this
https://github.com/stan-dev/rstanarm/blob/9e4e46dc3538d281f588ffe25b9d43e786f57e8e/R/loo.R#L710
because the formula doesn't include fac
. This ends up resulting in fac
not being included in the dataset used to refit the models for kfold. I'm working on a fix now.
Summary:
Bug in the kfold function where it is unable to find a random effect predictor.
Description:
I've been playing around with fitting models in
rstanarm::stan_gamm4()
.The models fit fine but when I useloo
I receive warning messages suggesting I use kfold with K=10 (see MWE below). However, when I use kfold it produces an error that indicates it cannot find the random effect variable .The example below is just an example of the problem (ignore the very large number of high pareto_k.. I've chosen it just to highlight the issue.
Reproducible Steps:
RStanARM Version:
rstanarm (2.19.3) rstantools (2.0.0) loo (2.2.0)
R Version:
R 4.0.0
Operating System:
MacOS 10.14.6