19.12 Group specific parameters
- Climb model 2:
\[ log(\frac{\pi_{ijk}}{1-\pi_{ijk}})=(\beta_0 + b_{0j} + p_{0k}) + \beta_1 X_{ijk1} + \beta_2 X_{ijk2} \]
- For each of the 200 sampled expeditions and 46 sampled peaks, we have associated posterior distributions for the \(b_{0j}\) and \(p_{0k}\)
group_levels_2 <- tidy(climb_model_2, effects = "ran_vals") %>%
select(level, group, estimate)- Example tweaks for peaks:
group_levels_2 %>%
filter(group == "peak_name") %>%
head(2)# A tibble: 2 × 3
level group estimate
<chr> <chr> <dbl>
1 Ama_Dablam peak_name 2.91
2 Annapurna_I peak_name -2.05
- Example tweaks for expedition:
group_levels_2 %>%
filter(group == "expedition_id") %>%
head(2)# A tibble: 2 × 3
level group estimate
<chr> <chr> <dbl>
1 AMAD03107 expedition_id -0.00442
2 AMAD03327 expedition_id 3.36
- For example, to predict success probability for a climber new expedition to an existing peak (say Ama_Dablam, an ‘easy one’), we would would use \(b=0\) and the appropriate \(p_{0j}=2.91\). If the climber were 30 years old but did not plan to use oxygen:
logit_p = -1.53 + 2.91 - .0474*30
invlogit(logit_p)## [1] 0.4895015
49% chance of success. Could also use posterior_prediction
new_expedition <- data.frame(
age = c(30), oxygen_used = c(FALSE),
expedition_id = c("new"), peak_name = c("Ama_Dablam") )
binary_prediction <- posterior_predict(climb_model_2, newdata = new_expedition)
mean(binary_prediction)
# [1] 0.49425If they did use oxygen:
logit_p = -1.53 + 2.91 - .0474*30 + 6.2
invlogit(logit_p)## [1] 0.997888
With prediction:
new_expedition <- data.frame(
age = c(30), oxygen_used = c(TRUE),
expedition_id = c("new"), peak_name = c("Ama_Dablam") )
binary_prediction <- posterior_predict(climb_model_2, newdata = new_expedition)
mean(binary_prediction)
# [1] 0.95185Why different? invlogit is nonlinear (but monotonic)