#===================================================
# Loading the library and its dependencies
#===================================================
library("PRIMsrc")
#===================================================
# PRIMsrc package news
#===================================================
PRIMsrc.news()
#===================================================
# PRIMsrc package citation
#===================================================
citation("PRIMsrc")
#===================================================
# Demo with a synthetic dataset
# Use help for descriptions
#===================================================
data("Synthetic.1", "Synthetic.5", "Real.1", "Real.2", package="PRIMsrc")
?Synthetic.1
?Synthetic.5
?Real.1
?Real.2
#===================================================
# Simulated dataset #1 (n=250, p=3)
# Replicated Combined Cross-Validation (RCCV)
# Peeling criterion = LRT
# Optimization criterion = LRT
# Without parallelization
# Without computation of permutation p-values
#===================================================
CVCOMBREP.synt1 <- sbh(dataset = Synthetic.1,
cvtype = "combined", cvcriterion = "lrt",
B = 1, K = 5,
vs = TRUE, cpv = FALSE, probval = 0.5,
arg = "beta=0.05,
alpha=0.1,
minn=10,
L=NULL,
peelcriterion="lr"",
parallel = FALSE, conf = NULL, seed = 123)
# selected covariates:
selected <- CVCOMBREP.synt1$selected
selected
# covariates used for peeling:
used <- CVCOMBREP.synt1$used
used
# some output results:
CVCOMBREP.synt1$cvfit$cv.maxsteps
CVCOMBREP.synt1$cvfit$cv.nsteps
CVCOMBREP.synt1$cvfit$cv.trace
CVCOMBREP.synt1$cvfit$cv.rules$frame[,used]
round(CVCOMBREP.synt1$cvfit$cv.stats$mean,2)
#===================================================
# Examples of parallel backend parametrization
#===================================================
# Example #1 - 1-Quad (4-core double threaded) PC
# Running WINDOWS
# With SOCKET communication
#===================================================
if (.Platform$OS.type == "windows") {
cpus <- detectCores()
conf <- list("names" = rep("localhost", cpus),
"cpus" = cpus,
"type" = "SOCK",
"homo" = TRUE,
"verbose" = TRUE,
"outfile" = "")
}
#===================================================
# Example #2 - 1 master node + 3 worker nodes cluster
# All nodes equipped with identical setups and multicores
# Running LINUX
# With SOCKET communication
#===================================================
if (.Platform$OS.type == "unix") {
masterhost <- Sys.getenv("HOSTNAME")
slavehosts <- c("compute-0-0", "compute-0-1", "compute-0-2")
nodes <- length(slavehosts) + 1
cpus <- 8
conf <- list("names" = c(rep(masterhost, cpus),
rep(slavehosts, cpus)),
"cpus" = nodes * cpus,
"type" = "SOCK",
"homo" = TRUE,
"verbose" = TRUE,
"outfile" = "")
}
#===================================================
# Example #3 - Multinode multicore per node cluster
# Running LINUX
# with MPI communication
# Here, a file named ".nodes" (e.g. in the home directory)
# contains the list of nodes of the cluster
#===================================================
if (.Platform$OS.type == "unix") {
hosts <- scan(file=paste(Sys.getenv("HOME"), "/.nodes", sep=""),
what="",
sep="\n")
hostnames <- unique(hosts)
nodes <- length(hostnames)
cpus <- length(hosts)/length(hostnames)
conf <- list("cpus" = nodes * cpus,
"type" = "MPI",
"homo" = TRUE,
"verbose" = TRUE,
"outfile" = "")
}
#===================================================
# Simulated dataset #1 (n=250, p=3)
# Replicated Combined Cross-Validation (RCCV)
# Peeling criterion = LRT
# Optimization criterion = LRT
# With parallelization
# With computation of permutation p-values
#===================================================
CVCOMBREP.synt1 <- sbh(dataset = Synthetic.1,
cvtype = "combined", cvcriterion = "lrt",
B = 10, K = 5, A = 1024,
vs = TRUE, cpv = TRUE, probval = 0.5,
arg = "beta=0.05,
alpha=0.1,
minn=10,
L=NULL,
peelcriterion=\"lr\"",
parallel = TRUE, conf = conf, seed = 123)
# selected covariates:
selected <- CVCOMBREP.synt1$selected
selected
# covariates used for peeling:
used <- CVCOMBREP.synt1$used
used
# some output results:
CVCOMBREP.synt1$cvfit$cv.maxsteps
CVCOMBREP.synt1$cvfit$cv.nsteps
CVCOMBREP.synt1$cvfit$cv.trace
CVCOMBREP.synt1$cvfit$cv.pval
CVCOMBREP.synt1$cvfit$cv.rules$frame[,used]
round(CVCOMBREP.synt1$cvfit$cv.stats$mean,2)
Run the code above in your browser using DataLab