strengejacke / sjstats

Effect size measures and significance tests
https://strengejacke.github.io/sjstats
189 stars 21 forks source link

Loo-adjusted R2 warning: In ypredloo - y : longer object length is not a multiple of shorter object length #50

Closed DominiqueMakowski closed 6 years ago

DominiqueMakowski commented 6 years ago

I have the following warning when extracting loo adjusted r2. Any idea why? Thanks a lot 😃

Warning message:
In ypredloo - y :
  longer object length is not a multiple of shorter object length

The data is attached and the code is the following:

library(rstanarm)

df <- read.table("df.txt")
fit <- stan_lmer(y ~ group / poly(x, 2) +
                   (1|r1) + (1|r2),
                 data=df, seed=6, QR=TRUE)
sjstats::r2(fit, loo=TRUE)
strengejacke commented 6 years ago

Should be fixed, though I'm not sure why there's a difference between the lengh of y (values from the response) and the length of ypredloo (the predicted values for the response). Maybe it's not possible to predict all values for the response properly in your model?

strengejacke commented 6 years ago
ncol(posterior_linpred(fit))
#> [1] 3963