demo/ols.r

### SHELL> mpiexec -np 4 Rscript --vanilla [...].r

### Initial MPI.
suppressMessages(library(pbdDEMO, quietly = TRUE))
init()

### Generate balanced fake data.
comm.set.seed(1234, diff = TRUE)
N <- 100                  # Pretend N is large.
p <- 2
### Distributed data.
X.gbd <- matrix(rnorm(N * p), ncol = p)
beta <- 1:p
epsilon <- rnorm(N)
y.gbd <- X.gbd %*% beta + epsilon 

### Run.
ret.gbd <- mpi.ols(y.gbd, X.gbd)

### Output.
comm.print(ret.gbd)
finalize()

Try the pbdDEMO package in your browser

Any scripts or data that you put into this service are public.

pbdDEMO documentation built on May 2, 2019, 3:33 p.m.