BRM model compiling but returning model object

Viewed 443

I am building a hierarchical model using the BRMS package in R, and having trouble fitting a model successfully. When running the code it outputs "Compiling Stan program...", runs for about five minutes, and then stops. There are no other messages or errors, but there is no model object.

Some reproducible code from an example online, though I imagine this is not code related since the same issue occurs in my model and this one downloaded from a tutorial. When running the following code the only console output is:

Compiling Stan program...
> 
> summary(interceptonlymodeltest)
Error in summary(interceptonlymodeltest) : 
  object 'interceptonlymodeltest' not found


# Reproducible code
library(brms) # for the analysis
        library(haven) # to load the SPSS .sav file
        library(tidyverse) # needed for data manipulation.
        library(RColorBrewer) # needed for some extra colours in one of the graphs
        library(ggmcmc)
        library(ggthemes)
        library(ggridges)
        
        popular2data <- read_sav(file = "https://github.com/MultiLevelAnalysis/Datasets-third-edition-Multilevel-book/blob/master/chapter%202/popularity/SPSS/popular2.sav?raw=true")
        
        interceptonlymodeltest <- brm(popular ~ 1 + (1 | class), 
                                      data   = popular2data, 
                                      warmup = 100, 
                                      iter   = 200, 
                                      chains = 2, 
                                      inits  = "random",
                                      cores  = 2)  #the cores function tells STAN to make use of 2 CPU cores simultaneously instead of just 1.
        
        summary(interceptonlymodeltest)

I uninstalled and reinstalled r and rtools, as well as brms and all of its dependencies. Running find_rtools() from the devtools package returns TRUE, so as far as I can tell everything with the installation of the packages is squared away.

Any and all help is appreciated!

2 Answers

After more digging, it turns out this is a bug introduced in the latest release of rstan (v 2.21.1), reverting back to the last version (2.19.3) has solved the issue for me.

I just tried to downgrade to 2.19.3 (it didn't work) and then upgraded again to last release (2.21.2). It still didn't work. Turns out, in my family argument, adding link = "identity" made the model start sampling. family = gaussian(link="identity") Originally, my code was family = gaussian(). After reading the documentation, I learned that "By default, a linear gaussian model is applied" (brm function documentation). So I just do not specify the family anymore. I still do not understand why family = gaussian() does not work, however.

Related