Challenge with Formula Syntax


#1

I am attempting to apply a Bayesian mixed model to estimate the impact of temperature on a home’s energy consumption.

priors <- c(set_prior("lognormal(0.01494647, 0.00937701)", class = "b", coef = "Temp"))

ins_month <- brm(use ~ Temp + (1+Temp|Month.f), 
                              data = dpa.ins.home, family = gaussian(link="log"), warmup = 100, iter = 200, chains = 2, inits = "random", control = list(adapt_delta = .95, max_treedepth = 12),
                              prior = priors, cores = 2, sample_prior = TRUE))

While I am comfortable with mixed-effects regression formulation, I am struggling with the details of the brms formula syntax specifically the priors and families . With the below information am I using priors and families correctly?

energy_use has a beta distribution

> descdist(ACH_test$use)
summary statistics
----------
min:  0.1473333   max:  10.4126 
median:  0.6733333 
mean:  1.349991 
estimated sd:  1.475063 
estimated skewness:  1.857041 
estimated kurtosis:  6.252937 

The prior for Temp is closes to a lognormal distribution

> descdist(temp$T.Impact)
summary statistics
------
min:  0   max:  0.1714414 
median:  0.01265037 
mean:  0.01494647 
estimated sd:  0.009377701 
estimated skewness:  2.071458 
estimated kurtosis:  12.71367 
  • Operating System: Windows 10
  • brms Version:

#2

The formula syntax isn’t needed for priors or families. How you defined the prior there looks correct. You can check what the model used by using prior_summary() on the model.

You say that use has a beta distribution, but the model code family = gaussian(link="log")uses a gaussian family with a log link. To use the beta family, you should use Beta(). See ?brms::brmsfamily for a description of the supported families.