Analysis of RT distributionswith R
Emil Ratko-DehnertWS 2010/ 2011
Session 09 – 18.01.2011
Last time...
• Recap of contents so far (Chapter 1 + 2)
• Hierarchical Interference (Townsend‘s system)
• Functional forms of RVs
– Density function (TAFKA „distribution“)
– Cumulative distribution function
– Quantiles
– Kolmogorov-Smirnof test2
RT DISTRIBUTIONS IN THE FIELD
3
II
RTs in visual search
4
Why analyze distribution?
1. Normality assumption almost always violated
2. Experimental manipulations might affect only
parts of RT distribution
3. RT distributions can be used to constrain
models e.g. of visual search (model fitting and
testing)5
RT distributions
• Typically unimodal and positively skewed
• Can be characterized by e.g. the following
distributions
6
Ex-Gauss Ex-Wald
Gamma Weibull
Ex-Gauss distribution
• Introduced by Burbeck and Luce (1982)
• Is the convolution of a normal and an
exponential distribution
• Density:
2
2
2
2exp
1),,;(
tt
tf
7
Ex-Gauss
CDF of N(0,1)
Convolution• ... is a modified version of the two original functions
• It is the integral of the product of the two functions
after one is reversed and shifted:
dtgftgf )()())(*(
8
Ex-Gauss
9-4 -2 0 2 4 6 8 10
0.0
0.1
0.2
0.3
0.4
0.5
Manipulating gaussian parameters
xx
y1
exg(mu=0, sigma=1, nu=1)exg(mu=2, sigma=1, nu=1)exg(mu=0, sigma=3, nu=1)exg(mu=0, sigma=0.5, nu=1)
10-5 0 5 10
0.0
0.2
0.4
0.6
0.8
1.0
Manipulating gaussian parameters
xx
y1
exg(mu=0, sigma=1, nu=1)exg(mu=2, sigma=1, nu=1)exg(mu=0, sigma=3, nu=1)exg(mu=0, sigma=0.5, nu=1)
11-4 -2 0 2 4 6 8 10
0.0
00
.05
0.1
00
.15
0.2
00
.25
0.3
0
Manipulating exponential parameter
xx
y5exg(mu=0, sigma=1.5, nu=0.5)exg(mu=0, sigma=1.5, nu=1)exg(mu=0, sigma=1.5, nu=2)exg(mu=0, sigma=1.5, nu=5)exg(mu=0, sigma=1.5, nu=9)
120 5 10 15
0.0
0.2
0.4
0.6
0.8
1.0
Manipulating exponential parameter
xx
y5
exg(mu=0, sigma=1.5, nu=0.5)exg(mu=0, sigma=1.5, nu=1)exg(mu=0, sigma=1.5, nu=2)exg(mu=0, sigma=1.5, nu=5)exg(mu=0, sigma=1.5, nu=9)
Why popular?
• Components of Ex-Gauss might correspond to
different mental processes
– Exponential Decision; Gaussian Residual
perceptual and response-generating processes
• It is known to fit RT distributions very well
(particularly hard search tasks)
• One can look at parameter dynamics and infer on
trade-offs13
Ex-Gauss
Further reading• Overview:
– Schwarz (2001)
– Van Zandt (2002)
– Palmer, et al. (2009)
• Others:
– McGill (1963)
– Hohle (1965)
– Ratcliff (1978, 1979)
– Burbeck, Luce (1982)
– Hockley (1984)
– Luce (1986)
– Spieler, et al. (1996)
– McElree & Carrasco (1999)
– Spieler, et al. (2000)
– Wagenmakers, Brown (2007)
14
Ex-Gauss
Ex-Wald distribution
• Is the convolution of an exponential and a Wald
distribution
• Represents decision and response components
as a diffusion process (Schwarz, 2001)
15
Ex-Wald
Ex-Wald density
where
16
Ex-Wald
Diffusion Process
17
A
B
z
drift rate ~N(ν,η)
time
Evid
ence
Boundary separation
Mean drift ν
Respond „A“
Respond „B“
Information space
Ex-Wald
Qualitative Behaviour
18
A2
0
A1
time
lax criterion
strict criterion
larger drift rate
smaller drift rate
Decision times for lax and strict criterion
Ex-Wald
19200 300 400 500 600 700
0.0
00
0.0
02
0.0
04
0.0
06
0.0
08
Ex-Wald densities
xx
y1exwald(mu=0.320, sigma=1, a = 108, gamma = 1/22)exwald(mu=0.356, sigma=1, a = 111, gamma = 1/22)exwald(mu=0.321, sigma=1, a = 97, gamma = 1/22)exwald(mu=0.348, sigma=1, a = 98, gamma = 1/20)
20200 300 400 500 600 700
0.0
0.2
0.4
0.6
0.8
1.0
Ex-Wald distributions
xx
y1
exwald(mu=0.320, sigma=1, a = 108, gamma = 1/22)exwald(mu=0.356, sigma=1, a = 111, gamma = 1/22)exwald(mu=0.321, sigma=1, a = 97, gamma = 1/22)exwald(mu=0.348, sigma=1, a = 98, gamma = 1/20)
Why popular?
• Parameters can be interpreted psychologically
• Very successful in modelling RTs for a number of
cognitive and perceptual tasks
• Are neurally plausible
– Neuronal firing behaves like a diffusion process
– Observed via single cell recordings
21
Ex-Wald
Further reading
• Theoretical Papers:
– Schwarz (2001, 2002)
– Ratcliff (1978)
– Heathcote (2004)
– Palmer, et al. (2005)
– Wolfe, et al. (2009)
• Cognitive+perceptual tasks:
– Palmer, Huk & Shadlen (2005)
• Visual Search:
– Reeves, Santhi & Decaro
(2005)
– Palmer, et al. (2009)
22
Ex-Wald
Gamma distribution
• Series of exponential distributions
• α = average scale of processes
• β = reflects approximate number of processes
23
Gamma
240 2 4 6 8 10 12
0.0
0.1
0.2
0.3
0.4
0.5
Gamma densities
xx
y1gamma(shape = 1, scale = 2)gamma(shape = 2, scale = 2)gamma(shape = 3, scale = 2)gamma(shape = 5, scale = 1)gamma(shape = 9, scale = 0.5)
25
0 5 10 15 20
0.0
0.2
0.4
0.6
0.8
1.0
Gamma distributions
xx
y1
gamma(shape = 1, scale = 2)gamma(shape = 2, scale = 2)gamma(shape = 3, scale = 2)gamma(shape = 5, scale = 1)gamma(shape = 9, scale = 0.5)
Why popular?
• In fact, not too popular (publication-wise)
• It has very decent fits, when assuming a
model, that sees RT distributions as composed
of three exponentially distributed processes
(Initial feed-forward search response selection)26
Gamma
Further reading
• Dolan, van der Maas, & Molenaar (2002):
A framework for ML estimation of parameters
of (mixtures of) common reaction time distri-
butions given optional truncation or censoring
(in Behavioral Research Methods, Instruments
& Computers, 34(3), 304-323)
27
Gamma
Weibull Distribution• Like a series of races (bounded by 0 and ∞) the
weibull distribution renders an asymptotic
description of their minima
• Johnsons (1994) version as 3 parameters: α, γ, ξ
– For γ = 1 exp. distr., for γ ~ 3.6 normal distr.
– Hence γ must lie somewhere in between28
Weibull
290 1 2 3 4 5 6 7
0.0
0.2
0.4
0.6
0.8
1.0
Weibull densities
xx
y1weibull(shape = 1, scale = 1)weibull(shape = 1, scale = 2)weibull(shape = 1.5, scale = 1)weibull(shape = 2, scale = 2)weibull(shape = 2, scale = 3)weibull(shape = 3.6, scale = 3)
300 1 2 3 4 5 6 7
0.0
0.2
0.4
0.6
0.8
1.0
Weibull distributions
xx
y1
weibull(shape = 1, scale = 1)weibull(shape = 1, scale = 2)weibull(shape = 1.5, scale = 1)weibull(shape = 2, scale = 2)weibull(shape = 2, scale = 3)weibull(shape = 3.6, scale = 3)
Why popular?
• Has been used in a variety of cognitive tasks
• Excels in those, which can be modeled as a
race among competing units (e.g. Memory
search RTs)
• Has decent functional fits31
Weibull
Further reading
• Logan (1992)
• Johnson, et al. (1994)
• Dolan, et al. (2002)
• Chechile (2003)
• Rouder, Lu, Speckman, Sun & Jiang (2005)
• Cousineau, Goodman & Shiffrin (2002)
• Palmer, Horowitz, Torrabla, Wolfe (2009)
32
Weibull
Comparing functional fits• Null hypothesis is fit of data with normal distribution
(standard assumption for mean/var analysis)
• All proposed distributions beat the gaussian, but not
equally well
1) Ex-Gauss, 2) Ex-Wald, 3) Gamma, 4)Weibull
• Also the first three have similar parameter trends
• For further reading, see the simulation study by
Palmer, Horowitz, Torrabla, Wolfe (2009)33
EXCURSION: BOOTSTRAPPING
34
Basic idea
• In statistics, bootstrapping is a method to assign
accuracy to sample estimates
• This is done by resampling with replacements
from the original dataset
• By that one can estimate properties of an
estimator (such as its variance)
• It assumes IID data35
Ex: Bootstrapping the sample mean
• Original data: X = x1, x2, x3, ..., x10
• Sample mean: X = 1/10 * (x1 + x2 + x3 + ... + x10)
• Resample data to obtain a bootstrap means:
X1* = x2, x5, x10, x10, x2, x8, x3, x10, x6, x7 μ1*
• Repeat this 100 times to get μ1*, ..., μ100*
• Now one has an empirical bootstrap distribution of μ
• From this one can derive e.g. the bootstrap CI of μ36
Pro bootstrapping
• It is ...
– simple and easy to implement
– straightforward to derive SE and CI for complex
estimtors of complex parameters of the distribution
(percentile points, odds ratio, correlation coefficients)
– an appropriate way to control and check the stability of
the results
37
Contra bootstrapping
• Under some conditions it is asymptotically
consistent, so it does not provide general finite-
sample guarantees
• It has a tendency to be overly optimistic (under-
estimates real error)
• Application not always possible because of IID
restriction38
Situations to use bootstrapping
1. When theoretical distribution of a statistic is compli-
cated or unknown
2. When the sample size is insufficient for straight-
forward statistical inference
3. When power calculations have to be performed and
a small pilot sample is availible
• How many samples are to be computed?
As much as your hardware allows for... 39
AND NOW TO
40
Creating own functionsnew.fun <- function(arg1, arg2, arg3){
x <- exp(arg1)
y <- sin(arg2)
z <- mean(arg2, arg3)
result <- x + y + z
result
}
A <- new.fun(12, 0.4, -4)41
„inputs“
„output“
Algo
rithm
of f
uncti
on
Usage of new.fun