Closed fweber144 closed 8 months ago
Thanks for letting us know, that's not good. I debugged this just now and it seems to happen at this line
https://github.com/stan-dev/rstanarm/blob/a9889e6237a113cd17c387540e7f825b74211f85/R/pp_data.R#L232
which means it's when ranef is called. This is actually a gamm4 issue because it happens even outside of rstanarm when calling ranef on a gamm4 object:
ranef(gamm4(y ~ s(x0) + x1 + s(x2), data = dat, random = ~ (1 | fac)))
gives me the same error. So I think this needs to be fixed in gamm4. @bgoodri @avehtari it doesn't look like gamm4 has a GitHub repo, so we can send the maintainer an email.
Here's the reproducible example without rstanarm
library(gamm4)
nobs <- 400
ngrp <- 20
dat <- mgcv::gamSim(1, n = nobs, scale = 2)
dat$fac <- as.factor(sample.int(ngrp, size = nobs, replace = TRUE))
dat$y <- dat$y + model.matrix(~ fac - 1, data = dat) %*% rnorm(ngrp) * 0.5
fit <- gamm4(y ~ s(x0) + x1 + s(x2), data = dat, random = ~ (1 | fac))
Thanks, just sent Simon Wood an email using the email address on the CRAN page for gamm4
I corresponded with Simon and it seems like an issue with incompatible versions of lme4 and Matrix (for some reason there isn't backwards compatibility and both need to updated to the latest versions at the same time). If you update lme4 does this error go away? That got it working for me.
Hm, that's strange. At the time of my initial comment, my lme4 version was already at 1.1-35.1 (the current CRAN version) and it still is. Do you refer to the most recent GitHub version of lme4?
To be safe, I have now updated all my R packages (except for tikzDevice, but that shouldn't matter here) to their most recent CRAN versions (and StanHeaders to its most recent https://mc-stan.org/r-packages/ version, but again, that shouldn't matter here), but the issue still occurs.
Hmm, very strange. I wasn't referring to the GitHub version of lme4, just the latest CRAN version. According to Simon Wood gamm4 should work with any pair of lme4 and Matrix that are compatible with each other, but that seems not to be the case for you (although it works for me now). Not sure what's going on, but I definitely think it's related to lme4/Matrix/gamm4 and not anything specific to rstanarm.
Yes, seems to be unrelated to rstanarm. If you want, you can close this issue here.
In case someone gets hits by this and finds this issue, it's about binary incompatibility, and installing lme4
and Matrix
from source solves this (+ restart R session). See https://stackoverflow.com/questions/77481539/error-in-initializeptr-function-cholmod-factor-ldeta-not-provided-by-pack
In case someone gets hits by this and finds this issue, it's about binary incompatibility, and installing
lme4
andMatrix
from source solves this (+ restart R session). See https://stackoverflow.com/questions/77481539/error-in-initializeptr-function-cholmod-factor-ldeta-not-provided-by-pack
Thanks, works indeed.
Summary:
Calling
posterior_linpred()
on astan_gamm4()
fit errors if version 1.6-4 of the Matrix package is installed.Description:
See "Summary" above.
Reproducible Steps:
The last line succeeds with 'Matrix' v1.6-3, but errors with 'Matrix' v1.6-4:
RStanARM Version:
2.26.1 (from CRAN)
R Version:
4.3.2
Operating System:
Ubuntu 22.04.3 LTS