Learn R Programming

Bergm (version 1.4)

bergm: Bayesian exponential random graph models

Description

Function to fit Bayesian exponential random graphs models using the exchange algorithm with either single-site update or population MCMC with parallel ADS move.

Usage

bergm(model, 
      burn.in = 0, 
      main.iter = 5000, 
      aux.iter = 1000, 
      sdprop = NULL, 
      sdprior = NULL, 
      mprior = NULL, 
      popMCMC = TRUE, 
      nchains = NULL, 
      gamma = 1, 
      sdepsilon = 0.05, 
      save = FALSE,
      ...)

Arguments

model
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 for the beginning of an MCMC run. If population MCMC is performed, it refers to the number of burn-in iterations for each chain of the population.
main.iter
count; number of iterations for the main chain(s).
aux.iter
count; number of auxiliary iterations used to simulate networks.
sdprop
vector; standard deviation of the (independent) Normal proposals (for single-site update procedure).
sdprior
vector; standard deviation of the (independent) Normal priors.
mprior
vector; mean of the Normal priors.
popMCMC
logical; If TRUE, population MCMC is performed using parallel ADS procedure.
nchains
count; number of chains for population MCMC procedure.
gamma
scalar; ``snooker move'' factor.
sdepsilon
parameter; standard deviation for ``snooker move'' parameter (epsilon).
save
logical; if TRUE a file called "bergm.out" is saved in the working directory.
...
additional arguments, to be passed to lower-level functions.

Value

  • thetamatrix containing all the parameter values in the chain(s).
  • dimmodel dimensions.
  • chainsnumber of chains.
  • iternumber of iterations for the main chain(s).
  • rateacceptance rate(s).
  • modmodel specifications.

See Also

mcmc.output, posterior.plot, bgof.

Examples

Run this code
# load the Florentine marriage network 
# included with the ergm package

data(florentine)

# Estimation of a 3-dimensional model
# measuring the propensity to form 2- and 3- stars.
# PopMCMC with parallel ADS approach is used
# (this  will take about 6 minutes)

flo <- bergm(flomarriage~edges+kstar(2:3),
burn.in=500,aux.iter=3000,main.iter=5000,
sdprior=c(5,5),gamma=0.6,sdepsilon=0.1)

# MCMC diagnostics for the second chain
# and overall poterior estimate

diagnostics <- mcmc.output(flo,lags=300,chain=2)

# Posterior density scatterplots 
# and covariance matrix

posterior.plot(diagnostics)

# Bayesian goodness-of-fit test

bgof(flo,lags=200,n.sim=100,n.deg=10,n.dist=9,n.esp=6)

Run the code above in your browser using DataLab