I’m running into an error message that I don’t understand and can’t find an answer for online when running a binomial regression model using `rstanarm`

and then trying to use some functions from the R package `projpred`

. I can’t share the data, but my best guess is that there’s a minor issue with the data I’m using that’s causing some issues. I’m following the approach detailed here: https://mc-stan.org/projpred/articles/quickstart.html

The model runs fine:

```
n <- 227
D <- 27
p0 <- 5 # prior guess for the number of relevant variables
tau0 <- p0/(D-p0) * 1/sqrt(n)
prior_coeff <- hs(global_scale = tau0, slab_scale = 1) # regularized horseshoe prior
binregcov <- stan_glm(formula = cbind(PresenceTotal, NumberOfSamples - PresenceTotal)~., family = binomial(link="logit"), prior = prior_coeff,
data = NTMgrouped%>%dplyr::select(-landcover3))
```

But then once I try:

```
cvs <- cv_varsel(binregcov, method='forward', cv_method='kfold', K=5)
```

I get the following error:

```
STATS is longer than the extent of 'dim(x)[MARGIN]'Error in dimnames(x) <- dn :
length of 'dimnames' [2] not equal to array extent
```

There are only 227 observations and 27 covariate values, some categorical variables, etc. I can run the examples provided here https://mc-stan.org/projpred/articles/quickstart.html, but it’s not quite working out with my data. Perhaps it’s not the best data set for this, but I wanted to try it out anyway.

Has anyone come across this error message before?