SimulateDyadicLinearERGM: Simulates an ERGM network using given covariate values

View source: R/SimulateDyadicLinearERGM.R

SimulateDyadicLinearERGMR Documentation

Simulates an ERGM network using given covariate values

Description

Simulates a random ERGM network using a given matrix of covariate values and a corresponding vector of parameter values.

Usage

SimulateDyadicLinearERGM(N, dyadiccovmat, eta)

Arguments

N

number of individuals in the population.

dyadiccovmat

matrix of dyadic covariates.

eta

vector of parameters.

Details

dyadiccovmat is an {N \choose 2} by (k+2) matrix containing the dyadic covariates for the population, where N is the number of individuals in the population and k is the number of dyadic covariates used in the model. The matrix contains one row for each dyad (pair of nodes). Columns 1 and 2 give the ID of the two nodes comprising the dyad, and the remaining k columns give the covariate values; eta is the vector of parameters corresponding to the covariates.

For this class of dyadic independence network, the probability of an edge between individuals i and j is p_{\{i,j\} }, where

\log \left( \frac{p_{\{i,j\} }}{1-p_{\{i,j\} }} \right) = \sum_{k} \eta_k X_{\{i,j\},k}

More information about this type of model can be found in Groendyke et al. (2012).

Value

a network in edgelist matrix format

Author(s)

David Welch david.welch@auckland.ac.nz, Chris Groendyke cgroendyke@gmail.com

References

Groendyke, C., Welch, D. and Hunter, D. 2012. A Network-based Analysis of the 1861 Hagelloch Measles Data, Biometrics, 68-3.

See Also

SEIR.simulator for simulating an SEIR epidemic over a network.

Examples

# Construct a network of 30 individuals
set.seed(3)
N <- 30
# Build dyadic covariate matrix
# Have a single covariate for overall edge density; this is the Erdos-Renyi model
nodecov <- matrix(1:N, nrow = N)
dcm <- BuildX(nodecov)
# Simulate network
examplenet <- SimulateDyadicLinearERGM(N, dyadiccovmat = dcm, eta = -1.8)

# Another example
set.seed(1)
N <- 50
mycov <- data.frame(id = 1:N, xpos = runif(N), ypos = runif(N))
dyadCov <- BuildX(mycov, binaryCol = list(c(2, 3)),binaryFunc = c("euclidean"))
# Build network
eta <- c(0,-7)
net <- SimulateDyadicLinearERGM(N = N, dyadiccovmat = dyadCov, eta = eta)

epinet documentation built on May 29, 2024, 3:11 a.m.