Separating exogenous and endogenous temporal attention - janeshdev/ggplot2 GitHub Wiki
Authors: Mike Lawrence & Ray Klein, Dalhousie University
This case study describes work that at the time of the creation of this post (2010-09-18) is currently under peer review.
Attention is the means by which the brain differentially allocates information processing, conserving possibly limited resources. The mechanisms of such allocation have been generally characterized as "endogenous" (relatively volitional and sensitive to learned contingencies) versus "exogenous" (relatively automatic and sensitive to evolutionarily pertinent contingencies). Additionally, multiple domains of allocation have been studied, including space ("attend over here" versus "attend over there") and task ("do this now and do that next"). A recognized but somewhat neglected domain of allocation is the domain of time, for example, it's known that the time it takes to respond to a target stimulus is reduced if the target is preceded by a signal that reliably predicts the time of the target stimulus. However, research on temporal attention has thus far failed to distinguish between the potential for such signal stimuli to engage either endogenous versus exogenous mechanisms of attention.
By employing two novel experimental manipulations, we were able to independently manipulate the degree to which we anticipated engagement of (potential) endogenous mechanisms of attention as well as the degree to which we anticipated engagement of (potential) exogenous mechanisms of attention. The variable Design sought to manipulate endogenous mechanisms and has two levels, Contingent Design (CD) and Non-contingent Design (NCD), in which it was thought that endogenous mechanisms would be engaged and disengaged, respectively. The variable ∆dB sought to manipulate exogenous mechanisms and also has two levels, +∆dB and 0∆dB, in which it was thought that exogenous mechanisms would be engaged and disengaged, respectively. Factorial combination of these variables permits investigation of the potential existence of separable mechanisms of endogenous and exogenous temporal attention, as well as any interactions that such mechanisms might have. An additional variable Stimulus Onset Asynchrony (SOA) manipulates the time between signal and target, thus permitting characterization of the time-course of temporal attention phenomena. Target stimuli required participants to identify the target as either orange or blue, thus two dependent variables are obtained: response time and error rate. 16 participants provided data across all combinations of the manipulated variables, and data was fitted to a generalized additive mixed model; confidence intervals for predictions generated by the model was obtained by bootstrap resampling.
Figure 1 depicts the raw error rate and response time performance data as a function of SOA for each combination of the levels of Design and ∆dB. Even in this raw data, there are strong effects of Design and smaller but notable effects of ∆dB. These effects become more easily visualized by computing the difference scores for each effect, as shown in Figure 2. The effect of Design is computed as NCD minus CD, and the effect of ∆dB is computed as 0∆dB minus +∆dB; with such operationalization, positive values for each effect reflect an improvement in performance (“benefits”) when attention is engaged (compared to when attention is not engaged) and negative values reflect a decrement in performance (“costs”).
The left column of Figure 2 depicts the effect of Design across SOA, and here we see that the response time performance benefit in the CD condition rapidly increases at early SOAs (presumably as the system is provided more time to prepare for the target stimulus) until a maximum benefit at around 400ms, after which point the benefit decreases at a moderate rate (presumably as time-keeping mechanisms accumulate error). The Design effect is also associated with nearly ubiquitous error rate benefits. In contrast, the right column, depicting the effect of ∆dB across SOA, shows a much weaker effect of ∆dB that manifests as a response time benefit restricted to a very early interval on the SOA timeline. Across this same timeframe it appears that the ∆dB effect is associated with slight costs to error rate. When the ∆dB effect is computed within each Design condition (CD and NCD), as shown in Figure 3, it becomes apparent that the effect of ∆dB interacts with Design such that in the CD condition (left column of Figure 3), the effects of ∆dB observed in Figure 2 are amplified (benefits in response time and costs in error rate at an early SOA interval) while in the NCD condition (right column of Figure 3) there are apparently no substantial effects of ∆dB.
Figure 4 provides an alternative representation of the study's findings, computing the Design effect on error rate and response time in each ∆dB condition and vice versa, collapsed across SOAs over which each effect manifests and computed within each bootstrap iteration independently. The resulting data is plotted as bivariate distributed points in a space defined by the effect on error rate and the effect on response time, and a 95% confidence ellipse can be computed for each distribution.
The blue and purple distributions, representing the effect of Design in the 0∆dB and +∆dB conditions, respectively, fall in the area of space that reflects a benefit to performance on both error rate and RT, suggesting that the operation of endogenous temporal attention serves to enhance information processing. These distributions also show a considerable amount of overlap, suggesting that the operation of the endogenous mechanisms of temporal attention are not considerably influenced by the state of exogenous temporal attention. In contrast, the red and green distributions, representing the effect of ∆dB in the CD and NCD conditions, respectively show less overlap, and while the green distribution encompasses the origin, the red distribution appears to be shifted towards the area of space that reflects an effect on performance that emphasizes speed over accuracy. Thus, it appears that the operation of exogenous temporal attention is contingent on the state of endogenous temporal attention such that when endogenous temporal attention is not engaged, exogenous temporal attention has no effect (indeed, may not operate), whereas when endogenous temporal attention is engaged, exogenous temporal attention serves to speed performance at the cost of increased error rates.
Below is the code to plot the above figures. Generally, the data frame submitted to ggplot() contains a column called "Mean", which represents the central prediction line and columns called "lo" and "hi", representing the upper and lower 95% confidence intervals on prediction. Figure 4 is a little different in that it calls upon 4 pre-existing data frames then dynamically creates a 5th data frame that represents some text to be plotted.
######## # FIGURE 1 ######## fig1 = ggplot(raw)+ geom_vline( xintercept = 0 ,linetype = 2 )+ geom_ribbon( mapping = aes( x = soa , ymin = lo , ymax = hi , fill = design , group = g ) , alpha = .2 )+ geom_line( mapping = aes( x = soa , y = Mean , colour = design , linetype = ddB ) )+ facet_grid( dv ~ . , scales = 'free_y' )+ labs( y = '' , x = 'SOA (ms)' , linetype = expression(bold(paste(Delta,'dB'))) , fill = 'Design' , colour = 'Design' )+ scale_linetype( breaks = c('+ddB','0ddB') , labels = c( expression(paste('+',Delta,'dB')) ,expression(paste('0',Delta,'dB')) ) )+ scale_x_continuous( expand = c(0,0) , breaks = seq(0,1000,200) )+ opts( axis.title.y = theme_blank() ) ######## # FIGURE 2 ######## fig2 = ggplot(effects)+ geom_vline( xintercept = 0 , linetype = 2 )+ geom_hline( yintercept = 0 , linetype = 2 )+ geom_ribbon( mapping = aes( x = soa , ymin = lo , ymax = hi ) , alpha = .2 )+ geom_line( mapping = aes( x = soa , y = Mean ) )+ facet_grid( dv ~ effect , scales = 'free_y' , labeller = "label_parsed" )+ labs( y = '' , x = 'SOA (ms)' )+ scale_x_continuous( expand = c(0,0) , breaks = seq(0,1000,200) )+ opts( axis.title.y = theme_blank() ) ######## # FIGURE 3 ######## fig3 = ggplot(ddB_effect2_stats)+ geom_vline( xintercept = 0 , linetype = 2 )+ geom_hline( yintercept = 0 , linetype = 2 )+ geom_ribbon( mapping = aes( x = soa , ymin = lo , ymax = hi ) , alpha = .2 )+ geom_line( mapping = aes( x = soa , y = Mean ) )+ facet_grid( dv ~ design , scales = 'free_y' , labeller = "label_parsed" )+ labs( y = '' , x = 'SOA (ms)' )+ scale_x_continuous( expand = c(0,0) , breaks = c(0,200,400,600,800,1000) )+ opts( axis.title.y = theme_blank() ) ######## # FIGURE 4 ######## fig4 = ggplot()+ layer( geom = 'point' , data = ddB_effect_sat , mapping = aes( x = rt , y = er , colour = design ) , alpha = .2 , legend = F )+ layer( geom = 'path' , data = ddB_effect_sat_ci , mapping = aes( x = rt , y = er , colour = design ) )+ layer( geom = 'point' , data = design_effect_sat , mapping = aes( x = rt , y = er , colour = ddB ) , alpha = .2 , legend = F )+ layer( geom = 'path' , data = design_effect_sat_ci , mapping = aes( x = rt , y = er , colour = ddB ) )+ geom_vline( xintercept = 0 , linetype = 2 )+ geom_hline( yintercept = 0 , linetype = 2 )+ geom_text( data = data.frame( label = c( ' Performance benefit' , 'Accuracy emphasis ' , 'Performance cost ' , ' Speed emphasis' ) , angle = c(45,45+90*3,45,45+90*3) , hjust = c(0,1,1,0) , x = 0 , y = 0 ) , mapping = aes( x = x , y = y , label = label , angle = angle , hjust = hjust ) )+ labs( x = 'Effect on response time (ms)' , y = 'Effect on error rate (%)' )+ scale_colour_hue( name = '' , breaks = c('CD','NCD','+ddB','0ddB') , labels = parse(text=c( expression(paste(Delta,'dB effect in the CD condition')) , expression(paste(Delta,'dB effect in the NCD condition')) , expression(paste('Design effect in the +',Delta,'dB condition')) , expression(paste('Design effect in the 0',Delta,'dB condition')) )) )+ opts( legend.position = c(.815,.235) , legend.background = theme_rect(colour='white',fill='transparent') , legend.title = theme_blank() , legend.key = theme_rect(colour='transparent',fill='transparent') , legend.text = theme_text(hjust=0) , panel.grid.major = theme_blank() , panel.grid.minor = theme_blank() )