rm(list=ls(all=TRUE)) # clear all variables
graphics.off() # clear all graphics
# Visual Search
# Greg Francis
# PSY 646
# 27 September 2018
# fit a linear model that predicts response time as a function of the number of distractors
# To look at issues of divergence
# load full data file
VSdata<-read.csv(file="VisualSearch.csv",header=TRUE,stringsAsFactors=FALSE)
# Pull out just the trials for the first participant's conjunctive condition (includes Target present and Target absent)
VSdata2<-subset(VSdata, VSdata$Participant=="Francis200S16-2" & VSdata$DistractorType=="Conjunction")
# load the brms library
library(brms)
#-----------------
# Build a model using an exgaussian rather than a gaussian (better for response times)
model4 <- brm(RT_ms ~ Target*NumberDistractors, family = exgaussian(link = "identity"), data = VSdata2, iter = 8000, warmup = 2000, chains = 3)
# print out summary of model
print(summary(model4))
# Adjust adapt_delta
model5 <- brm(RT_ms ~ Target*NumberDistractors, family = exgaussian(link = "identity"), data = VSdata2, iter = 8000, warmup = 2000, chains = 3, control = list(adapt_delta = 0.99))
# print out summary of model
print(summary(model5))
# Add some priors to see if it helps
# Build a model using an exgaussian rather than a gaussian (better for response times)
model6 <- brm(RT_ms ~ Target*NumberDistractors, family = exgaussian(link = "identity"), data = VSdata2, iter = 8000, warmup = 2000, chains = 3, prior = c(prior(normal(1000, 100), class = "Intercept"), prior(normal(0, 50), class = "b")) )
# print out summary of model
print(summary(model6))
# Use the full data set
VSdata2<-subset(VSdata, VSdata$DistractorType=="Conjunction")
model7 <- brm(RT_ms ~ Target*NumberDistractors, family = exgaussian(link = "identity"), data = VSdata2, iter = 8000, warmup = 2000, chains = 3)
print(summary(model7))