opt.bins: Find the optimal way to bin the response times.

Description Usage Arguments Details Value See Also Examples

Description

A function to divide the response time data into a fixed number of small consecutive intervals or bins, in a way that is optimal given the distribution of the reponse time data. This involves finding an optimal offset (or start) of bining, and possily an optimal bin size.

Usage

1
2
3
4
opt.bins(RT, maxRT = 6300, breaksize = 7, 
  startbin = 1, endbin = 16, binsize = 350, 
  type = c("fixed", "free"),
  add.two=FALSE, shift.edge = FALSE)

Arguments

RT

a numeric vector containing the raw response time information

maxRT

numeric. Maximum duration of response time above which will be trimmed for the estimation.

breaksize

a single number representing the size of bins (in milisecond) used in the intermediate step.

startbin

integer.

endbin

integer.

binsize

a single number corresponding to the initial (and final if type="fixed") window size to be used for binning

type

a character string indicating whether to use the window of prespecified width ("fixed") or the widow of data-specific width ("free").

add.two

logical. An option for compatibility. If TRUE, a magic number 2 is added to the window size when calculating the fit.

shift.edge

logical. An option forcompatibility with old codes. If TRUE, the timing bins are shifted 100 ms forward. Default to FALSE.

Details

This function is meant to be called internally from a wapper function get.bins.

The optimal timing bin size (if window="free") and offset are estimated by fitting the half-rectified sine wave against the histgram of response data.

Value

A list containing:

maxRT, breaksize, endbin, binsize, type

same as scpecified in the arguemnts

peaktime

a vector of time points representing peak in each time bin

offset

difference in time between the offset of the stimulus and the onset of the fastest response.

fit

root mean squared distance between the actual distribution of the data and the half-rectified sine wave

phase

phase (in ms) for the sign wave function.

omega

fitted window size. If type="fixed", the value should be the same as the argument binsize

rt.hist

an object of class "histogram", with x=RT, and breaks=seq(from=0, to=maxRT, by=breaksize)

amp

amplitude for the sign wave function.

See Also

get.bins

Examples

1
2
3
4
5
data(Auditory_demo)
rt_col <- grep("rt[0-3][0-9]",colnames(Auditory_demo), value=TRUE)
RT <- Auditory_demo[,rt_col]
d.opt <- opt.bins(unlist(na.omit(RT)))
plot(d.opt)

matsukik/mrsat documentation built on May 21, 2019, 12:57 p.m.