Learn R Programming

Bergm (version 2.5)

bergm: Bayesian exponential random graph models

Description

Function to fit Bayesian exponential random graphs models using the exchange algorithm. Two are the sampling approaches available: block update and population MCMC with parallel Adaptive Direction Sampling (ADS).

Usage

bergm(formula, 
      burn.in=100,
      main.iters=1000,
      aux.iters=1000, 
      m.prior = NULL, 
      sigma.prior = NULL, 
      nchains = NULL, 
      gamma = 0.5, 
      sigma.epsilon = NULL,
      save = FALSE,
      ...)

Arguments

formula
formula; an R formula object, of the form ~ where is a network object and are ergm-terms.
burn.in
count; number of burn-in iterations at the beginning of an MCMC run. If population MCMC is performed, it refers to the number of burn-in iterations for every chain of the population.
main.iters
count; number of iterations for the MCMC chain(s) excluding burn-in. If population MCMC is performed, it refers to the number of iterations for every chain of the population.
aux.iters
count; number of auxiliary iterations used for network simulation.
m.prior
vector; mean of the multivariate Normal prior. By default set to a vector of 0's.
sigma.prior
variance/covariance matrix for the multivariate Normal prior. By default set to a diagonal matrix with every diagonal entry equal to 100.
nchains
count; number of chains of the population MCMC. By default set to twice the model dimension (number of model terms). If the model is one-dimensional, nchains is set to 1.
gamma
scalar; ``parallel ADS move factor.'' In case of one-dimensional models, the population MCMC procedure is disabled and gamma is used as variance of the Normal proposal distribution.
sigma.epsilon
variance/covariance matrix for the multivariate Normal proposal or ``parallel ADS move parameter''. By default set to a diagonal matrix with every diagonal entry equal to 0.0025. If the model is one-dimensional, sigma.espilon is set equal to
save
logical; if TRUE a file called "bergm.out" is saved in the working directory.
...
additional arguments, to be passed to lower-level functions.

See Also

bergm.output, bgof.

Examples

Run this code
# load the Florentine marriage network 

data(florentine)

# Estimation of a 2-dimensional model
# measuring the propensity to form 2-stars.
# Population MCMC with ADS approach is used

flo <- bergm(flomarriage ~ edges + kstar(2),
             burn.in=50,
             aux.iters=500,
             main.iters=500,
             gamma=1)

# MCMC diagnostics

bergm.output(flo)

# Bayesian goodness-of-fit test

bgof(flo,
     aux.iters=500,
     sample.size=50,
     n.deg=10,
     n.dist=9,
     n.esp=6)

Run the code above in your browser using DataLab