Hi, I want to refit a simple model >18,000 times. The model estimates the mean and SD of some characteristic of a plant species based on several species-specific observations. Each time, the response variable is a new species and I set the sample mean of that species as the prior for the mean.

Is there a way to avoid recompiling if you change the response variable?

I now coded it as a for loop:

for (i in 1:N){

m1<-sample_mean[i,2]

stanvars <- stanvar(m1, name=βm1β)

bprior <- prior(normal(m1,2), class = Intercept) + prior(cauchy(0,2), class = sigma)

fit <- brm(paste(colnames(df2[i]), β~ 1β),data = df2, family = gaussian(), prior = bprior,chains=2, iter = 1000,stanvars=stanvars)

}ββ

I was first thinking of fitting a multilevel model with each species as a grouping variable, but I donβt know if thatβs feasible with 18,000 species.

FWIW

- Operating System: Windows 10
- brms Version: 2.10