stan-dev / stan-dev/rstanarm

Including all remaining variables via "." operator gives error in stan_gamm4

Open
#307 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug minor bug
Dominant language
R
Stars
401
Forks
136
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied stan_gamm4 reproducible example and trace how its formula is processed when the data argument contains '.'. Compare the behavior with stan_glm, which does not reproduce the error. Done means the example runs successfully with the '.' operator without the terms.formula error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.