Hi. I am currently trying to replicate the results of a computational model for panic disorder (you can find the pre-print article here: https://osf.io/preprints/psyarxiv/km37w 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.
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)
pacheho.sh (file)
mara.R
# !/usr/bin/env Rscript
iter <- commandArgs(trailingOnly=TRUE)
rnorm(iter)
pacheho.sh
#!/bin/bash
Rscript --vanilla mara.R 5
if you call pacheho.sh 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
# jonashaslbeck@protonmail.com; Oct 26th, 2023
# --------------------------------------------------------------
# ---------- Get Iteration Number ------------------------------
# --------------------------------------------------------------
# !/usr/bin/env Rscript
iter <- commandArgs(trailingOnly=TRUE)
print(iter)
iter <- as.numeric(iter)