开始使用免费开始使用

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.

本练习是课程的一部分

Bayesian Modeling with RJAGS

查看课程

练习说明

  • 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.

交互式实操练习

通过完成这段示例代码来试试这个练习。

# 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(___)
编辑并运行代码