simondp

Ordinal ratings with high disagreement

Dec 2nd, 2021
697
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Generate data
  2. data1 <- data.frame(matrix(NA,200,2))
  3. data1[,1] <- c(1,5)
  4. data1[,2] <- 1
  5.  
  6. data2 <- data.frame(matrix(NA,200,2))
  7. data2[,1] <- 3
  8. data2[,2] <- 2
  9.  
  10. data3 <- data.frame(matrix(NA,200,2))
  11. data3[,1] <- c(2,4)
  12. data3[,2] <- 3
  13.  
  14. data1 <- rbind(data1,data2,data3)
  15. names(data1) <- c("rating","bottle")
  16. data1$rating <- ordered(data1$rating)
  17. data1$bottle <- as.factor(data1$bottle)
  18.  
  19. # Model data
  20. wineM <- brm(rating ~ bottle, data = data1,
  21.     family = cumulative(threshold = "flexible"),
  22.     chains = 2, cores = 2, iter=4000)
  23.  
  24. # Plot Average
  25. conditional_effects(wineM, categorical = F)
  26.  
  27. # Plot Categorical
  28. conditional_effects(wineM, categorical = T)
RAW Paste Data