How to fit gamma distributions with ulam?


I am brand new to Bayesian modeling and I am currently following the Statistical Rethinking course by McElreath. I am using the rethinking package for Rstudio and have been trying to apply the ulam function to fit a gamma distribution model to daily precipitation data. However, R returns an error message that there is no template distribution for dgamma. See code below.

m.2 ← ulam(
p ~ dgamma(shape, scale) ,
log(shape) ← a,
a ~ dnorm(0.5,0.2),
log(scale) ← b ,
b ~ dnorm(0.5,0.2)
), data = dat_list, chains = 1, log_lik = TRUE

Error in get_dist_template(the_dist[1]) :
No template for distribution ‘dgamma’

Can anyone provide example code for how to work with gamma distributions using the rethinking package? Also, are there any general principles to follow when assigning sensible priors to skewed distributions?


Use gamma(a, b) instead of dgamma(a, b)

Thanks. I tried changing to gamma(a, b) and now it works.

However, I am still confused about how to assign plausible priors. It is not straight forward how to interpret a and b in relation to the outcome variable.