#! /usr/bin/env Rscript
# This file was used to submit the simulation files to
# a slurm-based Unix system. Using the sce.sh shell script
# one can submit each simulation in sequence. First, data files are
# created for each simulation. Those data files are then analyzed
# in the 'run' execution. Then the results are collated in the 'merge'
# execution.
# get environment variables
MYSCRATCH <- Sys.getenv('MYSCRATCH')
RESULTDIR <- Sys.getenv('RESULTDIR')
STEPSIZE <- as.numeric(Sys.getenv('STEPSIZE'))
TASKID <- as.numeric(Sys.getenv('SLURM_ARRAY_TASK_ID'))
# set defaults if nothing comes from environment variables
MYSCRATCH[is.na(MYSCRATCH)] <- '.'
RESULTDIR[is.na(RESULTDIR)] <- '.'
STEPSIZE[is.na(STEPSIZE)] <- 1
TASKID[is.na(TASKID)] <- 0
# get command lines arguments
args <- commandArgs(trailingOnly = TRUE)
if(length(args) < 1){
stop("Not enough arguments. Please use args 'listsize', 'prepare', 'run <itemsize>' or 'merge'")
}
# # load packages
library(arm)
library(plyr)
library(gam, lib.loc = "/home/dbenkese/R/x86_64-unknown-linux-gnu-library/3.2")
library(caret)
library(haltmle.sim, lib.loc = "/home/dbenkese/R/x86_64-unknown-linux-gnu-library/3.2")
library(Rsolnp, lib.loc = "/home/dbenkese/R/x86_64-unknown-linux-gnu-library/3.2")
library(future, lib.loc = "/home/dbenkese/R/x86_64-unknown-linux-gnu-library/3.2")
library(cvma, lib.loc = "/home/dbenkese/R/x86_64-unknown-linux-gnu-library/3.2")
library(hal9001, lib.loc = "/home/dbenkese/R/x86_64-unknown-linux-gnu-library/3.2")
library(drtmle, lib.loc = "/home/dbenkese/R/x86_64-unknown-linux-gnu-library/3.2")
library(SuperLearner)
ns <- c(200, 2000)
min_R2 <- c(0.01, seq(0.101, 0.901, by = 0.1))
max_R2 <- c(seq(0.1,0.9,0.1),0.99)
mat_R2 <- cbind(min_R2, max_R2)
bigB <- 1000
# # simulation parameters
parm <- expand.grid(seed=1:bigB,
n=ns,
range_R2 = split(mat_R2, row(mat_R2)))
# directories to save in
saveDir <- "~/haltmle.sim/out/"
scratchDir <- "~/haltmle.sim/scratch/"
# get the list size #########
if (args[1] == 'listsize') {
cat(nrow(parm))
}
# execute prepare job ##################
if (args[1] == 'prepare') {
}
# execute parallel job #################################################
if (args[1] == 'run') {
if (length(args) < 2) {
stop("Not enough arguments. 'run' needs a second argument 'id'")
}
id <- as.numeric(args[2])
print(paste(Sys.time(), "arrid:" , id, "TASKID:",
TASKID, "STEPSIZE:", STEPSIZE))
for (i in (id+TASKID):(id+TASKID+STEPSIZE-1)) {
print(paste(Sys.time(), "i:" , i))
print(parm[i,])
set.seed(parm$seed[i])
dat <- haltmle.sim:::makeRandomDataT(n=parm$n[i], maxD = 8,
minR2 = parm$range_R2[[i]][1],
maxR2 = parm$range_R2[[i]][2])
folds <- rep(seq_len(10), length = parm$n[i])
folds <- sample(folds)
save(list(data = dat, folds = folds), file=paste0(scratchDir,"draw_n=",parm$n[i],"_seed=",parm$seed[i],
"_r2=",parm$range_R2[[i]][1],".RData"))
}
# merge job ###########################
if (args[1] == 'merge') {
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.