Hi,

I would like to know if it is possible to specify a regression in brms that has a submodel for one (or more) of the predictors. In my example, I want to predict PM2.5 (air pollution), and for this example just with wind speed as a predictor variable. PM2.5 is a mean daily (24 hr) value. For wind speed, I have hourly values. So there are 24 hourly values associated with the mean daily PM2.5 value.

Instead of just summarizing the wind values, I would like to be able to have main level of the model that relates wind to PM2.5, and a sub-model in which a representative daily value for wind speed is drawn from the distribution of hourly values for a day.

I have done a similar things using JAGS and runjags in R before, but wondering if this is possible in brms and what the syntax would be. Below is an example of the the JAGS code that I would use for this. Thanks for any assistance with this.

Michael

JAGS.code ← "

model{

#Submodel for wind

for (i in 1:length(wind)) {

wind[i] ~ dnorm(mu.wind[dayid[i]], phi.wind[dayid[i]])

}

#wind priors for each day

for (i in 1:max(dayid)) {

mu.wind[i] ~ dexp(1/mu0)

phi.wind[i] ~ dexp(1/phi0)

}

#regression

for (i in 1:max(dayid)) {

pm[i]~dnorm(mu.pm[i], z.prec)

mu.pm[i]<-b0+b1*mu.wind[i]

}

#priors for regression parameters

b0~dnorm(0, 1)

b1~ dnorm(0, 1)

z.sd ~ dexp(1)

z.prec ← pow(z.sd, -2)

#Top level priors

phi0~dexp(1)

mu0~dexp(1)

}"