[Rsiena-commits] r348 - in pkg: RSiena RSiena/R RSiena/man RSiena/tests RSienaTest RSienaTest/R RSienaTest/doc RSienaTest/man RSienaTest/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 8 17:20:17 CEST 2020


Author: tomsnijders
Date: 2020-04-08 17:20:15 +0200 (Wed, 08 Apr 2020)
New Revision: 348

Modified:
   pkg/RSiena/ChangeLog
   pkg/RSiena/DESCRIPTION
   pkg/RSiena/R/initializeFRAN.r
   pkg/RSiena/R/sienaDataCreate.r
   pkg/RSiena/R/sienaGOF.r
   pkg/RSiena/R/sienaModelCreate.r
   pkg/RSiena/R/sienaprint.r
   pkg/RSiena/man/RSiena-package.Rd
   pkg/RSiena/man/siena07.Rd
   pkg/RSiena/man/sienaGOF-auxiliary.Rd
   pkg/RSiena/man/sienaGOF.Rd
   pkg/RSiena/tests/parallel.Rout.save
   pkg/RSienaTest/ChangeLog
   pkg/RSienaTest/DESCRIPTION
   pkg/RSienaTest/R/bayesTest.r
   pkg/RSienaTest/R/initializeFRAN.r
   pkg/RSienaTest/R/sienaDataCreate.r
   pkg/RSienaTest/R/sienaGOF.r
   pkg/RSienaTest/R/sienaModelCreate.r
   pkg/RSienaTest/R/sienaprint.r
   pkg/RSienaTest/doc/RSiena.bib
   pkg/RSienaTest/doc/RSienaDeveloper.tex
   pkg/RSienaTest/doc/RSiena_Manual.pdf
   pkg/RSienaTest/doc/RSiena_Manual.tex
   pkg/RSienaTest/man/RSiena-package.Rd
   pkg/RSienaTest/man/siena07.Rd
   pkg/RSienaTest/man/sienaGOF-auxiliary.Rd
   pkg/RSienaTest/man/sienaGOF.Rd
   pkg/RSienaTest/tests/parallel.Rout.save
Log:
Version 1.2-25

Modified: pkg/RSiena/ChangeLog
===================================================================
--- pkg/RSiena/ChangeLog	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/ChangeLog	2020-04-08 15:20:15 UTC (rev 348)
@@ -1,5 +1,22 @@
+2020-04-08 R-Forge Revision 348, package version 1.2-25.
+Changes in RSiena and RSienaTest:
+   * Correction of sienaDataCreate for actor covariates (gave a warning).
+   * Auxiliary function dyadicCov now can handle missings,
+     does not return a named value for frequency of zeros,
+     and returns the frequencies without any division.
+   * descriptives.sienaGOF also shows the exceedance probabilities
+     of the observed statistics.
+   * modelType and behModelType, if NULL, get their defaults already in
+     initializeFRAN (checkNames) rather than in C++.
+   * Some extra information in help page for siena07.
+Changes in RSienaTest:
+   * getNames corrected for data with multiple periods
+     (used in sienaBayes, extract.sienaBayes, and extract.posteriorMeans)
+check bayesTest.getNames, voor extract.sienaBayes en extract.posteriorMeans !!!
+   
+
 2020-02-16 R-Forge Revision 347, package version 1.2-24.
-   * Changes in RSiena and RSienaTest:
+Changes in RSiena and RSienaTest:
    * New auxiliary function dyadicCov.
    * Correction of error in modelType when one-mode as well as two-mode
      networks are used (initializeFRAN.r).

Modified: pkg/RSiena/DESCRIPTION
===================================================================
--- pkg/RSiena/DESCRIPTION	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/DESCRIPTION	2020-04-08 15:20:15 UTC (rev 348)
@@ -2,8 +2,8 @@
 Package: RSiena
 Type: Package
 Title: Siena - Simulation Investigation for Empirical Network Analysis
-Version: 1.2-24
-Date: 2020-02-16
+Version: 1.2-25
+Date: 2020-04-08
 Author: Ruth Ripley, Krists Boitmanis, Tom A.B. Snijders, Felix Schoenenberger,
    Nynke Niezink
 Depends: R (>= 2.15.0)

Modified: pkg/RSiena/R/initializeFRAN.r
===================================================================
--- pkg/RSiena/R/initializeFRAN.r	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/R/initializeFRAN.r	2020-04-08 15:20:15 UTC (rev 348)
@@ -19,6 +19,8 @@
 	##@checkNames used in initializeFRAN for siena07
 	checkNames <- function(xx, types) {
 		# checks whether names of named vectors are in names of dependent variables.
+		# returns xx; if is.null(xx), returns named vector
+		# with variable names and all values 1.
 		if (('oneMode' %in% types) || ('bipartite' %in% types))
 		{
 			thetype <- 'network'
@@ -49,6 +51,8 @@
 		if (is.null(xx))
 		{
 			wrongName <- FALSE
+			xx <- rep(1, sum(theVars))
+			names(xx) <- theVarNames
 		}
 		else
 		{
@@ -73,7 +77,7 @@
 				stop('Invalid algorithm-data combination.')
 			}
 		}
-		invisible(!wrongName)
+		xx
 	}
 
 	# start of initializeFRAN proper
@@ -138,10 +142,12 @@
 		}
 
 		# Check that the following attributes have correct names
+		# and change NULL to default values for x$modelType and x$behModelType
+		# For symmetric networks, default is changed below from 1 to 2.
 		checkNames(x$MaxDegree, c('oneMode','bipartite'))
 		checkNames(x$UniversalOffset, c('oneMode','bipartite'))
-		checkNames(x$modelType, c('oneMode','bipartite'))
-		checkNames(x$behModelType, 'behavior')
+		x$modelType <- checkNames(x$modelType, c('oneMode','bipartite'))
+		x$behModelType <- checkNames(x$behModelType, 'behavior')
 		# The following error will occur if ML estimation is requested
 		# and there are any impossible changes from structural values
 		# to different observed values.
@@ -657,7 +663,7 @@
 		UNIVERSALOFFSET <- x$UniversalOffset
 		storage.mode(UNIVERSALOFFSET) <- "double"
 	}
-	if ((length(x$modelType) == 0)||(x$modelType == 0) || is.null(x$modelType))
+	if ((length(x$modelType) == 0)||all(x$modelType == 0) || is.null(x$modelType))
 	{
 		MODELTYPE <-  NULL
 	}

Modified: pkg/RSiena/R/sienaDataCreate.r
===================================================================
--- pkg/RSiena/R/sienaDataCreate.r	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/R/sienaDataCreate.r	2020-04-08 15:20:15 UTC (rev 348)
@@ -2391,7 +2391,7 @@
 	for (i in seq(along=z$cCovars))
 	{
 		nodeSet <- attr(z$cCovars[[i]], "nodeSet")
-		use <- (netTypes != "behavior" & netActorSet == nodeSet)
+		use <- (!(netTypes %in% c("behavior", "continuous")) & (netActorSet == nodeSet))
 		simMeans <- namedVector(NA, netNames[use])
 		for (j in which(use))
 		{
@@ -2404,7 +2404,7 @@
 	for (i in seq(along=z$vCovars))
 	{
 		nodeSet <- attr(z$vCovars[[i]], "nodeSet")
-		use <- (netTypes != "behavior" & netActorSet == nodeSet)
+		use <- (!(netTypes %in% c("behavior", "continuous")) & (netActorSet == nodeSet))
 		simMeans <- namedVector(NA, netNames[use])
 		for (j in which(use))
 		{

Modified: pkg/RSiena/R/sienaGOF.r
===================================================================
--- pkg/RSiena/R/sienaGOF.r	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/R/sienaGOF.r	2020-04-08 15:20:15 UTC (rev 348)
@@ -867,7 +867,9 @@
 				sort(sims[,i])[ind.lower]  )
 	yperc.upper = sapply(1:ncol(sims), function(i)
 				sort(sims[,i])[ind.upper]  )
-	violins <- matrix(NA, 7, ncol(sims))
+	ypg <- sapply(1:ncol(sims), function(i)	mean(sims[,i] > obs[1,i]))
+	ypp <- sapply(1:ncol(sims), function(i)	mean(sims[,i] >= obs[1,i]))
+    violins <- matrix(NA, 9, ncol(sims))
 	violins[1,] <- sims.themax
 	violins[2,] <- yperc.upper
 	violins[3,] <- sims.mean
@@ -875,8 +877,10 @@
 	violins[5,] <- yperc.lower
 	violins[6,] <- sims.themin
 	violins[7,] <- obs
-	rownames(violins) <- c('max', 'perc.upper', 'mean',
-							'median', 'perc.lower', 'min', 'obs')
+    violins[8, ] <- ypg
+    violins[9, ] <- ypp
+    rownames(violins) <- c("max", "perc.upper", "mean", "median",
+        "perc.lower", "min", "obs", "p>", "p>=")
 	colnames(violins) <- key
 	violins
 }
@@ -1407,25 +1411,19 @@
 # certain values of the categorical dyadic covariate dc.
 # dc should be a matrix of the same dimensions as
 # the dependent variable.
-dyadicCov <-  function (i, obsData, sims, period, groupName,
-                           varName, dc, dc.table=NULL){
+# Frequencies of ties with dc == 0 are not counted.
+dyadicCov <-  function (i, obsData, sims, period, groupName, varName, dc){
 	m <- sparseMatrixExtraction(i, obsData, sims, period, groupName, varName)
-	tmdyv <- table((m*dc)@x) # note that m*dc is a sparse matrix, too
-	if (is.null(dc.table))
-	{
-		tdyv <- table(dc)
-	}
-	else
-	{
-		tdyv <- dc.table
-	}
-	# Now we want to construct the proportions of m*dyv in dyv;
-	# and categories in dyv not represented in m*dyv should get a 0.
-	# First make a vector of the correct length with 0s in place.
+    tmdyv <- table((m * dc)@x, useNA="no") # note that m*dc is a sparse matrix, too
+	values <- unique(as.vector(dc))
+	tdyv <- sort(values[!is.na(values)])
+	tdyv <- tdyv[-which(tdyv==0)] # if 0 is included, take it out
+	# Now we want to construct the table of numbers of m*dyv;
+	# and categories in dc not represented in m*dyv should get a 0.
+	# First make a named vector of the correct length with 0s in place.
 	ttmdyv <- 0*tdyv
+	names(ttmdyv) <- tdyv
 	dims <- dimnames(tmdyv)[[1]]
-	ttmdyv[dims] <- tmdyv
-	z <- ttmdyv/tdyv
-#	names(z) <- dims
-	z
+	ttmdyv[dims] <- tmdyv # The other entries remain 0
+	ttmdyv
 }

Modified: pkg/RSiena/R/sienaModelCreate.r
===================================================================
--- pkg/RSiena/R/sienaModelCreate.r	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/R/sienaModelCreate.r	2020-04-08 15:20:15 UTC (rev 348)
@@ -28,7 +28,7 @@
 	if (is.null(projname))
 	{
 		model$projname <- tempfile("Siena")
-		cat('siena07 will create an output file', 
+		cat('If you use this algorithm object, siena07 will create an output file',
 				paste(model$projname,'.txt',sep=''),'.\n')
 		cat('This is a temporary file for this R session.\n')
 	}
@@ -37,7 +37,7 @@
 		if (is.character(projname))
 		{
 			model$projname <- projname
-			cat('siena07 will create an output file', 
+			cat('If you use this algorithm object, siena07 will create an output file', 
 				paste(model$projname,'.txt',sep=''),'.\n')
 		}
 		else

Modified: pkg/RSiena/R/sienaprint.r
===================================================================
--- pkg/RSiena/R/sienaprint.r	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/R/sienaprint.r	2020-04-08 15:20:15 UTC (rev 348)
@@ -400,12 +400,12 @@
 			cat("\nSimulated statistics are in ", objectName,'$sf',sep="")
 			if (x$returnDeps)
 			{
-				cat("\nand simulated dependent variables in ",
-								objectName,'$sims.\n',sep="")
+				cat("\nand simulated dependent variables in ", objectName,
+					'$sims, where ', objectName,' is the created object.\n',sep="")
 			}
 			else
 			{
-				cat(".\n")
+				cat(", where", objectName, "is the created object.\n")
 			}
 		}
 		else

Modified: pkg/RSiena/man/RSiena-package.Rd
===================================================================
--- pkg/RSiena/man/RSiena-package.Rd	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/man/RSiena-package.Rd	2020-04-08 15:20:15 UTC (rev 348)
@@ -36,6 +36,7 @@
   and which can be created by \code{\link{sienaAlgorithmCreate}}.
 
   Function \code{\link{siena07}} is used to fit a model.
+ Function \code{\link{sienaGOF}} can be used for studying goodness of fit.
 
   A general introduction to the method is available in the tutorial paper
   Snijders, van de Bunt, and Steglich (2010).
@@ -44,8 +45,8 @@
   \tabular{ll}{
     Package: \tab RSiena\cr
     Type: \tab Package\cr
-    Version: \tab 1.2-24\cr
-    Date: \tab 2020-02-16\cr
+    Version: \tab 1.2-25\cr
+    Date: \tab 2020-04-06\cr
     Depends: \tab R (>= 3.0.0)\cr
     Imports: \tab Matrix\cr
     Suggests: \tab tcltk, network, codetools, lattice, MASS, parallel,
@@ -103,7 +104,7 @@
 myeff <- getEffects(mydata)
 myeff <- includeEffects(myeff, transTrip)
 myeff
-myalgorithm <- sienaAlgorithmCreate(nsub=3, n3=200, projname=NULL)
+myalgorithm <- sienaAlgorithmCreate(nsub=3, n3=200)
 ans <- siena07(myalgorithm, data=mydata, effects=myeff, batch=TRUE)
 summary(ans)
 }

Modified: pkg/RSiena/man/siena07.Rd
===================================================================
--- pkg/RSiena/man/siena07.Rd	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/man/siena07.Rd	2020-04-08 15:20:15 UTC (rev 348)
@@ -65,6 +65,8 @@
     of ministeps should be returned; this may produce a very big file.}
 }
 \details{
+  This is the main function and workhorse of RSienaTest.
+
   For use of \code{siena07}, it is necessary to specify parameters \code{data}
   (RSiena data set) and \code{effects} (effects object), which are
   required parameters in function \code{\link{simstats0c}}.
@@ -82,7 +84,7 @@
  simulation to estimate standard errors and check convergence of the model. The
  simulation function is called once for each iteration in these phases
  and also once to initialise the model fitting and once to complete it.
- Unless in batch mode, displays a tcl/tk screen to allow interruption
+ Unless in batch mode, a tcl/tk screen is displayed to allow interruption
  and to show progress.
 
  If  \code{x$maxlike=TRUE}, estimation is done by Maximum Likelihood
@@ -99,6 +101,12 @@
  (This parameter is inserted through '\dots' into the function
  \code{\link{initializeFRAN}}.)
 
+ For good estimation of standard errors, it is necessary that \code{x$n3} is
+ large enough. More about this is in the manual. The default value \code{x$n3}
+ set in \code{\link{sienaAlgorithmCreate}} is adequate for most explorative use,
+ but for presentation in publications larger values are necessary, depending
+ on the data set and model; e.g., \code{x$n3=3000} or larger.
+
  Parameters can be tested against zero by dividing the estimate by its
  standard error and using an approximate standard normal null distribution.
  Further, functions \code{\link{Wald.RSiena}} and
@@ -174,7 +182,11 @@
     estimated means of estimation statistics.}
  \item{sims}{If \code{returnDeps=TRUE}:
     list of simulated dependent variables (networks, behaviour).
-    Networks are given as a list of edgelists, one for each period.}
+    Networks are given as a list of edgelists, one for each period.\cr
+    The structure of sims is a nested list:
+    \code{sims[[run]][[group]][[dependent variable]][[period]]}.
+    If \code{x$maxlike=TRUE} and there is only one group and one period,
+    the structure is \code{[[run]][[dependent variable]]}.}
  \item{chain}{If \code{returnChains = TRUE}:
     list, or data frame, of simulated chains of ministeps.
     The chain has the structure
@@ -223,7 +235,7 @@
   There are print, summary and xtable methods for \code{\link{sienaFit}}
   objects: \code{\link{xtable}}, \code{\link{print.sienaFit}}.}
 \examples{
-myalgorithm <- sienaAlgorithmCreate(nsub=2, n3=100, seed=1293, projname=NULL)
+myalgorithm <- sienaAlgorithmCreate(nsub=2, n3=100, seed=1293)
 # nsub=2 and n3=100 is used here for having a brief computation, not for practice.
 mynet1 <- sienaDependent(array(c(tmp3, tmp4), dim=c(32, 32, 2)))
 mydata <- sienaDataCreate(mynet1)
@@ -294,7 +306,7 @@
 mats <- array(c(mat1,mat2,mat3), dim=c(4,4,3))
 net <- sienaDependent(mats, allowOnly=FALSE)
 sdat <- sienaDataCreate(net)
-alg <- sienaAlgorithmCreate(maxlike=TRUE, nsub=3, n3=100, seed=12534, projname=NULL)
+alg <- sienaAlgorithmCreate(maxlike=TRUE, nsub=3, n3=100, seed=12534)
 effs <- getEffects(sdat)
 (ans <- siena07(alg, data=sdat, effects=effs, returnDeps=TRUE, batch=TRUE))
 # See manual Section 9.1 for information about the following functions
@@ -312,9 +324,13 @@
 n <- 4
 ego <- rep.int(1:n,n)
 alter <- rep(1:n, each=n)
+# Get the average simulated adjacency matrices for wave 3 (period 2):
 ones <- sapply(1:n^2, function(i)
     {mean(sapply(ans$sims,
            function(x){the.edge(x[[1]][[2]][[1]],n,ego[i],alter[i])}))})
+# Note that for maximum likelihood estimation,
+# if there is one group and one period,
+# the nesting levels for group and period are dropped from ans$sims.
 cbind(ego,alter,ones)
 matrix(ones,n,n)
 }

Modified: pkg/RSiena/man/sienaGOF-auxiliary.Rd
===================================================================
--- pkg/RSiena/man/sienaGOF-auxiliary.Rd	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/man/sienaGOF-auxiliary.Rd	2020-04-08 15:20:15 UTC (rev 348)
@@ -43,8 +43,7 @@
 
 mixedTriadCensus(i, obsData, sims, period, groupName, varName)
 
-dyadicCov(i, obsData, sims, period, groupName, varName,
-          dc, dc.table=NULL)
+dyadicCov(i, obsData, sims, period, groupName, varName, dc)
 
 sparseMatrixExtraction(i, obsData, sims, period, groupName, varName)
 
@@ -74,9 +73,6 @@
     cumulative (<=) distributions?}
   \item{dc}{Dyadic covariate: matrix with the same dimensions as
     adjacency matrix for dependent network variable.}
-  \item{dc.table}{Used as denominator for counts of dc. Can be given as
-    table for dc, calculated in advance, to circumvent calculating
-    \code{table(dc)} a large number of times.}
 }
 \details{
  The statistics should be chosen to represent features of the network
@@ -113,9 +109,10 @@
  the \code{sna} procedure may be faster.
 
  \code{dyadicCov} assumes that \code{dc} is a categorical dyadic variable,
- and the frequencies of the values for realized ties are returned divided by
- the elements of \code{dc.table}, which normally is the table of
- overall frequencies of values of \code{dc}.
+ and returns the frequencies of the non-zero values for realized ties.
+ Since zero values of dc are not counted, it may be advisable
+ to code dc so that all non-diagonal values are non-zero,
+ and all diagonal values are zero.
  }
 
 \value{
@@ -134,6 +131,9 @@
  \code{mixedTriadCensus} returns a named vector, the distribution of the
   mixed triad census of Hollway, Lomi, Pallotti,and Stadtfeld (2017).
 
+ \code{dyadicCov} returns a named vector, the frequencies of the non-missing
+  non-zero values dc(ego,alter) of the observed or simulated (ego,alter) ties.
+
  \code{sparseMatrixExtraction} returns the simulated network as a
   \code{dgCMatrix};
   this is the "standard" class for sparse numeric matrices in the
@@ -189,8 +189,8 @@
 
 mynet1 <- sienaDependent(array(c(s501, s502), dim=c(50, 50, 2)))
 mybeh <- sienaDependent(s50a[,1:2], type="behavior")
-mydycov <- matrix(rep(1:5, 500), 50, 50) # artificial, just for trying
-mydy.table <- table(mydycov)
+mycov <- c(rep(1:3,16),1,2) # artificial, just for trying
+mydycov <- matrix(rep(1:5, 500), 50, 50) # also artificial, just for trying
 mydata <- sienaDataCreate(mynet1, mybeh)
 myeff <- getEffects(mydata)
 myeff <- includeEffects(myeff, transTies, cycle3)
@@ -203,7 +203,7 @@
 OutdegreeDistribution(NULL, ans$f, ans$sims, period=1, groupName="Data1",
   levls=0:7, varName="mynet1")
 dyadicCov(NULL, ans$f, ans$sims, period=1, groupName="Data1",
-  dc=mydycov, dc.table=mydy.table, varName="mynet1")
+  dc=mydycov, varName="mynet1")
 # An arbitrary selection for simulation run i:
 IndegreeDistribution(5, ans$f, ans$sims, period=1, groupName="Data1",
   varName="mynet1")
@@ -227,9 +227,27 @@
 plot(gofo)
 
 (gofdc <- sienaGOF(ans, dyadicCov, verbose=TRUE, join=TRUE,
-    dc=mydycov, dc.table=mydy.table, varName="mynet1"))
+    dc=mydycov, varName="mynet1"))
 plot(gofdc)
 
+# How to use dyadicCov for ego-alter combinations of a monadic variable:
+mycov.egoalter <- outer(10*mycov, mycov ,'+')
+diag(mycov.egoalter) <- 0
+dim(mycov.egoalter) # 50 * 50 matrix
+# This is a dyadic variable indicating ego-alter combinations of mycov.
+# This construction works since mycov has integer values 
+# not outside the interval from 1 to 9.
+# All cells of this matrix contain a two-digit number,
+# left digit is row (ego) value, right digit is column (alter) value.
+# See the top left part of the matrix:
+mycov.egoalter[1:10,1:12]
+# The number of values is the square of the number of values of mycov;
+# therefore, unwise to do this for a monadic covariate with more than 5 values.
+gof.mycov <- sienaGOF(ans, dyadicCov, verbose=TRUE, varName="mynet1", 
+    dc=mycov.egoalter)  
+plot(gof.mycov)
+descriptives.sienaGOF(gof.mycov, showAll=TRUE)
+
 (gofb <- sienaGOF(ans, BehaviorDistribution, varName = "mybeh",
     verbose=TRUE, join=TRUE, cumulative=FALSE))
 plot(gofb)

Modified: pkg/RSiena/man/sienaGOF.Rd
===================================================================
--- pkg/RSiena/man/sienaGOF.Rd	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/man/sienaGOF.Rd	2020-04-08 15:20:15 UTC (rev 348)
@@ -203,8 +203,10 @@
     \code{descriptives.sienaGOF} returns a matrix giving numerical
     information about what is plotted in the \code{plot} method:
     maximum, upper percentile, mean, median, lower percentile, minimum,
-    of the simulated distributions of the auxiliary statistics, and the
-    observed values. If \code{center=TRUE} the median is subtracted
+    of the simulated distributions of the auxiliary statistics, the
+    observed values, and the proportions of simulated values greater
+    and greater-or-equal than the observed values. 
+    If \code{center=TRUE} the median is subtracted
     from mean, median, and percentiles; if \code{scale=TRUE}
     these numbers are divided by (maximum - minimum). \cr
     If \code{showAll=FALSE}, statistics with variance 0 will be dropped.

Modified: pkg/RSiena/tests/parallel.Rout.save
===================================================================
--- pkg/RSiena/tests/parallel.Rout.save	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSiena/tests/parallel.Rout.save	2020-04-08 15:20:15 UTC (rev 348)
@@ -1,6 +1,6 @@
 
-R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
-Copyright (C) 2019 The R Foundation for Statistical Computing
+R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
+Copyright (C) 2020 The R Foundation for Statistical Computing
 Platform: x86_64-w64-mingw32/x64 (64-bit)
 
 R is free software and comes with ABSOLUTELY NO WARRANTY.
@@ -24,7 +24,7 @@
 > myeff<- getEffects(mydata)
 > mymodel<- model.create(findiff=TRUE, fn = simstats0c,
 +                        cond=FALSE, nsub=2, n3=50, seed=3)
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 > print('test3')
 [1] "test3"
 > ans<- siena07(mymodel, data=mydata, effects=myeff,
@@ -96,7 +96,7 @@
 > myeff<- getEffects(mydata)
 > mymodel<- model.create(fn = simstats0c,  nsub=2, n3=50,
 +                        cond=FALSE, seed=5)
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 > print('test5')
 [1] "test5"
 > ans<- siena07(mymodel, data=mydata, effects=myeff,  batch=TRUE,
@@ -153,7 +153,7 @@
 > myeff<- getEffects(mydata)
 > mymodel<- model.create(fn = simstats0c,  nsub=2, n3=50,
 +                        cond=FALSE, doubleAveraging=0,seed=5)
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 > print('test6')
 [1] "test6"
 > ans<- siena07(mymodel, data=mydata, effects=myeff,  batch=TRUE,
@@ -178,7 +178,7 @@
 > myeff<- getEffects(mydata)
 > mymodel<- model.create(fn = simstats0c,  nsub=2, n3=50,
 +                        cond=FALSE,  diagonalize=0.5, seed=5)
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 > print('test7')
 [1] "test7"
 > ans<- siena07(mymodel, data=mydata, effects=myeff,  batch=TRUE,
@@ -201,7 +201,7 @@
 > ##test8
 > mymodel<- model.create(fn = simstats0c,  nsub=1, n3=50,
 +                        cond=TRUE, condvarno=1, seed=5)
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 > print('test8')
 [1] "test8"
 > ans <- siena07(mymodel, data=mydata, effects=myeff,  batch=TRUE,
@@ -278,7 +278,7 @@
 [1] "test11"
 > mymodel<- model.create(fn = simstats0c,  nsub=1, n3=50,
 +                        behModelType=c(mynet2=2), seed=6)
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 > (ans <- siena07(mymodel, data=mydata, effects=myeff, batch=TRUE,
 +                parallelTesting=TRUE, silent=TRUE))
 Estimates, standard errors and convergence t-ratios
@@ -327,7 +327,7 @@
 1 myvar1 in-alter dist 2 TRUE    FALSE FALSE          0   1   
 > ans <- siena07(sienaModelCreate(n3=50, nsub=2, seed=1),
 +                data=mydata, effects=myeff, batch=TRUE, silent=TRUE)
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 > ans
 Estimates, standard errors and convergence t-ratios
 
@@ -407,7 +407,7 @@
 1 myvar1 ego TRUE    FALSE FALSE          0   0   
 > (ans <- siena07(sienaModelCreate(n3=50, nsub=2, seed=1),
 +                data=mydata, effects=myeff, batch=TRUE, silent=TRUE))
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 Estimates, standard errors and convergence t-ratios
 
                                  Estimate   Standard   Convergence 
@@ -436,7 +436,7 @@
   effectName            include fix   test  initialValue parm
 1 indegree - popularity TRUE    FALSE FALSE          0   0   
 > algo <- sienaAlgorithmCreate(nsub=1, n3=20, maxlike=TRUE, seed=15, mult=1)
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 > (ans <- siena07(algo, data=dataset, effects=myeff, batch=TRUE, silent=TRUE))
 Estimated by Maximum Likelihood
 
@@ -493,7 +493,7 @@
 6 behavior feedback from behavior      TRUE    FALSE FALSE   -0.11172   0
 7 behavior intercept                   TRUE    FALSE FALSE   -0.86402   0
 > algorithmMoM <- sienaAlgorithmCreate(nsub=1, n3=20, seed=321)
-siena07 will create an output file Siena.txt .
+If you use this algorithm object, siena07 will create an output file Siena.txt .
 > (ans <- siena07(algorithmMoM, data = mydata, effects = myeff, batch=TRUE))
 SDE init parameters:  -0.1519645 -1.175127 0.7355777
 SDE par stand errors: 0.06428706 0.2889378 0.1507865
@@ -569,4 +569,4 @@
 > 
 > proc.time()
    user  system elapsed 
-  16.35    0.70   17.09 
+  18.90    0.64   19.75 

Modified: pkg/RSienaTest/ChangeLog
===================================================================
--- pkg/RSienaTest/ChangeLog	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSienaTest/ChangeLog	2020-04-08 15:20:15 UTC (rev 348)
@@ -1,5 +1,21 @@
+2020-04-08 R-Forge Revision 348, package version 1.2-25.
+Changes in RSiena and RSienaTest:
+   * Correction of sienaDataCreate for actor covariates (gave a warning).
+   * Auxiliary function dyadicCov now can handle missings,
+     does not return a named value for frequency of zeros,
+     and returns the frequencies without any division.
+   * descriptives.sienaGOF also shows the exceedance probabilities
+     of the observed statistics.
+   * modelType and behModelType, if NULL, get their defaults already in
+     initializeFRAN (checkNames) rather than in C++.
+   * Some extra information in help page for siena07.
+Changes in RSienaTest:
+   * getNames corrected for data with multiple periods
+     (used in sienaBayes, extract.sienaBayes, and extract.posteriorMeans)
+  
+
 2020-02-16 R-Forge Revision 347, package version 1.2-24.
-   * Changes in RSiena and RSienaTest:
+Changes in RSiena and RSienaTest:
    * New auxiliary function dyadicCov.
    * Correction of error in modelType when one-mode as well as two-mode
      networks are used (initializeFRAN.r).

Modified: pkg/RSienaTest/DESCRIPTION
===================================================================
--- pkg/RSienaTest/DESCRIPTION	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSienaTest/DESCRIPTION	2020-04-08 15:20:15 UTC (rev 348)
@@ -2,8 +2,8 @@
 Package: RSienaTest
 Type: Package
 Title: Siena - Simulation Investigation for Empirical Network Analysis
-Version: 1.2-24
-Date: 2020-02-16
+Version: 1.2-25
+Date: 2020-04-08
 Author: Ruth Ripley, Krists Boitmanis, Tom A.B. Snijders, Felix Schoenenberger,
    Nynke Niezink
 Depends: R (>= 2.15.0)

Modified: pkg/RSienaTest/R/bayesTest.r
===================================================================
--- pkg/RSienaTest/R/bayesTest.r	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSienaTest/R/bayesTest.r	2020-04-08 15:20:15 UTC (rev 348)
@@ -265,30 +265,26 @@
 		# and with "unspecified interaction" replaced by
 		# information about the effects in question
 		b <- x$basicRate
-		tpar<- rep(NA,length(b))
 		# True Parameters, i.e., all except rate parameters for groups 2 and up.
-		for (i in (2:length(b))){tpar[i] <- !b[i]|(b[i]&!b[i-1])}
-		tpar[1] <- TRUE
+# earlier, can be deleted when checked:
+#		tpar<- rep(NA,length(b))
+#		for (i in (2:length(b))){tpar[i] <- !b[i]|(b[i]&!b[i-1])}
+#		tpar[1] <- TRUE
+		tpar <- !x$basicRate
+		tpar[unlist(x$rateParameterPosition[[1]])] <- TRUE
+		theNames <- x$requestedEffects$effectName[tpar]
+		if (length(unlist(x$rateParameterPosition[[1]]) <= 1))
+		{
 		# Take away the ' (period 1)' in the first rate parameter
-		sub(' (period 1)','', x$requestedEffects$effectName[tpar], fixed=TRUE)
+			theNames <- sub(' (period 1)','', theNames, fixed=TRUE)
+		}
+		theNames
 }
 
-
 ##@extract.sienaBayes extracts samples from sienaBayesFit objects
 extract.sienaBayes <- function(zlist, nfirst=zlist[[1]]$nwarm+1, extracted,
-	sdLog=TRUE){
-	getNames <- function(x){
-		# effect names without duplicated rate parameters
-		# and with "unspecified interaction" replaced by
-		# information about the effects in question
-		b <- x$basicRate
-		tpar<- rep(NA,length(b))
-		# True Parameters, i.e., all except rate parameters for groups 2 and up.
-		for (i in (2:length(b))){tpar[i] <- !b[i]|(b[i]&!b[i-1])}
-		tpar[1] <- TRUE
-		# Take away the ' (period 1)' in the first rate parameter
-		sub(' (period 1)','', x$requestedEffects$effectName[tpar], fixed=TRUE)
-	}
+	sdLog=TRUE)
+{
 	if (!(is.list(zlist)))
 	{
 		stop('zlist must be a list of sienaBayesFit objects')
@@ -429,18 +425,6 @@
 # produces a matrix with the groups in the rows
 # and all effects in the columns, with for each effect
 # first the posterior mean ("p.m.") and then the posterior standard deviation ("psd.")
-	getNames <- function(x){
-		# effect names without duplicated rate parameters
-		# and with "unspecified interaction" replaced by
-		# information about the effects in question
-		b <- x$basicRate
-		tpar<- rep(NA,length(b))
-		# True Parameters, i.e., all except rate parameters for groups 2 and up.
-		for (i in (2:length(b))){tpar[i] <- !b[i]|(b[i]&!b[i-1])}
-		tpar[1] <- TRUE
-		# Take away the ' (period 1)' in the first rate parameter
-		sub(' (period 1)','', x$requestedEffects$effectName[tpar], fixed=TRUE)
-	}
 	if (!inherits(z, "sienaBayesFit"))
 	{
 		stop('z must be a sienaBayesFit object')

Modified: pkg/RSienaTest/R/initializeFRAN.r
===================================================================
--- pkg/RSienaTest/R/initializeFRAN.r	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSienaTest/R/initializeFRAN.r	2020-04-08 15:20:15 UTC (rev 348)
@@ -19,6 +19,8 @@
 	##@checkNames used in initializeFRAN for siena07
 	checkNames <- function(xx, types) {
 		# checks whether names of named vectors are in names of dependent variables.
+		# returns xx; if is.null(xx), returns named vector
+		# with variable names and all values 1.
 		if (('oneMode' %in% types) || ('bipartite' %in% types))
 		{
 			thetype <- 'network'
@@ -49,6 +51,8 @@
 		if (is.null(xx))
 		{
 			wrongName <- FALSE
+			xx <- rep(1, sum(theVars))
+			names(xx) <- theVarNames
 		}
 		else
 		{
@@ -73,7 +77,7 @@
 				stop('Invalid algorithm-data combination.')
 			}
 		}
-		invisible(!wrongName)
+		xx
 	}
 
 	# start of initializeFRAN proper
@@ -138,10 +142,12 @@
 		}
 
 		# Check that the following attributes have correct names
+		# and change NULL to default values for x$modelType and x$behModelType
+		# For symmetric networks, default is changed below from 1 to 2.
 		checkNames(x$MaxDegree, c('oneMode','bipartite'))
 		checkNames(x$UniversalOffset, c('oneMode','bipartite'))
-		checkNames(x$modelType, c('oneMode','bipartite'))
-		checkNames(x$behModelType, 'behavior')
+		x$modelType <- checkNames(x$modelType, c('oneMode','bipartite'))
+		x$behModelType <- checkNames(x$behModelType, 'behavior')
 		# The following error will occur if ML estimation is requested
 		# and there are any impossible changes from structural values
 		# to different observed values.
@@ -658,7 +664,7 @@
 		UNIVERSALOFFSET <- x$UniversalOffset
 		storage.mode(UNIVERSALOFFSET) <- "double"
 	}
-	if ((length(x$modelType) == 0)||(x$modelType == 0) || is.null(x$modelType))
+	if ((length(x$modelType) == 0)||all(x$modelType == 0) || is.null(x$modelType))
 	{
 		MODELTYPE <-  NULL
 	}

Modified: pkg/RSienaTest/R/sienaDataCreate.r
===================================================================
--- pkg/RSienaTest/R/sienaDataCreate.r	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSienaTest/R/sienaDataCreate.r	2020-04-08 15:20:15 UTC (rev 348)
@@ -2391,7 +2391,7 @@
 	for (i in seq(along=z$cCovars))
 	{
 		nodeSet <- attr(z$cCovars[[i]], "nodeSet")
-		use <- (netTypes != "behavior" & netActorSet == nodeSet)
+		use <- (!(netTypes %in% c("behavior", "continuous")) & (netActorSet == nodeSet))
 		simMeans <- namedVector(NA, netNames[use])
 		for (j in which(use))
 		{
@@ -2404,7 +2404,7 @@
 	for (i in seq(along=z$vCovars))
 	{
 		nodeSet <- attr(z$vCovars[[i]], "nodeSet")
-		use <- (netTypes != "behavior" & netActorSet == nodeSet)
+		use <- (!(netTypes %in% c("behavior", "continuous")) & (netActorSet == nodeSet))
 		simMeans <- namedVector(NA, netNames[use])
 		for (j in which(use))
 		{

Modified: pkg/RSienaTest/R/sienaGOF.r
===================================================================
--- pkg/RSienaTest/R/sienaGOF.r	2020-02-16 17:03:50 UTC (rev 347)
+++ pkg/RSienaTest/R/sienaGOF.r	2020-04-08 15:20:15 UTC (rev 348)
@@ -865,16 +865,20 @@
 				sort(sims[,i])[ind.lower]  )
 	yperc.upper = sapply(1:ncol(sims), function(i)
 				sort(sims[,i])[ind.upper]  )
-	violins <- matrix(NA, 7, ncol(sims))
-	violins[1,] <- sims.themax
-	violins[2,] <- yperc.upper
-	violins[3,] <- sims.mean
-	violins[4,] <- yperc.mid
-	violins[5,] <- yperc.lower
-	violins[6,] <- sims.themin
-	violins[7,] <- obs
-	rownames(violins) <- c('max', 'perc.upper', 'mean',
-							'median', 'perc.lower', 'min', 'obs')
+	ypg <- sapply(1:ncol(sims), function(i)	mean(sims[,i] > obs[1,i]))
+	ypp <- sapply(1:ncol(sims), function(i)	mean(sims[,i] >= obs[1,i]))
+    violins <- matrix(NA, 9, ncol(sims))
+    violins[1, ] <- sims.themax
+    violins[2, ] <- yperc.upper
+    violins[3, ] <- sims.mean
+    violins[4, ] <- yperc.mid
+    violins[5, ] <- yperc.lower
+    violins[6, ] <- sims.themin
+    violins[7, ] <- obs
+    violins[8, ] <- ypg
+    violins[9, ] <- ypp
+    rownames(violins) <- c("max", "perc.upper", "mean", "median",
+        "perc.lower", "min", "obs", "p>", "p>=")
 	colnames(violins) <- key
 	violins
 }
@@ -1405,25 +1409,20 @@
 # certain values of the categorical dyadic covariate dc.
 # dc should be a matrix of the same dimensions as
 # the dependent variable.
-dyadicCov <-  function (i, obsData, sims, period, groupName,
-                           varName, dc, dc.table=NULL){
+# Frequencies of ties with dc == 0 are not counted.
+dyadicCov <-  function (i, obsData, sims, period, groupName, varName, dc){
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/rsiena -r 348


More information about the Rsiena-commits mailing list