###################################################################### #    DISCLAIMER #    This program is free software; you can redistribute it and/or modify #    it under the terms of the GNU General Public License as published by #    the Free Software Foundation; either version 2 of the License, or #    (at your option) any later version. # #    This program is distributed in the hope that it will be useful, #    but WITHOUT ANY WARRANTY; without even the implied warranty of #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the #    GNU General Public License for more details. # ###################################################################### # #    The R code below was tested on R version 2.10.0 # September 2010 # # Analyses and figures for the study: # # Hohenstein, S., Laubrock, J., & Kliegl, R. (2010). # Semantic preview benefit during eye movements in reading: A parafoveal fast-priming study. # Journal of Experimental Psychology: Learning, Memory, and Cognition, 36, 1150-1170. require(lme4) # for statistical analyses require(ggplot2) # for plotting rm(list = ls()) #### load data load('Hohenstein_et_al.2010.rda') #### INSTRUCTION: # note: all analyses are done with the object 'b2.rs'; # create this object from the data of either Experiment 1, 2, 3, or 4 ## Choose the data set to analyze ## Experiment 1: b2.rs <- Exp1 ## Experiment 1: #b2.rs <- Exp2 ## Experiment 1: #b2.rs <- Exp3 ## Experiment 1: #b2.rs <- Exp4 ## b2.rs # the object 'b2.rs' is the main data frame containing all target reading data and is used for most analyses # # INDEPENDENT VARIABLES: # prime: preview type (factor) # p.dur: prime duration (factor) # cond: condition (factor generated by crossing prime type and prime duration) # id: subject id # sn: sentence id # # READING MEASURES: # o: initial target fixation position (ranges from 0 to 1) # refix: dichtomic variable indicating whether the target was refixated # tar.GD: target gaze duration [ms] # tar.FFD: target first fixation duration [ms] ## Cmat2b # the object 'Cmat2b' is the contrast matrix for experiments with prime durations of 35, 80, and 125 ms; # it includes linear and quadratic contrasts for prime durations and prime contrast within each prime duration ## Cmat2c # the object 'Cmat2c' is the contrast matrix for the experiment with prime durations of 20, 40, and 60 ms; # it includes linear and quadratic contrasts for prime durations and prime contrast within each prime duration #### STATISTICAL ANALYSES FOR EXPERIMENTS 1 TO 3 ## contrasts and global priming effects # a) target gaze duration lmer(tar.GD ~ cond + (1 | sn) + (1 | id), data = b2.rs, contrasts = list(cond = Cmat2b)) lmer(tar.GD ~ prime + (1 | sn) + (1 | id), data = b2.rs) # b) target first fixation duration lmer(tar.FFD ~ cond + (1 | sn) + (1 | id), data = b2.rs, contrasts = list(cond = Cmat2b)) lmer(tar.FFD ~ prime + (1 | sn) + (1 | id), data = b2.rs) # c) target refixation probability glmer(refix ~ cond + (1 | sn) + (1 | id), data = b2.rs, contrasts = list(cond = Cmat2b), family = "binomial") glmer(refix ~ prime + (1 | sn) + (1 | id), data = b2.rs, family = "binomial") # d) target landing position lmer(o ~ cond + (1 | sn) + (1 | id), data = b2.rs, contrasts = list(cond = Cmat2b)) lmer(o ~ prime + (1 | sn) + (1 | id), data = b2.rs) #### STATISTICAL ANALYSES FOR EXPERIMENT 4 ## contrasts and global priming effects # a) pretarget gaze duration lmer(tar.GD ~ cond + (1 | sn) + (1 | id), data = b2.rs, contrasts = list(cond = Cmat2c)) lmer(tar.GD ~ prime + (1 | sn) + (1 | id), data = b2.rs) # b) target first fixation duration lmer(tar.FFD ~ cond + (1 | sn) + (1 | id), data = b2.rs, contrasts = list(cond = Cmat2c)) lmer(tar.FFD ~ prime + (1 | sn) + (1 | id), data = b2.rs) # c) target refixation probability glmer(refix ~ cond + (1 | sn) + (1 | id), data = b2.rs, contrasts = list(cond = Cmat2c), family = "binomial") glmer(refix ~ prime + (1 | sn) + (1 | id), data = b2.rs, family = "binomial") # d) target landing position lmer(o ~ cond + (1 | sn) + (1 | id), data = b2.rs, contrasts = list(cond = Cmat2c)) lmer(o ~ prime + (1 | sn) + (1 | id), data = b2.rs) #### FIGURE FOR EXPERIMENTS 1 TO 4 ## Figure: Target gaze duration as as function of the six experimental conditions # cast data into a proper form fig.data <- cast(b2.rs, prime + p.dur ~ ., function(x) c( GD=round(mean(x)), SD = round(sd(x)), SE=round(sd(x)/sqrt(length(x)),+Inf), N=length(x) )) # extract adjusted SEs for graphics (without iem and subject difference) model.fig <- lmer(tar.GD ~ prime * p.dur + (1 | sn) + (1 | id), data = b2.rs) b2.rs$residuals <- resid(model.fig) SE.adjusted <- aggregate(b2.rs$residuals, by = list(p.dur = b2.rs$p.dur, prime = b2.rs$prime), function(x) c(sd(x)/sqrt(length(x)))) # add adjusted residual information fig.data$SE.adj <- SE.adjusted$x # plot data p <- ggplot(fig.data, aes(y = GD, x = p.dur, linetype = prime, shape = prime) ) + geom_point(size = 3) + geom_line(aes(group = prime), size = 0.8) + geom_errorbar(aes(min = GD-SE.adj, max = GD+SE.adj, width = 0.2), size = 0.7) p <- p + scale_x_discrete("Prime duration [ms]") + scale_y_continuous("Gaze duration [ms]") + scale_shape("Prime") + scale_linetype("Prime") p <- p + opts(legend.position = c(0.2, 0.85)) p