Convert network represented by a sparse adjacency matrix into simcausal
network IDs matrix (NetInd_k
).
sparseAdjMat.to.NetInd(sparseAdjMat, trimKmax)
A named list with 3 items: 1) NetInd_k
; 2) nF
; and 3) Kmax
.
1) NetInd_k
- matrix of network IDs of dimension (n=nrow(sparseAdjMat),Kmax)
, where each row i
consists of the network IDs (friends) for observation i
.
Remainders are filled with NAs.
2) nF
- integer vector of length n
specifying the number of friends for each observation.
3) Kmax
- integer constant specifying the maximum observed number of friends in input sparseAdjMat
(this is the column dimension for the output matrix NetInd_k
).
Network represented as a sparse adjacency matrix (S4 class object dgCMatrix
from package Matrix
).
NOTE: The friends (row numbers) of observation i
are assumed to be listed in column i
(i.e, which(sparseAdjMat[,i])
are friends of i
).
Trim the maximum number of friends to this integer value. If this argument is not missing,
the conversion network matrix obtained from sparseAdjMat
will be trimmed, so that each observation has at most trimKmax
friends.
The trimming initiates from the last column of the network ID matrix, removing columns until only trimKmax
columns are left.
network
; NetInd.to.sparseAdjMat
; sparseAdjMat.to.igraph
; igraph.to.sparseAdjMat
;