simulate_srm_network: A function to simulate single layer directed networks using a...

View source: R/simulate_srm_network.R

simulate_srm_networkR Documentation

A function to simulate single layer directed networks using a social relations model

Description

This is a function to simulate single layer network data with sender-receiver effects and dyadic reciprocity. This function is essentially a social relations model.

Usage

simulate_srm_network(
  N_id = 99,
  B = -4,
  sr_mu = c(0, 0),
  sr_sigma = c(0.3, 1.5),
  sr_rho = 0.6,
  dr_mu = c(0, 0),
  dr_sigma = 1,
  dr_rho = 0.7,
  mode = "bernoulli",
  individual_predictors = NULL,
  dyadic_predictors = NULL,
  individual_effects = NULL,
  dyadic_effects = NULL
)

Arguments

N_id

Number of individuals.

B

Intercept tie log-odds.

sr_mu

Mean vector for sender and receivier random effects. In most cases, this should be c(0,0).

sr_sigma

Standard deviation vector for sender and receivier random effects. The first element controls node-level variation in out-degree, the second in in-degree.

sr_rho

Correlation of sender-receiver effects: aka. generalized reciprocity.

dr_mu

Mean vector for dyadic random effects. In most cases, this should be c(0,0).

dr_sigma

Standard deviation for dyadic random effects.

dr_rho

Correlation of dyad effects: aka. dyadic reciprocity.

mode

Outcome mode: can be "bernoulli", "poisson", or "binomial".

individual_predictors

An N_id by N_individual_parameters matrix of covariates.

dyadic_predictors

An N_id by N_id by N_dyadic_parameters array of covariates.

individual_effects

A 2 by N_individual_parameters matrix of slopes. The first row gives effects of focal characteristics (on out-degree). The second row gives effects of target characteristics (on in-degree).

dyadic_effects

An N_dyadic_parameters vector of slopes.

Value

A list of objects including: network (an adjacency matrix of binary outcomes), tie_strength (an adjacency matrix with probability weights), individual_predictors (the supplied covariate data is saved along with the network data), and dyadic_predictors (the supplied covariate data is saved along with the network data).

Examples

## Not run: 
library(igraph)
N_id = 100
A = simulate_srm_network(N_id = N_id, B=-7, 
                         individual_predictor=matrix(rnorm(N_id, 0, 1), nrow=N_id, ncol=1), 
                         individual_effects=matrix(c(1.2, 1.5), ncol=1, nrow=2),
                         sr_sigma = c(1.4, 0.8), sr_rho = 0.5,
                         dr_sigma = 1.2, dr_rho = 0.8,
                         mode="bernoulli"
                         )
Net = graph_from_adjacency_matrix(A$network, mode = c("directed"))

plot(Net, edge.arrow.size =0.1, edge.curved = 0.3, vertex.label=NA, vertex.size = 5)

## End(Not run)


ctross/STRAND documentation built on Nov. 14, 2024, 11:50 p.m.