Learn R Programming

RSiena (version 1.1-212)

sienaNet: Function to create a Siena network object

Description

Creates a Siena network object from a matrix or array or list of sparse matrix of triples.

Usage

sienaNet(netarray, type=c("oneMode", "bipartite", "behavior"),
nodeSet="Actors", sparse=is.list(netarray))

Arguments

Value

An object of class "sienaNet". An array or (networks only) a list of sparse matrices with attributes:netdimsDimensions of the network or behavior variable. Senders, receivers (1 for behavior), periodstypeoneMode, bipartite or behaviorsparseBoolean: whether a list of sparse matrices or notnodeSetCharacter string with name(s) of node set(s)

Details

Adds attributes so that the array or list of matrices can be used in a Siena model fit.

References

See http://www.stats.ox.ac.uk/siena/

See Also

sienaDataCreate

Examples

Run this code
mynet1 <- sienaNet(array(c(s501, s502, s503), dim=c(50, 50, 3)))
mynet2 <- sienaNet(s50a, type="behavior")
## note that the following example works although the node sets do not exist!
mynet3 <- sienaNet(array(c(s501, s502, s503), dim=c(50, 50, 3)),
type="bipartite", nodeSet=c("senders", "receivers"))
## sparse matrix input - create some RSiena edgelists first
library(Matrix)
tmp1 <- as(Matrix(s501), "dgTMatrix")
tmp2 <- as(Matrix(s502), "dgTMatrix")
tmp3 <- as(Matrix(s503), "dgTMatrix")
mymat1 <- cbind(tmp1@i + 1, tmp1@j + 1, 1, 1)
mymat2 <- cbind(tmp2@i + 1, tmp2@j + 1, 1, 2)
mymat3 <- cbind(tmp3@i + 1, tmp3@j + 1, 1, 3)
mymat <- rbind(mymat1, mymat2, mymat3)
library(Matrix)
## mymat includes all 3 waves
mymatlist <- by(mymat, mymat[, 4], function(x)
    spMatrix(50, 50, x[, 1], x[, 2], x[, 3]))
mynet4 <- sienaNet(mymatlist)
## or alternatively
mymat1 <- mymat[mymat[, 4] == 1, ]
mymat2 <- mymat[mymat[, 4] == 2, ]
mymat3 <- mymat[mymat[, 4] == 3, ]
mymat1s <- spMatrix(50, 50, mymat1[, 1], mymat1[, 2], mymat1[, 3])
mymat2s <- spMatrix(50, 50, mymat2[, 1], mymat2[, 2], mymat2[, 3])
mymat3s <- spMatrix(50, 50, mymat3[, 1], mymat3[, 2], mymat3[, 3])
mynet4 <- sienaNet(list(mymat1s, mymat2s, mymat3s))

Run the code above in your browser using DataLab