```
#===================================================
# Loading the library and its dependencies
#===================================================
library("MVR")
#===================================================
# MVR package news
#===================================================
MVR.news()
#================================================
# MVR package citation
#================================================
citation("MVR")
#===================================================
# Loading of the Synthetic and Real datasets
# (see description of datasets)
#===================================================
data("Synthetic", "Real", package="MVR")
#===================================================
# Mean-Variance Regularization (Synthetic dataset)
# Single-Group Assumption
# Assuming equal variance between groups
# Without cluster usage
#===================================================
nc.min <- 1
nc.max <- 20
probs <- seq(0, 1, 0.01)
n <- 10
mvr.obj <- mvr(data = Synthetic,
block = rep(1,n),
tolog = FALSE,
nc.min = nc.min,
nc.max = nc.max,
probs = probs,
B = 100,
parallel = FALSE,
conf = NULL,
verbose = TRUE)
#===================================================
# Setup of a SOCKET cluster:
# With 1 masternode and 3 workernodes
# All hosts run identical setups
# Same number of core CPUs (8) per node
#===================================================
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" = "")
#===================================================
# Setup of a PVM cluster (requires rpvm commands):
# With 1 masternode and 3 workernodes
# All hosts run identical setups
# Same number of core CPUs (8) per node
#===================================================
if (.Platform$OS.type == "unix") {
if (!is.loaded("rpvm")) {
library("rpvm")
}
}
masterhost <- Sys.getenv("HOSTNAME")
slavehosts <- c("compute-0-0", "compute-0-1", "compute-0-2")
nodes <- length(slavehosts) + 1
cpus <- 8
conf <- list("cpus" = nodes * cpus,
"type" = "PVM",
"homo" = TRUE,
"verbose" = TRUE,
"outfile" = "")
.PVM.start.pvmd(hosts = masterhost)
.PVM.addhosts(hosts = slavehosts)
#===================================================
# Run:
# Mean-Variance Regularization (Real dataset)
# Multi-Group Assumption
# Assuming unequal variance between groups
#===================================================
nc.min <- 1
nc.max <- 30
probs <- seq(0, 1, 0.01)
n <- 6
GF <- factor(gl(n = 2, k = n/2, len = n),
ordered = FALSE,
labels = c("M", "S"))
mvr.obj <- mvr(data = Real,
block = GF,
tolog = FALSE,
nc.min = nc.min,
nc.max = nc.max,
probs = probs,
B = 100,
parallel = TRUE,
conf = conf,
verbose = TRUE)
#===================================================
# If PVM cluster used (requires rpvm commands):
#===================================================
.PVM.delhosts(hosts = slavehosts)
.PVM.delhosts(hosts = masterhost)
.PVM.halt()
#===================================================
```

Run the code above in your browser using DataLab