sparseAdjMat.to.NetInd: Convert Network from Sparse Adjacency Matrix into Network IDs...

View source: R/network.R

sparseAdjMat.to.NetIndR Documentation

Convert Network from Sparse Adjacency Matrix into Network IDs Matrix

Description

Convert network represented by a sparse adjacency matrix into simcausal network IDs matrix (NetInd_k).

Usage

sparseAdjMat.to.NetInd(sparseAdjMat, trimKmax)

Arguments

sparseAdjMat

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).

trimKmax

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.

Value

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).

See Also

network; NetInd.to.sparseAdjMat; sparseAdjMat.to.igraph; igraph.to.sparseAdjMat;


osofr/simcausal documentation built on Oct. 21, 2022, 3:09 a.m.