Description Usage Arguments Value Examples

View source: R/simulate_networks.R

Simulates networks from a GERGM for a given set of parameter values.

1 2 3 4 5 6 7 8 9 10 | ```
simulate_networks(formula, thetas, simulation_method = c("Metropolis",
"Gibbs"), network_is_directed = TRUE,
number_of_networks_to_simulate = 500, thin = 1, proposal_variance = 0.1,
downweight_statistics_together = TRUE, MCMC_burnin = 100, seed = 123,
GERGM_Object = NULL, return_constrained_networks = FALSE,
optimize_proposal_variance = FALSE, target_accept_rate = 0.25,
use_stochastic_MH = FALSE, stochastic_MH_proportion = 1,
beta_correlation_model = FALSE, distribution_estimator = c("none",
"rowwise-marginal", "joint"), covariate_data = NULL, lambdas = NULL,
include_diagonal = FALSE, ...)
``` |

`formula` |
A formula object that specifies which statistics the user would like to include while simulating the network, and the network the user is providing as the initial network. Currently, the following statistics can be specified: c("edges", "out2stars", "in2stars", "ctriads", "mutual", "ttriads"). |

`thetas` |
A vector of theta parameters given in the same order as the formula terms, which the user would like to use to parameterize the model. |

`simulation_method` |
Default is "Metropolis" which allows for exponential down weighting, can also be "Gibbs". |

`network_is_directed` |
Logical specifying whether or not the observed network is directed. Default is TRUE. |

`number_of_networks_to_simulate` |
Number of simulations generated for estimation via MCMC. Default is 500. |

`thin` |
The proportion of samples that are kept from each simulation. For example, thin = 1/200 will keep every 200th network in the overall simulated sample. Default is 1. |

`proposal_variance` |
The variance specified for the Metropolis Hastings simulation method. This parameter is inversely proportional to the average acceptance rate of the M-H sampler and should be adjusted so that the average acceptance rate is approximately 0.25. Default is 0.1. |

`downweight_statistics_together` |
Logical specifying whether or not the weights should be applied inside or outside the sum. Default is TRUE and user should not select FALSE under normal circumstances. |

`MCMC_burnin` |
Number of samples from the MCMC simulation procedure that will be discarded before drawing the samples used for estimation. Default is 100. |

`seed` |
Seed used for reproducibility. Default is 123. |

`GERGM_Object` |
Optional argument allowing the user to supply a GERGM object output by the gergm() estimation function in order to simulate further networks. Defaults to NULL. If a GERGM object is provided, any user specified parameter values will be ignored and the final parameter estimates from the gergm() function will be used instead. When using this option, the following terms must still be specified: number_of_networks_to_simulate, thin, and MCMC_burnin. proposal_variance may also be specified, or if set equal to NULL, then the proposal variance from parameter estimation will be used instead ( this option is likely preferred in most situations). |

`return_constrained_networks` |
Logical argument indicating whether simulated networks should be transformed back to observed scale or whether constrained [0,1] networks should be returned. Defaults to FALSE, in which case networks are returned on observed scale. |

`optimize_proposal_variance` |
Logical indicating whether proposal variance should be optimized if using Metropolis Hastings for simulation. Defaults to FALSE. |

`target_accept_rate` |
Defaults to 0.25, can be used to optimize Metropolis Hastings simulations. |

`use_stochastic_MH` |
A logical indicating whether a stochastic approximation to the h statistics should be used under Metropolis Hastings in-between thinned samples. This may dramatically speed up estimation. Defaults to FALSE. HIGHLY EXPERIMENTAL! |

`stochastic_MH_proportion` |
Percentage of dyads/triads to use for approximation, defaults to 0.25 |

`beta_correlation_model` |
Defaults to FALSE. If TRUE, then the beta correlation model is estimated. A correlation network must be provided, but all covariates and undirected statistics may be supplied as normal. |

`distribution_estimator` |
Provides an option to estimate the structure of row-wise marginal and joint distribtuions using a uniform-dirichlet proposal distribution. THIS FEATURE IS EXPERIMENTAL. Defaults to "none", in which case a normal GERGM is estimated, but can be set to one of "rowwise-marginal" and "joint" to propose either row-wsie marginal distribtuions or joint distributions. If an option other than "none" is selected, the beta correlation model will be turned off, estimation will automatically be set to Metropolis, no covariate data will be allowed, and the network will be set to directed. Furthermore, a "diagonal" statistic will be added to the model which simply records the sum of the diagonal of the network. The "mutual" statistic will also be adapted to include the diagonal elements. In the future, more statistics which take account of the network diagonal will be included. |

`covariate_data` |
A data frame containing node level covariates the user wished to transform into sender or receiver effects. It must have row names that match every entry in colnames(raw_network), should have descriptive column names. If left NULL, then no sender or receiver effects will be added. |

`lambdas` |
A vector of lambda parameters given in the same order as the formula terms, which the user would like to use to parameterize the model. Covariate effects should be specified after endogenous effects. |

`include_diagonal` |
Logical indicating whether the diagonal should be included in the estimation proceedure. If TRUE, then a "diagonal" statistic is added to the model. Defaults to FALSE. |

`...` |
Optional arguments, currently unsupported. |

A list object containing simulated networks and parameters used to specify the simulation. See the $MCMC_Output field for simulated networks. If GERGM_Object is provided, then a GERGM object will be returned instead.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ```
## Not run:
set.seed(12345)
net <- matrix(runif(100),10,10)
diag(net) <- 0
colnames(net) <- rownames(net) <- letters[1:10]
formula <- net ~ edges + ttriads + in2stars
test <- simulate_networks(formula,
thetas = c(0.6,-0.8),
lambdas = 0.2,
number_of_networks_to_simulate = 100,
thin = 1/10,
proposal_variance = 0.5,
MCMC_burnin = 100,
seed = 456)
# preferred method for specifying a null model
formula <- net ~ edges(method = "endogenous")
test <- simulate_networks(
formula,
thetas = 0,
number_of_networks_to_simulate = 100,
thin = 1/10,
proposal_variance = 0.5,
MCMC_burnin = 100,
seed = 456)
## End(Not run)
``` |

matthewjdenny/GERGM documentation built on May 15, 2018, 4:22 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.