開始使用免費開始

Poisson 比率參數的推論

再次回顧以平日狀態 \(X\)i 與溫度 \(Z\)i 建模流量 \(Y\)i 的貝葉斯 Poisson 迴歸模型之概似結構:

\(Y\)i \(\sim Pois(l\)i),其中 \(l\)i\( \; = exp(a + b \; X\)i \(+ c \; Z\)i\()\)

你在工作空間中已有針對此模型後驗分佈所做的 10,000 次 RJAGS 模擬 poisson_sim,以及其對應的馬可夫鏈輸出資料框:

> head(poisson_chains, 2)
         a b.1.       b.2.          c
1 5.019807    0 -0.1222143 0.01405269
2 5.018642    0 -0.1217608 0.01407691

使用這 10,000 組參數 $a$、$b$、\(c\) 的後驗可能值,你將對「80 度」天氣下的典型步道流量進行推論。

本練習屬於課程

使用 RJAGS 的貝氏建模

檢視課程

練習說明

  • 針對 poisson_chains 中每一組參數值,計算 80 度週末日的典型步道流量 $l$。將這些趨勢存成新變數 l_weekend,加入 poisson_chains

  • 以同樣方式計算 80 度平日的典型步道流量。將結果存成新變數 l_weekday

  • 分別為 80 度週末日與 80 度平日的典型流量計算 95% 的後驗可信區間。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Calculate the typical volume on 80 degree weekends & 80 degree weekdays
poisson_chains <- poisson_chains %>% 
    mutate(l_weekend = exp(___ + ___ * 80)) %>% 
    mutate(l_weekday = exp(___ + ___ + ___ * 80))

# Construct a 95% CI for typical volume on 80 degree weekend


# Construct a 95% CI for typical volume on 80 degree weekday
編輯並執行程式碼