Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Encoding: UTF-8
Package: RSiena
Type: Package
Title: Siena - Simulation Investigation for Empirical Network Analysis
Version: 1.6.10
Date: 2026-06-14
Version: 1.6.11
Date: 2026-07-16
Authors@R: c(person("Tom A.B.", "Snijders", role = c("aut", "ctb"), comment = c(ORCID = "0000-0003-3157-4157")),
person("Ruth M.", "Ripley", role = "aut"),
person("Krists", "Boitmanis", role = c( "aut","ctb")),
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export(
networkExtraction, behaviorExtraction,
OutdegreeDistribution, IndegreeDistribution, BehaviorDistribution,
TriadCensus, mixedTriadCensus, dyadicCov, egoAlterCombi, egoAlterCovarComb,
AC_Moran, AC_Geary,
siena_table, xtable, score.Test, Wald.RSiena, Multipar.RSiena,
testSame.RSiena, funnelPlot, meta.table,
influenceTable, selectionTable,
Expand Down Expand Up @@ -66,8 +67,10 @@ S3method(write_report, sienadata)
S3method(print, sienaGroup)
S3method(print, sienaDependent)
S3method(print, sienaFit)
S3method(print, coef_siena)
S3method(summary, sienaFit)
S3method(coef, sienaFit)
S3method(coefficients, sienaFit)
S3method(vcov, sienaFit)
S3method(test_parameter, sienaFit)
S3method(write_result, sienaFit)
Expand Down
18 changes: 18 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
2026-07-16

# RSiena 1.6.11

## Changes in RSiena:
### Effects
### Functionality
* New auxiliary functions `AC_Moran` and `AC_Geary`.
* In `transformScript`, the replacement for `sienaCompositionChangeFromFile`
was put before the replacement for `sienaCompositionChange`.
* The component `theta` of results of function `siena`, the result of
functions `coef`, and `estimate_onestep` have got a class `coef_siena`,
which has its own `print` method (to allow vertical printing).
* Function `coef` now has default `shortenNames=FALSE`.
* Alias `coefficients` for `coef`.
* Remark to console about output file for `siena` only when
`silent=FALSE`.

2026-06-14

# RSiena 1.6.10
Expand Down
2 changes: 1 addition & 1 deletion R/TransformScript.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ namePairs <- list(c("sienaDependent", "as_dependent_rsiena"),
c("sienaNet", "as_dependent_rsiena"),
c("coCovar", "as_covariate_rsiena"),
c("varDyadCovar", "as_covariate_rsiena"),
c("sienaCompositionChange", "as_composition_rsiena"),
c("sienaCompositionChangeFromFile", "as_composition_file_rsiena"),
c("sienaCompositionChange", "as_composition_rsiena"),
c("sienaNodeSet", "as_nodeset_rsiena"),
c("sienaDataCreate", "make_data_rsiena"),
c("sienaModelCreate", "sienaAlgorithmCreate"),
Expand Down
15 changes: 9 additions & 6 deletions R/initializeFRAN.r
Original file line number Diff line number Diff line change
Expand Up @@ -271,20 +271,23 @@ initializeFRAN <- function(z, x, data, effects, prevAns=NULL, initC,
{
if (!is.null(prevAns) && inherits(prevAns, "sienaFit"))
{
if (is.null(x$useOneStep))
if (is.null(x$useOneStep)) # undocumented feature; probably meaningless
{
x$useOneStep <- FALSE
}
if (x$useOneStep)
{
keepStill <- which(prevAns$fixed)
if (length(keepStill) == 0)
{
if (is.null(x$keepStill))
{
x$keepStill <- which(prevAns$fixed)
}
if (length(x$keepStill) == 0)
{
keepStill <- 0
x$keepStill <- 0
}
}
effects <- update_theta(effects, prevAns,
onestep=x$useOneStep, keepUnchanged=keepStill)
onestep=x$useOneStep, keepUnchanged=x$keepStill)
}
}
## add any effects needed for settings model
Expand Down
2 changes: 1 addition & 1 deletion R/phase3.r
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ phase3.2 <- function(z, x, ...)
toosmall2 <- abs(sf) < 1e-10 * z$scale
dmsf[toosmall] <- 1e-20 * z$scale[toosmall] * z$scale[toosmall]
tstat <- rep(NA, z$pp)
tstat[!toosmall]<- sf[!toosmall] / sqrt(dmsf[!toosmall])
tstat[!toosmall] <- sf[!toosmall] / sqrt(dmsf[!toosmall])
tstat[toosmall & toosmall2] <- 0
tstat[toosmall & !toosmall2] <- NA
z$tstat <- tstat
Expand Down
42 changes: 31 additions & 11 deletions R/siena07.r
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ siena <- function(data = NULL, effects = NULL,
stop("For piped data, you need to give an outputName in the output control object.")
}
control_out$outputName <- paste(dataName, "_out", sep="")
cat('siena will create/use an output file',
paste(control_out$outputName,'.txt',sep=''),'.\n')
if (!silent)
{
cat('siena will create/use an output file',
paste(control_out$outputName,'.txt',sep=''),'.\n')
}
}
control_out$projname <- control_out$outputName
}
Expand Down Expand Up @@ -256,7 +259,7 @@ siena <- function(data = NULL, effects = NULL,
## need to reset the random number type to the normal one
assign(".Random.seed", z$oldRandomNumbers, pos=1)
}

class(z$theta) <- "coef_siena"
class(z) <- "sienaFit"
attr(z, "version") <- packageDescription(pkgname, fields = "Version")
z$tkvars <- NULL
Expand All @@ -281,7 +284,8 @@ estimate_onestep <- function(x, fixed=x$fixed, r=1, shortenNames=FALSE)
bfixed <- (1:x$pp) %in% fixed
}
else # it should be logical
{ if (length(fixed) != x$pp)
{
if (length(fixed) != x$pp)
{
stop(paste('The length of the boolean vector is ', length(fixed),
', but it should be ', x$pp, '.', sep=''))
Expand All @@ -292,6 +296,7 @@ estimate_onestep <- function(x, fixed=x$fixed, r=1, shortenNames=FALSE)
dfrac <- x$dfra[!bfixed, !bfixed]
meandev <- colMeans(x$sf[ , !bfixed])
onestep <- x$theta
dinv <- matrix(NA, x$pp, x$pp)
# This will keep the bfixed parameter values
if (!all(bfixed))
{
Expand All @@ -307,6 +312,7 @@ estimate_onestep <- function(x, fixed=x$fixed, r=1, shortenNames=FALSE)
{
names(onestep) <- fromObjectToText(names(onestep))
}
class(onestep) <- "coef_siena"
onestep
}

Expand Down Expand Up @@ -820,7 +826,7 @@ errorHandler <- function()
}

##@coef.sienaFit method for sienaFit
coef.sienaFit <- function(object, dropRates=TRUE, shortenNames=TRUE, ...)
coef.sienaFit <- function(object, dropRates=TRUE, shortenNames=FALSE, ...)
{
result <- object$theta
if (shortenNames)
Expand All @@ -833,16 +839,23 @@ coef.sienaFit <- function(object, dropRates=TRUE, shortenNames=TRUE, ...)
}
if (dropRates)
{
return(result[!object$requestedEffects$basicRate])
}
else
{
return(result)
result <- result[!object$requestedEffects$basicRate]
}
class(result) <- "coef_siena"
result
}


coefficients <- function(object, ...) UseMethod("coefficients", object)

coefficients.sienaFit <- function(object, dropRates=TRUE, shortenNames=FALSE, ...)
{
coef(object, dropRates, shortenNames, ...)
}


##@vcov.sienaFit method for sienaFit
vcov.sienaFit <- function(object, dropRates=TRUE, shortenNames=TRUE, ...)
vcov.sienaFit <- function(object, dropRates=TRUE, shortenNames=FALSE, ...)
{
result <- object$covtheta
if (shortenNames)
Expand All @@ -864,6 +877,13 @@ vcov.sienaFit <- function(object, dropRates=TRUE, shortenNames=TRUE, ...)
}
}

##@print.coef_siena Methods
print.coef_siena <- function(x, digits=4, ...)
{
print(round(matrix(x,dimnames=list(names(x), "coef ")), digits))
invisible(x)
}

fromObjectToText <- function(a, type='notex'){
# This is an extended version of the function in sienatable.r
b <- as.character(a)
Expand Down
80 changes: 80 additions & 0 deletions R/sienaGOF.r
Original file line number Diff line number Diff line change
Expand Up @@ -1657,3 +1657,83 @@ egoAlterCovarComb <- function (i, obsData, sims, period, groupName, varName,
attr(teax, "EgoAlter") <- TRUE
teax
}

# define spatial autocorrelation functions:
Moran <- function(x,z) {
n <- length(z)
z.ave <- mean(z,na.rm=TRUE)
numerator <- n*sum(x*outer(z-z.ave,z-z.ave),na.rm=TRUE)
denominator <- sum(x,na.rm=TRUE)*sum((z-z.ave)^2,na.rm=TRUE)
return(numerator/denominator)
}

Geary <- function(x,z) {
n <- length(z)
z.ave <- mean(z,na.rm=TRUE)
numerator <- (n-1)*sum(x*(outer(z,z,FUN='-')^2),na.rm=TRUE)
denominator <- 2*sum(x,na.rm=TRUE)*sum((z-z.ave)^2,na.rm=TRUE)
return(numerator/denominator)
}



AC_Moran <- function (i, obsData, sims, period, groupName, varName, depth=3)
{
# An auxiliary function calculating the Moran autocorrelations
# and rounding to 3 decimals
if (length(varName) != 2){
stop("AC_Moran expects two varName parameters")
}
varName1 <- varName[1]
varName2 <- varName[2]
m <- as.matrix(sparseMatrixExtraction(i, obsData, sims, period, groupName,
varName1))
x <- behaviorExtraction(i, obsData, sims, period, groupName,
varName2)
# Construct a list of powers 1:depth of m
if (depth >= 2){
mList <- lapply(1:(depth-1), function(i){m})
mPowList <- Reduce(function(x,y){pmin(x %*% y,1)}, mList, init=m,accumulate=TRUE)
mPowList <- lapply(mPowList, function(mat){mat[!is.na(x), !is.na(x)]})
x <- x[!is.na(x)]
Morans <- vapply(mPowList, function(mat){Moran(mat,x)}, FUN.VALUE=0)
}
else {
m <- m[!is.na(x), !is.na(x)]
x <- x[!is.na(x)]
Morans <- Moran(m,x)
}
names(Morans) <- paste("d=", 1:depth, sep="")
round(Morans, 3)
}

AC_Geary <- function (i, obsData, sims, period, groupName, varName, depth=3)
{
# An auxiliary function calculating the Geary autocorrelations
# and rounding to 3 decimals
if (length(varName) != 2){
stop("AC_Geary expects two varName parameters")
}
varName1 <- varName[1]
varName2 <- varName[2]
m <- as.matrix(sparseMatrixExtraction(i, obsData, sims, period, groupName,
varName1))
x <- behaviorExtraction(i, obsData, sims, period, groupName,
varName2)
if (depth >= 2){
# Construct a list of powers 1:depth of m
mList <- lapply(1:(depth-1), function(i){m})
mPowList <- Reduce(function(x,y){pmin(x %*% y,1)}, mList, init=m,accumulate=TRUE)
mPowList <- lapply(mPowList, function(mat){mat[!is.na(x), !is.na(x)]})
x <- x[!is.na(x)]
Gearys <- vapply(mPowList, function(mat){Geary(mat,x)}, FUN.VALUE=0)
}
else {
m <- m[!is.na(x), !is.na(x)]
x <- x[!is.na(x)]
Gearys <- Geary(m,x)
}
names(Gearys) <- paste("d=", 1:depth, sep="")
round(Gearys, 3)
}

5 changes: 4 additions & 1 deletion docs/manual/RSiena.bib
Original file line number Diff line number Diff line change
Expand Up @@ -3660,6 +3660,8 @@ @incollection{HannekeXing2007
title={Discrete temporal models of social networks},
author={Hanneke, Steve and Xing, Eric P.},
booktitle={Statistical network analysis: Models, issues, and new directions},
editor={Airoldi, Edoardo, Blei, David M., Fienberg, Stephen E.,
Goldenberg, Anna, Xing, Eric P., and Zheng, Alice X.},
pages={115--125},
year={2007},
publisher={Springer}
Expand Down Expand Up @@ -4881,7 +4883,7 @@ @article{Kindermann98
{U}sing composite social maps to identify peer networks and to study their influences},
author={Kindermann, Thomas},
journal={New directions for child development},
number={80},
volume={81},
pages={55--82},
year={1998}
}
Expand Down Expand Up @@ -6163,6 +6165,7 @@ @article{Lyons2011
journal={Statistics, Politics, and Policy},
volume={2},
number={1},
pages={1--27},
year={2011}
}

Expand Down
Binary file modified docs/manual/RSiena_Manual.pdf
Binary file not shown.
Loading
Loading