# # example code to compute the models of figure 7 of # Einhäuser, W., & Nuthmann, A. (2016). Salient in space, salient in time: Fixation probability predicts fixation duration during natural scene viewing. Journal of Vision, 16(11):13, 117, doi:10.1167/16.11.13. # # see readme.txt for details # # load library library(lme4) # clear workspace rm(list = ls()) # load the data load("usedData.Rdata") #names of the empirical maps empMapList<-c("empMapFromC1","empMapFromC2","empMapFromC3","empMapFromC4","empMapFromC5","empMapFromC6") #loop over the 6 conditions (to be predicted) for (k in 1:6){ # only keep data that belongs to the current condition currentIdx<-which(data$condNum==k) currentData<-data[currentIdx,] #counter for the empirical maps count<-0 #center and scale (z-score) the predictors currentData$zLUM<-scale(currentData$LUM,center=TRUE,scale=TRUE) currentData$zLCG<-scale(currentData$LCG,center=TRUE,scale=TRUE) currentData$zED<-scale(currentData$ED,center=TRUE,scale=TRUE) currentData$zECC<-scale(currentData$ECC,center=TRUE,scale=TRUE) # main loop for (empMapName in empMapList){ #counter count<-count+1 # output cat("\n\nEmpMap ",count," (",empMapName,") predicts condition ",k,"\n") # center and scale the current map, copy to empMap field currentData$"empMap"<-scale(currentData[[empMapName]],center=TRUE,scale=TRUE) # compute the model model<-lmer(fixDur ~ empMap+zLUM+zLCG+zED+zECC + (1+empMap|obsNum) + (1+empMap|imgNum) + (0+zLUM|obsNum) + (0+zLUM|imgNum) + (0+zLCG|obsNum) + (0+zLCG|imgNum) + (0+zED|obsNum) + (0+zED|imgNum) + (0+zECC|obsNum) + (0+zECC|imgNum), data = currentData, control=lmerControl(optimizer="bobyqa",optCtrl=list(maxfun=1e7))) # print the results print(summary(model)) # uncomment the following line, if the model shall be saved # save(file=paste("figure7_condition_",k,"_by_",empMapName,".Rdata",sep=""),list=c("model")) } }