Specification of scaling factor in brms BYM2 model

Hi Stan community,

I’m relatively new to the syntax of brms, and unfortunately I can’t find any information about this on the page detailing how to specify a CAR term within a brms model.

I am trying to specify a BYM2 model (a variant of the ICAR model) in brms. This is relatively easy to do as detailed here: Spatial conditional autoregressive (CAR) structures — car • brms

Following the guide, I set such a term in my model. Since it’s complex, I’m using a simplified example here. (In my actual model I do specify gr in my CAR term).

For the example, I’m using the same setup as in the guide linked above, except I generate a dummy count variable for the response and set family=poisson(). I set the priors for rhocar and sdcar according to the case studies that the BYM2 model in brms is based on: Spatial Models in Stan: Intrinsic Auto-Regressive Models for Areal Data

However, the article also mentions a scaling factor, and I’m wondering whether I need to set this myself in the model. I tried two ways of doing so, both of which returned the error that car_scale is not a recognised argument. (I named it car_scale because after calling make_stancode, I saw that the underlying Stan code has an argument named car_scale for setting this parameter).

library(brms)

east <- north <- 1:10
Grid <- expand.grid(east, north)
K <- nrow(Grid)

# set up distance and neighbourhood matrices
distance <- as.matrix(dist(Grid))
W <- array(0, c(K, K))
W[distance == 1] <- 1   

# generate the covariate and response data
x <- rnorm(K)

lambda <- 4
y <- rpois(K,lambda)

df <- data.frame(y,x)

prior_bym <- c(prior(normal(0,5), class=Intercept),
               prior(normal(0,1),class=b,coef="x"),
               prior(beta(0.5,0.5),class=rhocar),
               prior(exponential(1),class=sdcar) 
)


fit <- brm(y ~ x + car(W, type="bym2"), 
           data = df, data2 = list(W = W),
           family = poisson(),
           prior = prior_bym,
           iter = 500, warmup = 200, chains = 2, # some arbitrary amount
           control = list(adapt_delta=0.95, max_treedepth=20)
) 

So far, I have tried to set car_scale = scaling factor in the CAR term, but without success:

scaling_factor = 0.5 # just an example

fit <- brm(y ~ x + car(W, type="bym2",car_scale = scaling_factor), # doesn't work
           data = df, data2 = list(W = W),
           family = poisson(),
           prior = prior_bym,
           iter = 500, warmup = 200, chains = 2, # some arbitrary amount
           control = list(adapt_delta=0.95, max_treedepth=20)
) 

I also tried setting it in brm, likewise without success:

fit <- brm(y ~ x + car(W, type="bym2"), 
           data = df, data2 = list(W = W),
           car_scale = scaling_factor, # doesn't work
           family = poisson(),
           prior = prior_bym,
           iter = 500, warmup = 200, chains = 2, # some arbitrary amount
           control = list(adapt_delta=0.95, max_treedepth=20)
) 

My question is:

  1. Can I set the scaling factor myself and if so, how?
  2. If this is not supported yet, is the scaling factor calculated automatically?

Thank you so much for your help, and I hope the information I provided was adequate.