R/fit_ezddm.R
fit_ezddm.Rd
Fits Wagenmaker et al.'s (2007) EZ-diffusion model for two-choice response time tasks. To use the function, ensure your dataframe is in long form, has single-trial reaction time (in seconds) and responses (coded as 0 or 1) on each row. You can use the function to fit the EZ-diffusion model to just a single subject or multiple subjects, and separately for each experimental condition (see below for examples).
fit_ezddm(data, rts, responses, id = NULL, group = NULL, s = 0.1, decimal = 4)
data | data object with reaction time and accuracy variables (long form data expected) |
---|---|
rts | specify in characters the name of the reaction time column (reaction time must be in seconds) |
responses | specify in characters the name of the accuracy column (coded as 0/1) |
id | specify in characters the name of your subject/id column (if not specified, assumes data [all rows] belong to a single subject) |
group | specify in characters the name of your column(s) indicating various conditions (default = NULL) |
s | scaling parameter (often set to 0.1 or 1.0) |
decimal | round parameter estimates (default = 4) |
A datatable
Details to follow
Notes to follow
Wagenmakers, E. J., van der Maas, H. L., & Grasman, R. P. (2007). An EZ-diffusion model for response time and accuracy. Psychonomic Bulletin & Review, 14(1), 3-22. doi:10.3758/BF03194023 (https://link.springer.com/article/10.3758/BF03194023)
Hause Lin
if (FALSE) { library(rtdists) # load package to simulate data with diffusion parameters data1 <- rdiffusion(n = 100, a = 2, v = 0.3, t0 = 0.5, z = 0.5 * 2) # simulate data data2 <- rdiffusion(n = 100, a = 2, v = -0.3, t0 = 0.5, z = 0.5 * 2) # simulate data dataAll <- rbind(data1, data2) # join data dataAll$response <- ifelse(dataAll$response == "upper", 1, 0) # convert responses to 1 and 0 dataAll$subject <- rep(c(1, 2), each = 100) # assign subject id dataAll$cond1 <- base::sample(c("a", "b"), 200, replace = TRUE) # randomly assign conditions a/b dataAll$cond2 <- base::sample(c("y", "z"), 200, replace = TRUE) # randomly assign conditions y/z # fit model to just entire data set (assumes all data came from 1 subject) fit_ezddm(data = dataAll, rts = "rt", responses = "response") # fit model to just entire data set (assumes all data came from 1 subject) fit_ezddm(data = dataAll, rts = "rt", responses = "response", id = "subject") # fit model to each subject by cond1 fit_ezddm(data = dataAll, rts = "rt", responses = "response", id = "subject", group = "cond1") # fit model to each subject by cond1,cond2 fit_ezddm(data = dataAll, rts = "rt", responses = "response", id = "subject", group = c("cond1", "cond2")) }