When I add a varying intercept to stan_gamm4, suddenly
"Error in sampler$call_sampler(args_list[[i]]) : "  " c++ exception (unknown reason)" and
Stan model 'continuous' does not contain samples.
Here’s some code to reproduce the problem on my machine (I’m aware this model doesn’t answer a real-world problem–I’m just trying to demonstrate the issue with minimal code).
library(tidyverse) library(rstanarm) data <- read_csv("https://projects.fivethirtyeight.com/polls-page/president_polls.csv") #convert date to a numeric variable data$julian <- scale(julian(as.Date(data$end_date, format = "%m/%d/%y"))) fit <- stan_gamm4(pct ~ s(julian), random=~(1|pollster), data=data)
Even in the same R session, the model runs fine when I drop the random effect, and the
brms equivalent of the model runs fine as well:
# This runs (with 1 divergent transition) fit <- stan_gamm4(pct ~ s(julian), data=data) # This runs too (with 82 divergent transitions) library(brms) fit <- brm(pct ~ s(julian) + (1|pollster), data=data)
So I wonder if this is a bug with
rstanarm? I’d appreciate any trouble-shooting advice you can give.
- Operating System: OS Catalina 10.15.3
- rstanarm Version: 2.19.2