LOO error with a brmsfit model

Hello,

Very new to this Forum, and Bayesian analyses too, but learning a lot from the discussions here!

Im trying to do a model selection with loo, based on brmsfit models, but in some of them i’m getting these kind of errors:

loo.m1.3.3_arvoreta<-loo(m1.3.3_arvoreta,reloo=TRUE)
1 problematic observation(s) found.
The model will be refit 1 times.

Fitting model 1 out of 1 (leaving out observation 2)
Start sampling
Error in if (p.rank > ncol(object$X)) p.rank ← ncol(object$X) :
argument is of length zero

An this is the model code:

prior_1.3.3<-c(prior(normal(1,1),class=Intercept),
prior(normal(0,1), class = b),
prior(normal(0,1), class = Intercept,dpar=sigma),
prior(normal(0,1), class = sds),
prior(normal(0,.1), group = area, class = sd))

form1.3.3=bf(arvoreta~s(parcela) +(1|area))+lf(sigma~1,hu~1)

m1.3.3_arvoreta<-brm(form1.3.3,file=“m1.3.3_arvoreta”,sample_prior=“yes”,control = list(adapt_delta = 0.999, max_treedepth=15),
data=data.areabasal,family=hurdle_lognormal(),iter=10000, prior=prior_1.3.3)

Does anyone have an idea of what was my mistake?

Thanks in advance !

Operating System: Windows 10 x64 (build 17134)
Interface Version: loo_2.0.0 , brms_2.4.0

Could you try out brms 2.5.0 from CRAN and if that doesn’t work the dev version from github (https://github.com/paul-buerkner).

I believe this problem should be fixed already in at least the dev version.

It sounds from the error message like when you leave some observation out, it makes the design matrix rank deficient. If so, then almost by definition, the k-hat is going to be too large for that observation.

Thanks a lot for the quick answer!
It’s working normally now, with the brms 2.5.0.