Open fweber144 opened 2 years ago
There seems to be a bug in kfold.stanreg() when applied to a stan_polr() fit.
kfold.stanreg()
stan_polr()
When calling kfold.stanreg() on a stan_polr() fit, the error
Error in x$z[omitted_k, , drop = FALSE] : incorrect number of dimensions
is thrown. This is probably due to the fact that in lines https://github.com/stan-dev/rstanarm/blob/3dab09cabb4c889ae9fab2f98351757bfb267a84/R/loo-kfold.R#L196, https://github.com/stan-dev/rstanarm/blob/3dab09cabb4c889ae9fab2f98351757bfb267a84/R/loo-kfold.R#L219, and https://github.com/stan-dev/rstanarm/blob/3dab09cabb4c889ae9fab2f98351757bfb267a84/R/loo-kfold.R#L241, x$z is expanded to x$zeta.
x$z
x$zeta
options(mc.cores = parallel::detectCores(logical = FALSE)) data(inhaler, package = "brms") inhaler$rating <- paste0("rtg", inhaler$rating) library(rstanarm) rfit <- stan_polr(rating ~ period + carry + treat, data = inhaler, prior = R2(location = 0.5, what = "median"), seed = 1140350788) rkfold <- kfold(rfit, K = 2, cores = 1)
2.21.3
4.1.3
Ubuntu 20.04.4 LTS
Summary:
There seems to be a bug in
kfold.stanreg()
when applied to astan_polr()
fit.Description:
When calling
kfold.stanreg()
on astan_polr()
fit, the erroris thrown. This is probably due to the fact that in lines https://github.com/stan-dev/rstanarm/blob/3dab09cabb4c889ae9fab2f98351757bfb267a84/R/loo-kfold.R#L196, https://github.com/stan-dev/rstanarm/blob/3dab09cabb4c889ae9fab2f98351757bfb267a84/R/loo-kfold.R#L219, and https://github.com/stan-dev/rstanarm/blob/3dab09cabb4c889ae9fab2f98351757bfb267a84/R/loo-kfold.R#L241,
x$z
is expanded tox$zeta
.Reproducible Steps:
RStanARM Version:
2.21.3
R Version:
4.1.3
Operating System:
Ubuntu 20.04.4 LTS