R/bash/slurm
spartan
and set up the folderR
packagessource ~/.bash-profile # this is where the password is stored
sshpass -e ssh twozniak@spartan.hpc.unimelb.edu.au # connect without typing password
sinteractive # open interactive session
module load R/4.5.0 # load R
R # open R
install.packages("bsvars") # install the package
q("no") # quit R
exit # exit interactive session
slurm
file: bsvar1.slurm
R
file: bsvar1.R
set.seed(123) # set seed for reproducibility
library(bsvars) # load the package
us_fiscal_lsuw |> # use the data
specify_bsvar$new() |> # specify the model
estimate(S = 100) |> # initial estimation
estimate(S = 1000) -> # final estimation
post # store final estimation output
save( # save the output
post, # chose post object
file = paste0("bsvar1.rda") # file name
)
bsvars.sh
# upload files
sshpass -e scp bsvars/bsvar1.* twozniak@spartan.hpc.unimelb.edu.au:/data/projects/punim0093/bsvars/
sshpass -e ssh twozniak@spartan.hpc.unimelb.edu.au # connect
cd /data/projects/punim0093/bsvars/ # go to the folder
sbatch bsvar1.slurm # submit the job
squeue -u twozniak # check the queue
# download files
scp twozniak@spartan.hpc.unimelb.edu.au:/data/projects/punim0093/bsvars/*.rda bsvars/
slurm
file: bsvars.slurm
R
file: bsvars.R
args = commandArgs(trailingOnly = TRUE) # get arguments
iteration = as.integer(args[1]) # first argument is iteration
rm(args) # remove what's redundant
set.seed(123 + iteration) # set seed for reproducibility
rw = apply( # generate random walk data
matrix(rnorm(500), ncol = 2),
2,
cumsum
)
library(bsvars) # load bsvars package
rw |> # use rw data
specify_bsvar$new( # specify the model
stationary = rep(FALSE, 2) # customise specification
) |>
estimate(S = 100) |> # initial estimation
estimate(S = 1000) -> # final estimation
post # store final estimation output
save( # save the output
post, # chose post object
file = paste0("bsvars_", iteration, ".rda") # file name
)
bsvars.slurm
sshpass -e scp bsvars/bsvars.* twozniak@spartan.hpc.unimelb.edu.au:/data/projects/punim0093/bsvars/
# working with bsvars on spartan
#################################################
sshpass -e ssh twozniak@spartan.hpc.unimelb.edu.au
cd /data/projects/punim0093/bsvars/
sbatch bsvars.slurm
squeue -u twozniak
# Download files
scp twozniak@spartan.hpc.unimelb.edu.au:/data/projects/punim0093/bsvars/*.rda bsvars/
praise spartan!