Learn R Programming

retimes (version 0.1-2)

timefit: Analyzing Reaction Times

Description

Parameter estimation for reaction time distributions using the maximum likelihood method. Currently, the function works only for the ex-Gaussian probability distribution.

Usage

timefit(x, iter = 0, size = length(x), replace = TRUE,
        plot = FALSE, start = NULL, ...)

Arguments

x
Vector of reaction times, in milliseconds or seconds.
iter
if iter > 0, the estimation is performed by bootstrap resampling. For each iteration, a sub-sample with a positive skewness will be estracted from the original sample, and distribution parameters will be estimated on resampl
size
Sample dimension to use in resampling, when the bootstrap is active.
replace
Logical: specifies if the resampling must be performed with replacement.
plot
Logical: if TRUE, it shows the data distribution (continuous line) and the estimated distribution (dashed line). Furthermore, when the bootstrap is used, the histogram of each parameter distribution is shown.
start
Vector containing starting values (in order: $mu$, $sigma$ and $tau$) for the optimization routine. As default, the method of moments is used to estimate initial parameters. If the bootstrap is active, the argument will be ignored (start
...
Further arguments for the optimization routine. Arguments will be passed to the optim function: see the optim documentation for further details.

Value

  • An object of class timefit. The operator @ should be used to extract the values from the slots of the output object.
    • @x: vector of data.
    • @samples: bootstrapped samples.
    • @par: estimated parameters.
    • @bootPar: bootstrapped parameters.
    • @bootValue: log-likelihood of bootstrapped parameters.
    • @sigmaValid: not rejected (TRUE) and rejected (FALSE) values for$\sigma$.
    • @start: starting values.
    • @logLik: log-likelihood of estimated parameters.
    • @AIC: Akaike Information Criterion.
    • @BIC: Bayesian Information Criterion.

Details

The function timefit estimates ex-Gaussian parameters by maximum likelihood, using the optim function. As default, the Simplex method (Nelder-Mead) is applied to find the minimum of the objective function. The function implements a bootstrap approach to identify distribution parameters. The bootstrap is useful especially working on small samples. The implemented method identifies $\mu$ and $\sigma$ using a gaussian kernel estimator (see Van Zandt, 2000, for details). Since small samples often present problems of convergence for $\sigma$, for this parameter only the values included a theoretical plausible range are considered. This range is defined by: $$\sqrt{\frac{min(x-M)^2}{n-1}} \leq \sigma \leq S$$ where M and S are respectively the mean and the standard deviation of data. When $\mu$ and $\sigma$ are identified, $\tau$ is chosen within the bootstrapped values, according to the maximum likelihood criterion.

References

Cousineau, D., Brown, S. & Heathcote, A. (2004). Fitting distributions using maximum likelihood: Methods and packages. Behavior Research Methods, Instruments, & Computers, 36(4), 742-756. Heathcote, A. (1996). RTSYS: A DOS application for the analysis of reaction time data. Behavior Research Methods, Instruments, & Computers, 28(3), 427–445. Lacouture, Y., & Cousineau, D. (2008). How to use MATLAB to fit the ex-Gaussian and other probability functions to a distribution of response times. Tutorials in Quantitative Methods for Psychology, 4(1), 35-45. Luce, R. D. (1986). Response times: their role in inferring elementary mental organization. New York: Oxford University Press. Ratcliff, R. (1978). A theory of memory retrieval. Psychological Review, 85(2), 59-108. Ratcliff, R. (1979). Group Reaction Time Distributions and an Analysis of Distribution Statistics. Psychological Bulletin, 86(3), 446-461. Ratcliff, R. & Murdock Jr., B. B. (1976). Retrieval Processes in Recognition Memory. Psychological Review, 83(3), 190-214. Van Zandt, T. (2000). How to fit a response time distribution. Psychonomic Bulletin & Review, 7(3), 424-465. Van Zandt, T.(2002). Analysis of response time distributions. In J. T. Wixted (Vol. Ed.) & H. Pashler (Series Ed.): Stevens' Handbook of Experimental Psychology (3rd Edition), Volume 4: Methodology in Experimental Psychology (pp. 461-516). New York: Wiley Press.

See Also

exgauss, density-estim, skew

Examples

Run this code
# Vector of reaction times from Heathcote (1996):
RT <- c(474.688, 506.445, 524.081, 530.672, 530.869,
        566.984, 582.311, 582.940, 603.574, 792.358)
RTfit <- timefit(RT); RTfit

# Boostrap tesing with simulated data (m=500, s=100, t=250):

x1 <- c(451.536,958.612,563.538,505.735,1266.825,
        860.663,457.707,268.679,587.303,669.594)
fit1a <- timefit(x1); fit1a
fit1b <- timefit(x1, iter=1000); fit1b

x2 <- c(532.474,525.185,1499.471,480.732,631.752,
        672.419,322.341,571.356,428.832,680.848)
fit2a <- timefit(x2, plot=TRUE); fit2a
fit2b <- timefit(x2, iter=1000, plot=TRUE); fit2b

Run the code above in your browser using DataLab