Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Simulate observers
- library(brms)
- obs <- 16 # How many observers?
- trials <- 70 # How many trials per filter
- # Plausible ratings
- high <- c(rep(2,8),rep(3,27),rep(4,25),rep(5,10))
- med <- c(rep(1,4),rep(2,22),rep(3,32),rep(4,11),rep(5,2))
- low <- c(rep(1,15),rep(2,31),rep(3,16),rep(4,4))
- set.seed(42) # Set seed for reproducibility
- # All observers like the non-filtered equally
- filterNon <- sample(high, trials*obs, replace = T)
- # Half observers dislike one filter particularly
- filterBad <- sample(low, trials*(obs/2), replace = T)
- # Rest of observers dislike filters equally
- filterMed <- sample(med, trials*(obs*1.5), replace = T)
- # Create data frame
- ratings <- c(filterNon,filterBad,filterMed)
- filter <- sort(rep(c("0: None","1: Bad","2: Medium"),obs*trials))
- id <- factor(rep(sort(rep(1:obs,trials)),3))
- results <- data.frame(ratings,filter,id)
- # Create brms model
- results$rating <- ordered(results$ratings)
- # Rating for each filter, random effect per id
- mfilter <- brm(rating ~ filter + (filter|id), data = results,
- family = cumulative(threshold = "flexible"),
- chains = 2, cores = 2, iter=3000)
- # Plot each observer as understood by model
- conditional_effects(mfilter)
- consub <- make_conditions(results, vars = c("id"))
- # Look at categorical model
- conditional_effects(
- mfilter,
- "filter",
- conditions = consub,
- re_formula = NULL, categorical = F
- )
- # EXPERIMENT 2
- set.seed(101) # Set seed for reproducibility
- # All observers like the non-filtered equally
- filterNon2 <- sample(high, trials*obs, replace = T)
- # Half observers dislike one filter particularly
- filterBad2 <- sample(low, trials*(obs/2), replace = T)
- # Rest of observers dislike filters equally
- filterMed2 <- sample(med, trials*(obs*1.5), replace = T)
- # Create data frame for exp 2
- ratings <- c(filterNon2,filterBad2,filterMed2)
- results2 <- data.frame(ratings,filter,id)
- results2$rating <- ordered(results2$ratings)
- # Model Exp 2
- # How to compare with Exp 1?
Advertisement
Add Comment
Please, Sign In to add comment