Using Loo 2 for grouped k-fold cv

Ok, this is actually related to the issue in the post

although it might not seem obviously related. This should already be fixed on GitHub but until the next CRAN release you can get around the error by dropping the variables from data that you’re not using in the model (or more precisely, any variable not used in the model that also has NAs).

In your case, try this:

data <- data[, c("rt", "id", "acc")]
rtm0 <- stan_glmer(..., data = data)

nrparticipants <- length(unique(data$id))
folds <- kfold_split_stratified(K = nrparticipants, x = data$id)
kf_rtm0 <- kfold(rtm0, K = nrparticipants, folds = folds)

When the next CRAN release comes out the data <- data[, c("rt", "id", "acc")] line shouldn’t be necessary.

1 Like