Get startedGet started for free

Poisson posterior prediction

Your l_weekday variable reflects the trend in volume on 80 degree weekdays:

> head(poisson_chains, 2)
       a b.1.    b.2.      c l_weekend l_weekday
1 5.0198    0 -0.1222 0.0141   465.924   412.324
2 5.0186    0 -0.1218 0.0141   466.284   412.829

Now that you understand the trend, let's make some predictions! Specifically, let's predict trail volumes on the next 80 degree weekday. To do so, you must take into account individual variability from the trend, modeled by the likelihood \(Y\)i \(\sim Pois(l\)i).

Using rpois(n, lambda) for sample size n and rate parameter lambda, you will simulate Poisson predictions of volume under each value of the posterior plausible trend in poisson_chains.

This exercise is part of the course

Bayesian Modeling with RJAGS

View Course

Exercise instructions

  • From each of the 10,000 l_weekday values in poisson_chains, use rpois() to predict volume on an 80 degree weekday. Store these as Y_weekday in poisson_chains.
  • Use ggplot() to construct a density plot of your Y_weekday predictions.
  • Approximate the posterior probability that the volume on an 80 degree weekday is less than 400 users.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Simulate weekday predictions under each parameter set
poisson_chains <- poisson_chains %>% 
    mutate(Y_weekday = rpois(n = ___, lambda = ___))
    
# Construct a density plot of the posterior weekday predictions
ggplot(___, aes(x = ___)) + 
    geom_density()
    
# Posterior probability that weekday volume is less 400
mean(___)
Edit and Run Code