Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Test flexible vs equidistant models for wine data
- require(ordinal)
- require(brms)
- require(ggpubr) # Only needed for plotting
- # Wine flexible
- wineF <- brm(rating ~ temp + (1|judge), data = wine,
- family = cumulative(threshold = "flexible"),
- chains = 2, cores = 2, iter=4000)
- # Wine equidistant
- wineE <- brm(rating ~ temp + (1|judge), data = wine,
- family = cumulative(threshold = "equidistant"),
- chains = 2, cores = 2, iter=4000)
- # Visually compare equi and flexi
- library(ggplot2); theme_set(theme_classic())
- plotF <- pp_check(wineF, type = "bars", ndraws = 500)
- plotE <- pp_check(wineE, type = "bars", ndraws = 500)
- plotE <- plotE+ ylab(NULL)
- # Combine
- figure <- ggarrange(plotF, plotE,
- labels = c("Flexible", "Equidistant"),
- ncol = 2, nrow = 1,
- common.legend = TRUE, legend = "bottom")
- figure
- # Compare
- loo_wineF <- loo(wineF)
- loo_wineE <- loo(wineE)
- loo_compare(loo_wineF,loo_wineE)
Advertisement
RAW Paste Data
Copied
Advertisement