nsub <- 15 source("exGauss.R") set.seed(100) word <- c(rep(rep(c("red", "green"), 2), each=50), rep(c("xxx", "xxxxx"), each=50)) color <- rep(c("red", "green", "green", "red", "red", "green"), each=50) cond <- rep(c("cng", "incng", "neut"), each=100) proto <- data.frame(word=word, color=color, cond=cond) err <- function( eprob # Probability of error ) { sample(c(0,1), 100, replace=TRUE, prob=c(eprob,100-eprob)) } dir.create("./data", showWarnings=FALSE) options(warn=-1) makesample <- function(sub) { mu <- c(500, 600, 520) + rnorm(3, sd=10) + rnorm(1, sd=50) sigma <- c(50, 110, 50) + rnorm(3, sd=5) + rnorm(1, sd=10) tau <- c(110, 115, 90) + rnorm(3, sd=5) + rnorm(1, sd=10) RT <- round(as.vector(mapply(FUN=rexGauss, 100, mu, sigma, tau))) cor <- as.vector(sapply(FUN=err, X=c(3,15,5))) tmp <- proto tmp$RT <- RT tmp$cor <- cor tmp <- tmp[sample(1:300),] tmp$trial <- 1:300 tmp <- tmp[,c("trial", "word", "color", "cond", "RT", "cor")] filename <- paste("./data/sub_", sub, ".txt", sep="") con <- file(filename, open="w") textout <- c("Pseudo-data of Stroop task for ex-Gaussian RT analysis", "Experimenter\tSatou Tanaka", paste("Experimental date\t", Sys.Date()-nsub+sub, sep="")) writeLines(text=textout, con=con, sep="\n") cat("\n", file=con) close(con) write.table(tmp, file=filename, append=TRUE, sep="\t", quote=FALSE, col.names=TRUE, row.names=FALSE) } lapply(X=1:nsub, FUN=makesample) options(warn=0)