Skip to content

Commit 121bb80

Browse files
authored
Merge pull request #111 from stocnet/develop
Version 1.4.22
2 parents 137830e + c95b747 commit 121bb80

19 files changed

+794
-90
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Encoding: UTF-8
22
Package: RSiena
33
Type: Package
44
Title: Siena - Simulation Investigation for Empirical Network Analysis
5-
Version: 1.4.21
6-
Date: 2024-12-12
5+
Version: 1.4.22
6+
Date: 2025-02-08
77
Authors@R: c(person("Tom A.B.", "Snijders", role = c("cre", "aut"), email = "tom.snijders@nuffield.ox.ac.uk",
88
comment = c(ORCID = "0000-0003-3157-4157")),
99
person("Ruth M.", "Ripley", role = "aut"),

NAMESPACE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export(
1212
includeTimeDummy, sienaGOF, descriptives.sienaGOF,
1313
sparseMatrixExtraction, networkExtraction, behaviorExtraction,
1414
OutdegreeDistribution, IndegreeDistribution, BehaviorDistribution,
15-
TriadCensus, mixedTriadCensus, dyadicCov,
15+
TriadCensus, mixedTriadCensus, dyadicCov, egoAlterCombi,
1616
siena.table, xtable, score.Test, Wald.RSiena, Multipar.RSiena,
1717
testSame.RSiena, funnelPlot, meta.table,
1818
influenceTable, selectionTable
@@ -31,8 +31,8 @@ importFrom("stats", ".getXlevels", "acf", "as.formula", "coef",
3131
"model.response", "model.weights", "na.omit", "naprint",
3232
"optim", "optimize", "pchisq", "plot.ts", "pnorm",
3333
"predict.lm", "pt", "qchisq", "qnorm", "quantile",
34-
"rWishart", "rnorm", "runif", "sd", "ts", "uniroot", "var",
35-
"weighted.mean", "weights")
34+
"rWishart", "rnorm", "runif", "sd", "setNames", "ts", "uniroot",
35+
"var", "weighted.mean", "weights")
3636
importFrom("utils", "browseURL", "edit",
3737
"flush.console", "getFromNamespace", "object.size",
3838
"packageDescription", "read.csv",

NEWS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# RSiena 1.4.22
2+
3+
2025-02-08
4+
5+
## Changes in RSiena:
6+
### New functionality
7+
* New auxiliary GOF function `egoAlterCombi`.
8+
* Parameter `showAll` added to `plot.sienaGOF`.
9+
### New src functionality
10+
* New table `IntLogTable` and new generic function`IntLogFunction`.
11+
### Effects
12+
* Internal parameter 0 (for log(x)) added for `outActIntn`.
13+
(It would be trivial to implement this also for the other
14+
mixed degree effects, but currently there seems no need.)
15+
### Bug correction.
16+
* In `sienaGOF`, if the auxiliaryFunction does not always
17+
give vectors of the same length, the error message gives properly
18+
the name of the auxiliaryFunction.
19+
120
# RSiena 1.4.21
221

322
2024-12-18

R/sienaGOF.r

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ sienaGOF <- function(
8686
{
8787
stop("You need to supply the parameter <<auxiliaryFunction>>.")
8888
}
89+
# This should be captured for possible later use
90+
# (when it will have been used the name is no longer available):
91+
auxfu <- deparse(substitute(auxiliaryFunction))
8992
# There might be more than one varName:
9093
if (is.null(sFO$f[[groupName]]$depvars[[varName[1]]]))
9194
{
@@ -232,10 +235,10 @@ sienaGOF <- function(
232235
cat(" > Completed ", iterations, " calculations\n\n")
233236
}
234237
flush.console()
235-
if (var(vapply(simStatsByPeriod, length, FUN.VALUE=0))>1e-10)
238+
if (var(vapply(simStatsByPeriod, length, FUN.VALUE=0))>1e-8)
236239
{
237-
stop("Function", deparse(substitute(auxiliaryFunction)),
238-
"does not always give vectors of the same length")
240+
stop("Function ", auxfu,
241+
" does not always give vectors of the same length")
239242
}
240243
simStatsByPeriod <-
241244
matrix(unlist(simStatsByPeriod), ncol=iterations)
@@ -648,7 +651,8 @@ summary.sienaGOF <- function(object, ...) {
648651

649652
##@plot.sienaGOF siena07 Plot method for sienaGOF
650653
plot.sienaGOF <- function (x, center=FALSE, scale=FALSE, violin=TRUE,
651-
key=NULL, perc=.05, period=1, position=4, fontsize=12, ...)
654+
key=NULL, perc=.05, period=1, showAll=FALSE,
655+
position=4, fontsize=12, ...)
652656
{
653657
## require(lattice)
654658
args <- list(...)
@@ -681,17 +685,25 @@ plot.sienaGOF <- function (x, center=FALSE, scale=FALSE, violin=TRUE,
681685
## Need to check for useless statistics here:
682686
n.obs <- nrow(obs)
683687

684-
screen <- sapply(1:ncol(obs),function(i){
688+
if (showAll)
689+
{
690+
screen <- sapply(1:ncol(obs),function(i){
691+
(sum(is.nan(rbind(sims,obs)[,i])) == 0) })
692+
}
693+
else
694+
{
695+
screen <- sapply(1:ncol(obs),function(i){
685696
(sum(is.nan(rbind(sims,obs)[,i])) == 0) }) &
686697
(diag(var(rbind(sims,obs)))!=0)
687-
688-
if (any((diag(var(rbind(sims,obs)))==0)))
689-
{ cat("Note: some statistics are not plotted because their variance is 0.\n")
690-
cat("This holds for the statistic")
691-
if (sum(diag(var(rbind(sims,obs)))==0) > 1){cat("s")}
692-
cat(": ")
693-
cat(paste(attr(x,"key")[which(diag(var(rbind(sims,obs)))==0)], sep=", "))
694-
cat(".\n")
698+
if (any((diag(var(rbind(sims,obs)))==0)))
699+
{
700+
cat("Note: some statistics are not plotted because their variance is 0.\n")
701+
cat("This holds for the statistic")
702+
if (sum(diag(var(rbind(sims,obs)))==0) > 1){cat("s")}
703+
cat(": ")
704+
cat(paste(attr(x,"key")[which(diag(var(rbind(sims,obs)))==0)], sep=", "))
705+
cat(".\n")
706+
}
695707
}
696708

697709
sims <- sims[,screen, drop=FALSE]
@@ -1523,7 +1535,7 @@ TriadCensus <- function (i, obsData, sims, period, groupName, varName, levls = 1
15231535

15241536
##@dyadicCov sienaGOF Auxiliary variable for dyadic covariate
15251537
#
1526-
# An auxiliary function calculating the proportion of ties
1538+
# An auxiliary function calculating the number of ties
15271539
# for subsets of ordered pairs corresponding to
15281540
# certain values of the categorical dyadic covariate dc.
15291541
# dc should be a matrix of the same dimensions as
@@ -1559,3 +1571,38 @@ dyadicCov <- function (i, obsData, sims, period, groupName, varName, dc){
15591571
ttmdyv[dims] <- tmdyv # The other entries remain 0
15601572
ttmdyv
15611573
}
1574+
1575+
egoAlterCombi <- function (i, obsData, sims, period, groupName, varName,
1576+
trafo=NULL)
1577+
{
1578+
# An auxiliary function calculating the number of ties
1579+
# for each ego-alter combination of values of the dependent variable;
1580+
# the dependent variable is transformed by trafo.
1581+
if (length(varName) != 2){
1582+
stop("egoAlterCombi expects two varName parameters")
1583+
}
1584+
if (is.null(trafo)){
1585+
trafo <- function(x){x}
1586+
}
1587+
varName1 <- varName[1]
1588+
varName2 <- varName[2]
1589+
m <- sparseMatrixExtraction(i, obsData, sims, period, groupName,
1590+
varName1)
1591+
x <- behaviorExtraction(i, obsData, sims, period, groupName,
1592+
varName2)
1593+
brange <- attr(obsData[[groupName]]$depvars[[varName2]],
1594+
"behRange")[1]:attr(obsData[[groupName]]$depvars[[varName2]],
1595+
"behRange")[2]
1596+
combi.egoalter <- outer(10*trafo(x), trafo(x) ,'+')
1597+
possible.pairs <-
1598+
sort(unique(as.vector(outer(10*trafo(brange), trafo(brange), '+'))))
1599+
tmeax <- table((m * combi.egoalter)@x, useNA = "no")
1600+
ppnames <- as.character(possible.pairs)
1601+
teax <- setNames(0*possible.pairs, ppnames)
1602+
teax[dimnames(tmeax)[[1]]] <- tmeax
1603+
# pad names with leading 0s, if necessary:
1604+
pp.names <- ifelse(nchar(ppnames)==1, paste("0",ppnames,sep=""),ppnames)
1605+
names(teax) <- pp.names
1606+
teax
1607+
}
1608+

docs/manual/RSiena_Manual.pdf

-143 KB
Binary file not shown.

0 commit comments

Comments
 (0)