Learn R Programming

simcausal (version 0.5.7)

NetIndClass: R6 class for creating and storing a friend matrix (network IDs) for network data

Description

This R6 class defines fields and methods for creating and storing NetInd_k, a matrix of friend indices (network IDs) of dim = (nobs x Kmax).

Arguments

Format

An R6Class generator object

Methods

new(nobs, Kmax = 1)

Uses nobs and Kmax to instantiate an object of R6 class and pre-allocate memory for the future network ID matrix.

makeNetInd.fromIDs(Net_str, IDs_str = NULL, sep = ' ')

Build the matrix of network IDs (NetInd_k) from IDs string vector, all friends of one observation i are located in a string Net_str[i], with two distinct friend IDs of i separated by character sep. If IDs_str is NULL it is assumed that the friends in Net_str are actual row numbers in 1:nobs, otherwise IDs from Net_str will be used for looking up the observation row numbers in IDs_str.

make.nF(NetInd_k = self$NetInd_k, nobs = self$nobs, Kmax = self$Kmax)

This method calculates the integer number of friends for each row of the network ID matrix (self$NetInd_k). The result is assigned to a field self$nF and is returned invisibly.

mat.nF(nFnode)

nFnode - the character name for the number of friends variable that is assigned as a column name to a single column matrix in self$nF.

Methods


Method new()

Usage

NetIndClass$new(nobs, Kmax = 1)


Method makeNetInd.fromIDs()

Usage

NetIndClass$makeNetInd.fromIDs(Net_str, IDs_str = NULL, sep = " ")


Method make.nF()

Usage

NetIndClass$make.nF(
  NetInd_k = self$NetInd_k,
  nobs = self$nobs,
  Kmax = self$Kmax
)


Method mat.nF()

Usage

NetIndClass$mat.nF(nFnode)


Method clone()

The objects of this class are cloneable with this method.

Usage

NetIndClass$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

  • NetInd - Matrix of friend indices (network IDs) of dim = (nobs x Kmax) (Active Binding).

  • nF - Vector of integers, where nF[i] is the integer number of friends (0 to Kmax) for observation i.

  • nobs - Number of observations

  • Kmax - Maximum number of friends for any observation.