0

I've been trying to run a binomial MCMC model through rethinking::ulam() using beta priors (0.5,5), but the resulting posterior prediction density plots start from 0.5 on the x axis, rather than 0. For some background context, my data is in the format of binary animal behaviour observations, where I've recorded instances of uncommon behaviours using instantaneous sampling every 30 seconds (i.e. a lot of zeros, and a few 1s). I'm not very familiar with beta distributions, but something like dbeta(0.5, 5) seems like it would lean more towards zero, which makes more sense for my data than a flat normal prior.

For all other prior predictive checks I've ever carried out in ulam(), the density plot scale starts from zero. However, seemingly in this case only, the plot starts from 0.5 and the probability is heaped around 0.5, even if I change the first shape parameter to something else. However, when I run a simulated distribution with the same shape (0.5,5), it looks as expected.

I have run out of ideas, so any help would be hugely appreciated!

Below is a simplified version of my model, using the beta distribution for my prior (to install the rethinking package, see:

https://www.rdocumentation.org/packages/rethinking/versions/2.13

library(rethinking)

# Dummy data
behaviour <- rbinom(39, 1, 0.1)
data <- list(behaviour = behaviour)

# Model structure
model <- ulam(alist(
  behaviour ~ dbinom(1, p),
  logit(p) <- a,
  a ~ dbeta(0.5, 5)),
  data = data, chains = 4, cores = 4, log_lik = TRUE)

The density plot of the prior distribution starts from 0.5 on the x axis, like this:

Density plot of prior distribution

# Extracting prior
set.seed(1999)
prior <- extract.prior(model, n = 1e4)

# Converting parameter to the outcome scale
p <- inv_logit(prior$a)

# Density plot of prior distribution
dens(p, adj = 0.1) 

However, the distribution should look like this (simulated data), starting from 0 on the x axis:

Simulated beta distribution

dens(rbeta(1000, 0.5, 5))
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Lelia BS
  • 1
  • 3

0 Answers0