[Rsiena-commits] r304 - in pkg: RSiena RSiena/man RSiena/tests RSienaTest RSienaTest/man RSienaTest/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Oct 14 19:35:19 CEST 2016


Author: gvegayon
Date: 2016-10-14 19:35:19 +0200 (Fri, 14 Oct 2016)
New Revision: 304

Modified:
   pkg/RSiena/ChangeLog
   pkg/RSiena/DESCRIPTION
   pkg/RSiena/man/RSiena-package.Rd
   pkg/RSiena/man/siena07.Rd
   pkg/RSiena/tests/parallel.R
   pkg/RSienaTest/ChangeLog
   pkg/RSienaTest/DESCRIPTION
   pkg/RSienaTest/man/RSiena-package.Rd
   pkg/RSienaTest/man/siena07.Rd
   pkg/RSienaTest/tests/parallel.R
Log:
Fixing small issue in tests/parallel.R when using multiple processors + adding details on siena07, including examples (RSiena + RSienaTest).

Modified: pkg/RSiena/ChangeLog
===================================================================
--- pkg/RSiena/ChangeLog	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSiena/ChangeLog	2016-10-14 17:35:19 UTC (rev 304)
@@ -1,5 +1,10 @@
 2016-10-13 R-Forge Revision 303
 Changes in RSiena and RSienaTest (George Vega Yon):
+   * tests/parallel.R: Changing makeForkCluster to makeCluster.
+   * man/siena07.Rd: Adding a description of the -cl- option + examples.
+
+2016-10-13 R-Forge Revision 303
+Changes in RSiena and RSienaTest (George Vega Yon):
    * R/robmon.r: New argument -cl- allows users passing their own cluster,
      creating a new cluster only if length(cl) == 0.
    * R/siena07.r: Same as in robmon. Now, if the user passes -cl-, the cluster

Modified: pkg/RSiena/DESCRIPTION
===================================================================
--- pkg/RSiena/DESCRIPTION	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSiena/DESCRIPTION	2016-10-14 17:35:19 UTC (rev 304)
@@ -1,8 +1,8 @@
 Package: RSiena
 Type: Package
 Title: Siena - Simulation Investigation for Empirical Network Analysis
-Version: 1.1-303
-Date: 2016-10-13
+Version: 1.1-304
+Date: 2016-10-14
 Author: Ruth Ripley, Krists Boitmanis, Tom A.B. Snijders, Felix Schoenenberger
 Depends: R (>= 2.15.0), utils
 Imports: Matrix, tcltk, lattice, parallel, MASS, methods

Modified: pkg/RSiena/man/RSiena-package.Rd
===================================================================
--- pkg/RSiena/man/RSiena-package.Rd	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSiena/man/RSiena-package.Rd	2016-10-14 17:35:19 UTC (rev 304)
@@ -44,8 +44,8 @@
 \tabular{ll}{
 Package: \tab RSiena\cr
 Type: \tab Package\cr
-Version: \tab 1.1-303\cr
-Date: \tab 2016-10-13\cr
+Version: \tab 1.1-304\cr
+Date: \tab 2016-10-14\cr
 Depends: \tab R (>= 3.0.0)\cr
 Imports: \tab Matrix\cr
 Suggests: \tab tcltk, network, codetools, lattice, MASS, parallel,

Modified: pkg/RSiena/man/siena07.Rd
===================================================================
--- pkg/RSiena/man/siena07.Rd	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSiena/man/siena07.Rd	2016-10-14 17:35:19 UTC (rev 304)
@@ -45,7 +45,7 @@
   "PSOCK". On a single non-Windows machine may be "FORK", and
   subprocesses will be formed by forking. If "PSOCK", subprocesses are
   formed using \R scripts.}
-  \item{cl}{An object of class c("SOCKcluster", "cluster").}
+  \item{cl}{An object of class c("SOCKcluster", "cluster") (see Details).}
   \item{\dots}{Arguments for the simulation function, see
     \code{\link{simstats0c}}:
     usually, \code{data} and \code{effects}, as in the examples below;\cr
@@ -86,6 +86,17 @@
  the parameter \code{prevAns} as illustrated in the example below.\cr
  (This parameter is inserted through '\dots' into the function
  \code{\link{initializeFRAN}}.)
+
+ In the case of using multiple processors, there are two options for telling
+ \code{siena07} to use them. By specifying the options \code{useCluster}, \code{nbrNodes},
+ \code{clusterString} and \code{initC}, \code{siena07} will create a
+ \link[parallel:makeCluster]{cluster object} that will be used by the
+ \link[parallel]{parallel} package. After finishing the estimation procedure,
+ \code{siena07} will automatically stop the cluster. Alternatively, instead of
+ having the function to create a cluster, the user may provide its own by
+ specifying the option \code{cl}, similar to what the boot function does in
+ the \CRANpkg{boot} package. By using the option \code{cl} the user may be
+ able to create more complex clusters (see examples below).
 }
 \value{
   Returns an object of class \code{\link{sienaFit}}, some parts of which are:
@@ -158,15 +169,48 @@
 myeff <- getEffects(mydata)
 ans <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE)
 
-# or for non-conditional estimation
+# or for non-conditional estimation --------------------------------------------
 \dontrun{
 model <- sienaModelCreate(nsub=2, n3=100, cond=FALSE)
 ans <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE)
         }
 
-# or if a previous "on track" result ans was obtained
+# or if a previous "on track" result ans was obtained --------------------------
 \dontrun{
 ans1 <- siena07(myalgorithm, data=mydata, effects=myeff, prevAns=ans)
          }
+
+# Running in multiple processors -----------------------------------------------
+\dontrun{
+
+# Using 8 processors
+ans2 <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE,
+                useCluster=TRUE, nbrNodes=8, initC=TRUE)
+
+# Loading the parallel package and creating a cluster
+# with 8 processors (this should be equivalent)
+
+library(parallel)
+cl <- makeCluster(8)
+
+ans3 <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE,
+                cl = cl)
+
+# Notice that now -siena07- won't stop the cluster for you.
+stopCluster(cl)
+
+# You can create even more complex clusters using several computers. In this
+# example we are creating a cluster with 3*8 = 24 processors on three
+# different machines.
+cl <- makePSOCKcluster(
+    rep(c('localhost', 'machine2.website.com' , 'machine3.website.com'), 8),
+    user='myusername', rshcmd='ssh -p PORTNUMBER')
+
+ans4 <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE,
+                cl = cl)
+stopCluster(cl)
+
+
+    }
 }
 \keyword{models}

Modified: pkg/RSiena/tests/parallel.R
===================================================================
--- pkg/RSiena/tests/parallel.R	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSiena/tests/parallel.R	2016-10-14 17:35:19 UTC (rev 304)
@@ -98,7 +98,7 @@
 ##test13
 print('test13')
 library(parallel)
-cl <- makeForkCluster(2)
+cl <- makeCluster(2)
 system.time({
 ans <- siena07(sienaModelCreate(n3=50, nsub=2,seed=1, projname="test13a"),
                data=mydata, effects=myeff, batch=TRUE, silent=TRUE, cl = cl)
@@ -109,7 +109,7 @@
 system.time({
 ans <- siena07(sienaModelCreate(n3=50, nsub=2,seed=1, projname="test13b"),
                data=mydata, effects=myeff, batch=TRUE, silent=TRUE,
-               useCluster = TRUE, nbrNodes = 2, clusterType = "FORK")
+               useCluster = TRUE, nbrNodes = 2, clusterType = "PSOCK")
 })
 ans
 

Modified: pkg/RSienaTest/ChangeLog
===================================================================
--- pkg/RSienaTest/ChangeLog	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSienaTest/ChangeLog	2016-10-14 17:35:19 UTC (rev 304)
@@ -1,3 +1,8 @@
+2016-10-14 R-Forge Revision 304
+Changes in RSiena and RSienaTest (George Vega Yon):
+   * tests/parallel.R: Changing makeForkCluster to makeCluster.
+   * man/siena07.Rd: Adding a description of the -cl- option + examples. 
+
 2016-10-13 R-Forge Revision 303
 Changes in RSiena and RSienaTest (George Vega Yon):
    * R/robmon.r: New argument -cl- allows users passing their own cluster,

Modified: pkg/RSienaTest/DESCRIPTION
===================================================================
--- pkg/RSienaTest/DESCRIPTION	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSienaTest/DESCRIPTION	2016-10-14 17:35:19 UTC (rev 304)
@@ -1,8 +1,8 @@
 Package: RSienaTest
 Type: Package
 Title: Siena - Simulation Investigation for Empirical Network Analysis
-Version: 1.1-303
-Date: 2016-10-13
+Version: 1.1-304
+Date: 2016-10-14
 Author: Ruth Ripley, Krists Boitmanis, Tom A.B. Snijders, Felix Schoenenberger
 Depends: R (>= 2.15.0), utils
 Imports: Matrix, tcltk, lattice, parallel, MASS, RUnit, methods

Modified: pkg/RSienaTest/man/RSiena-package.Rd
===================================================================
--- pkg/RSienaTest/man/RSiena-package.Rd	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSienaTest/man/RSiena-package.Rd	2016-10-14 17:35:19 UTC (rev 304)
@@ -46,8 +46,8 @@
 \tabular{ll}{
 Package: \tab RSienaTest\cr
 Type: \tab Package\cr
-Version: \tab 1.1-303\cr
-Date: \tab 2016-10-13\cr
+Version: \tab 1.1-304\cr
+Date: \tab 2016-10-14\cr
 Depends: \tab R (>= 3.0.0)\cr
 Imports: \tab Matrix\cr
 Suggests: \tab tcltk, network, codetools, lattice, MASS, parallel,

Modified: pkg/RSienaTest/man/siena07.Rd
===================================================================
--- pkg/RSienaTest/man/siena07.Rd	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSienaTest/man/siena07.Rd	2016-10-14 17:35:19 UTC (rev 304)
@@ -56,7 +56,7 @@
   \item{logIncludeLocation}{
     When \code{TRUE} also log the code location (file, method, line) where the
     logging message originated.}
-  \item{cl}{An object of class c("SOCKcluster", "cluster").}
+  \item{cl}{An object of class c("SOCKcluster", "cluster") (see Details).}
   \item{\dots}{Arguments for the simulation function, see
     \code{\link{simstats0c}}:
     usually, \code{data} and \code{effects}, as in the examples below;\cr
@@ -98,6 +98,17 @@
  (This parameter is inserted through '\dots' into the function
  \code{\link{initializeFRAN}}.)
 
+ In the case of using multiple processors, there are two options for telling
+ \code{siena07} to use them. By specifying the options \code{useCluster}, \code{nbrNodes},
+ \code{clusterString} and \code{initC}, \code{siena07} will create a
+ \link[parallel:makeCluster]{cluster object} that will be used by the
+ \link[parallel]{parallel} package. After finishing the estimation procedure,
+ \code{siena07} will automatically stop the cluster. Alternatively, instead of
+ having the function to create a cluster, the user may provide its own by
+ specifying the option \code{cl}, similar to what the boot function does in
+ the \CRANpkg{boot} package. By using the option \code{cl} the user may be
+ able to create more complex clusters (see examples below).
+
  An alternative implementation is in \code{\link{sienacpp}},
  where the algorithm is coded entirely in C++;
  in \code{siena07} the 'front end' is coded in R.
@@ -173,15 +184,48 @@
 myeff <- getEffects(mydata)
 ans <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE)
 
-# or for non-conditional estimation
+# or for non-conditional estimation --------------------------------------------
 \dontrun{
 model <- sienaModelCreate(nsub=2, n3=100, cond=FALSE)
 ans <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE)
         }
 
-# or if a previous "on track" result ans was obtained
+# or if a previous "on track" result ans was obtained --------------------------
 \dontrun{
 ans1 <- siena07(myalgorithm, data=mydata, effects=myeff, prevAns=ans)
          }
+
+# Running in multiple processors -----------------------------------------------
+\dontrun{
+
+# Using 8 processors
+ans2 <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE,
+                useCluster=TRUE, nbrNodes=8, initC=TRUE)
+
+# Loading the parallel package and creating a cluster
+# with 8 processors (this should be equivalent)
+
+library(parallel)
+cl <- makeCluster(8)
+
+ans3 <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE,
+                cl = cl)
+
+# Notice that now -siena07- won't stop the cluster for you.
+stopCluster(cl)
+
+# You can create even more complex clusters using several computers. In this
+# example we are creating a cluster with 3*8 = 24 processors on three
+# different machines.
+cl <- makePSOCKcluster(
+    rep(c('localhost', 'machine2.website.com' , 'machine3.website.com'), 8),
+    user='myusername', rshcmd='ssh -p PORTNUMBER')
+
+ans4 <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE,
+                cl = cl)
+stopCluster(cl)
+
+
+    }
 }
 \keyword{models}

Modified: pkg/RSienaTest/tests/parallel.R
===================================================================
--- pkg/RSienaTest/tests/parallel.R	2016-10-13 20:55:45 UTC (rev 303)
+++ pkg/RSienaTest/tests/parallel.R	2016-10-14 17:35:19 UTC (rev 304)
@@ -109,7 +109,7 @@
 ##test14
 print('test14')
 library(parallel)
-cl <- makeForkCluster(2)
+cl <- makeCluster(2)
 system.time({
   ans <- siena07(sienaModelCreate(n3=50, nsub=2,seed=1, projname="test14a"),
                  data=mydata, effects=myeff, batch=TRUE, silent=TRUE, cl = cl)
@@ -120,7 +120,7 @@
 system.time({
   ans <- siena07(sienaModelCreate(n3=50, nsub=2,seed=1, projname="test14b"),
                  data=mydata, effects=myeff, batch=TRUE, silent=TRUE,
-                 useCluster = TRUE, nbrNodes = 2, clusterType = "FORK")
+                 useCluster = TRUE, nbrNodes = 2, clusterType = "PSOCK")
 })
 ans
 



More information about the Rsiena-commits mailing list