Brms::brm provides no output

Hi, this is the first time that I use brms. When I try to run my model, R prints the message Compiling stan program.... It appears to be instantly done running and nothing happens. There is no error message or anything and no object is created within the session.

> brm_model <-
   brms::brm(err_count ~ time + (1|participant) + (1|item) + (1|participant:item),
             data = trial_data,
             family = zero_inflated_poisson())

Compiling Stan program...

What might be the problem here? I use brms version ‎2.13.3, R version 4.0.x, and Windows 10. I have set up rtools40, as well.

Thank you for your help!

I would suspect the underlying Stan/rstan installation has gone awry, you can test it by running example(stan_model, package = "rstan", run.dontrun = TRUE).

If you get errors when running the above code, I would check the answers in this thread: Rstan on Windows.

You could also maybe try installing cmdstanr and then specifying backend = "cmdstanr" in the call. I’m not a Windows user so am not sure this would work, but it’s worth a shot.

2 Likes

I am actually having the same problem with both RStan and cmdstanr backends. It seems to fail when there’s a compilation error, but it doesn’t return whatever the error was.

Example:

library(data.table)
library(brms)

garbage_data <- data.table("x" = c(1,2,3),
                           "y" = c(2,5,4))

garbage_model_runs <- brm(y ~ 1 + x,
                          data = garbage_data,
                          family = "gaussian",
                          prior = c(prior(normal(0,4), class = "Intercept")),
                          chains = 4,
                          cores = 4,
                          backend = "cmdstanr")

This model compiles and runs successfully. However, if I intentionally misspell the prior:

garbage_model_fails <- brm(y ~ 1 + x,
                          data = garbage_data,
                          family = "gaussian",
                          prior = c(prior(not_a_distribution(0,4), class = "Intercept")),
                          chains = 4,
                          cores = 4,
                          backend = "cmdstanr")

This does the “/” animation for a bit, then just returns to the console silently with no error message from cmdstanr. Changing the backend to RStan results in the same behavior as described by the OP.

I’ve tried a couple clean installs of Rtools40, R 4.0.2, RStudio 1.3.1056 and the latest versions (github) of brms on Windows 10, with the same results. Models that are properly written compile and run; those with errors don’t return any error output.

It probably is brms suppressing this information accidentally. Will see if there is something I can do.

The relevant error messages should no longer be suppressed in the brms github version.