Advertisement
Guest User

Untitled

a guest
May 28th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.80 KB | None | 0 0
  1. ### This script calculates accuracy for each duration for Lukowska 2018
  2. ### Using rstanarm and leave one out cv (on a participant level)
  3. setwd("/home/delpin/Documents/Work/SdtModel/DatafromOthers")
  4. library("lme4")
  5. library("rstanarm")
  6. library("loo")
  7. options(mc.cores = parallel::detectCores())
  8.  
  9. # Clear workspace
  10. rm(list=ls())
  11.  
  12. # load data
  13. data <- read.csv2("E1_gbr.csv")
  14.  
  15. # How many participants?
  16. nrparticipants <- length(unique(data$id))
  17.  
  18. # Define null model
  19. rtm0 <- stan_glmer(rt~+(1|id),
  20.                  data=data, family=gaussian)
  21.  
  22. # Define model with one predictor
  23. rtm1 <- update(rtm0,.~.+acc)
  24.  
  25. ### Compare with classic loo
  26. loo_rtm0 <- loo(rtm0)
  27. loo_rtm1 <- loo(rtm1)
  28. compare(loo_rtm0,loo_rtm1)
  29.  
  30. ### Compare with grouped k-fold cv
  31. kfold_split_stratified(K = nrparticipants, x = data$id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement