rstanarm
rstanarm copied to clipboard
Including all remaining variables via "." operator gives error in stan_gamm4
I get the following error if I use the "." operator to include all remaining variables in stan_gamm4:
Error in terms.formula(gf, specials = c("s", "te", "ti", "t2", extra.special)) :
'.' in formula and no 'data' argument
Reproducible example:
dat <- mgcv::gamSim(1, n = 400, scale = 2) ## simulate 4 term additive truth
dat$fac <- fac <- as.factor(sample(1:20, 400, replace = TRUE))
dat$y <- dat$y + model.matrix(~ fac - 1) %*% rnorm(20) * .5
br <- stan_gamm4(y ~ s(x0) + s(x2) + . ,
data = dat, random = ~ (1 | fac),
chains = 1, iter = 200) # for example speed
I checked for other functions such as stan_glm and the error does not happen. Is any version of rstanarm where this error is resolved?
Hi all,
I think that the issue is located on the function mgcv::interpret.gam
which is called on the evaluation of the formula I will have a look on that one and see if I can solve it.
Or perhaps mgcv::jagam
On Fri, Jul 27, 2018 at 5:19 AM Carlos Serra Traynor < [email protected]> wrote:
Hi all,
I do think that the issue is located on the function mgcv::interpret.gam I will have a look on that one and see if I can solve it.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/stan-dev/rstanarm/issues/307#issuecomment-408362761, or mute the thread https://github.com/notifications/unsubscribe-auth/ADOrqk8OkZz44KGCnU6W_Jfcj_fsk9FHks5uKtsEgaJpZM4Vh_-F .
This is happening to me also with gamm4::gamm4
so I think it is something that would have to be addressed in the mgcv package somewhere in
4: terms.formula(gf, specials = c("s", "te", "ti", "t2", extra.special))
3: interpret.gam0(gf, extra.special = extra.special)
2: interpret.gam(formula)
1: gamm4::gamm4(y ~ s(x0) + s(x2) + ., data = dat, random = ~(1 |
fac))
Yes, it woud be helpful that worked as in the usual sense of adding all the remaining variables as fixed effects. Could not find the solution to it though. Plus, sincerely, I duplicated this post in stack but without replies so far: https://stackoverflow.com/questions/51560274/how-could-the-gam-function-be-modified-to-accept-all-remaining-variables-via
I will also try to understand the code of mgcv::jagam to see if there is something there that could be addressed in both functions.
I just experienced the same error. I think we should throw an informative error if .
is used until this is sorted out in mgcv.