Sbatch and sh files (replicating results)

Hi. I am currently trying to replicate the results of a computational model for panic disorder (you can find the pre-print article here: and the supplemental materials here: OSF | Advancing the network theory of mental disorders: A computational model of panic disorder).
The authors create a series of RDS files with random values (this is the code they use to do so: OSF), to simulate real participants and, to develop the RDS files and the random values, they apparently need to use the "sh" files (OSF and OSF).
I don't understand how they use the "sh" files and why, but I think they may be needed because when I run this code on my computer (OSF), I get the error you can see in the print pic.

Can somebody please help me? I've been trying to figure this out for weeks.

Hi @MaraPacheco10 ,

so just to clarify some things:

  • Script 1 - is used on a high performance cluster HPC (i am assuming it given the module instruction at the beginning of the script) and calls Script 2.
  • Script 2 - is the actual script that is run for every $SLURM_ARRAY_TASK_ID whatever that is for the authors.

So in short you don't need the sh files they are just used to automatize the process.

The only thing that is missing in order to call the Sim3_Intervention_LISA.R is the iter variable which is provided by the sh call and parsed with this line

# !/usr/bin/env Rscript
iter <- commandArgs(trailingOnly=TRUE)

by R.

Here a simple example:

Folder structure:
MaraPacheco10 (folder)

  • mara.R (file)
  • (file)


# !/usr/bin/env Rscript
iter <- commandArgs(trailingOnly=TRUE)



Rscript --vanilla mara.R 5

if you call from a bash (you get a bash on windows when you install git or use the default one on any unix system like debian) it will execute the code using 5 as the argument for iter (under windows R has to be in your path).

Here a gif

Now if you just want to execute the code change the first line to want you want

ignore this part

#; Oct 26th, 2023

# --------------------------------------------------------------
# ---------- Get Iteration Number ------------------------------
# --------------------------------------------------------------

# !/usr/bin/env Rscript
iter <- commandArgs(trailingOnly=TRUE)
iter <- as.numeric(iter)

ans just do

iter <- 5 #whatever number you want 

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.