@@ -187,13 +187,15 @@ fitFunctionSSP <- function(
187187}# End of fitFunctionSSP
188188# ------------------------------------------------------------------------------
189189
190- analysis_path = " /Users/fzaki001/thrive-theta-ddm/" # local
191- # analysis_path = "/home/data/NDClab/analyses/thrive-theta-ddm/" # HPC
192- output_sim_path <- ' /Users/fzaki001/thrive-theta-ddm/derivatives/behavior/ddm_recovery/sim_data'
193- output_fit_path <- ' /Users/fzaki001/thrive-theta-ddm/derivatives/behavior/ddm_recovery/fit_data'
190+ # analysis_path = "/Users/fzaki001/thrive-theta-ddm/" # local
191+ # analysis_path = "/Users/fzaki001/thrive-theta-ddm/" # local
192+ analysis_path = " /home/data/NDClab/analyses/thrive-theta-ddm/" # HPC
193+ output_sim_path <- sprintf(" %s/derivatives/behavior/ddm_recovery/sim_data/" , analysis_path )
194+ output_fit_path <- sprintf(" %s/derivatives/behavior/ddm_recovery/fit_data/" , analysis_path )
194195
195196# how many trials to simulate per condition
196- nTrials_to_sim = c(50 , 100 , 200 , 500 , 1000 , 5000 )
197+ # nTrials_to_sim = c(50, 100, 200, 500, 1000, 5000)
198+ nTrials_to_sim = c(5 , 10 , 25 )
197199
198200dt <- 0.001
199201vari <- 0.01
@@ -202,14 +204,25 @@ vari <- 0.01
202204Upper <- c(0.232 , 0.420 , 0.630 , 0.067 , 3.093 ); # mean of white 2011 Exp1 plus 5 sd
203205Lower <- c(0.032 , 0.180 , 0.130 , 0.0001 , 0.493 ); # mean of white 2011 Exp1 minus 5 sd
204206nTrials <- 10000
205- output_fit_file <- " recovered_params.csv"
207+ output_fit_file <- sprintf(
208+ " recovered_params_%s.csv" ,
209+ format(Sys.time(),' %y_%m_%d_%H_%M_%S' ) # will indicate start time
210+ )
206211numParams <- length(Upper )
207212
213+ fitOutput <- data.frame (matrix (ncol = 9 , nrow = 0 ))
214+ colnames(fitOutput ) <- c(" subject" , " a" , " ter" , " p" , " rd" , " sda" , " fitStat" , " iteNum" , " seed" )
215+ fitOutput <- data.frame (fitOutput )
216+
217+ # also write a .csv to append parms to at the end of loops
218+ write.csv(fitOutput , sprintf(" %s/%s" , output_fit_path , output_fit_file ), row.names = FALSE , na = " " , quote = F )
219+
208220for (condition in nTrials_to_sim ) {
209221
210- for (cb in seq(1 , 100 )) {
211- set.seed(cb ) # For reproducibility
212- output_fit_file <- sprintf(" %s/fit_data_%s_%s.csv" , output_fit_path , condition , cb )
222+ for (cb in seq(1 , 100 )[96 : 100 ]) {
223+ start_time <- Sys.time()
224+ seed <- cb + sample(1 : 10e6 , 1 )
225+ set.seed(seed ) # For reproducibility
213226 sim_data <- read.csv(sprintf(" %s/sim_data_%s_%s.csv" , output_sim_path , condition , cb ))
214227
215228 HumanTrialCounts <- numeric (2 ) # just a vector of zeros
@@ -340,7 +353,7 @@ for (condition in nTrials_to_sim) {
340353 condition , cb
341354 )
342355 )
343- # print(c(modelStart, s, subList[s], " pre_accuracy: ", preAccuracy, " condition_soc: ", conditionSoc))
356+
344357 # perform the fit
345358 OptimFitResults <- DEoptim(
346359 fitFunctionSSP ,
@@ -389,7 +402,7 @@ for (condition in nTrials_to_sim) {
389402
390403 newRow <- NULL
391404 # make new row with values created above
392- newRow <- data.frame (subject , bestParms1 , bestParms2 , bestParms3 , bestParms4 , bestParms5 , bestFitStat , iter , preAccuracy , conditionSoc )
405+ newRow <- data.frame (subject , bestParms1 , bestParms2 , bestParms3 , bestParms4 , bestParms5 , bestFitStat , iter , seed )
393406
394407 # appending the parms to the csv created before the loops
395408 write.table(newRow , file = sprintf(" %s/%s" , output_fit_path , output_fit_file ), sep = " ," , append = TRUE , col.names = FALSE , row.names = FALSE )
@@ -401,6 +414,6 @@ for (condition in nTrials_to_sim) {
401414 alloc_time / 60 )
402415 )
403416 } # end cb (cb) lop
404- } # end nntrials (condition) loop
417+ } # end ntrials (condition) loop
405418
406- sink()
419+ sink()
0 commit comments