Learn R Programming

Bergm (version 1.1)

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 snooker update.

Usage

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

Arguments

model
formula; ~
burn.in
count; number of burn-in iterations for each chain
main.iter
count; number of iterations for the main chain(s)
aux.iter
count; number of auxiliary iterations
sdprop
vector; standard deviation for the (Normal) proposal distribution (for single-site update)
sdprior
vector; standard deviation for the (Normal) prior distribution
mprior
vector; mean for the (Normal) prior distribution
theta
vector; initial parameter value
popMCMC
logical; If TRUE, population MCMC is performed using snooker update
nchains
count; number of chains for population MCMC
gamma
scalar; snooker factor
sdepsilon
vector; standard deviation for the snooker update parameter (epsilon)
save
logical; if TRUE a file called "bergm.out" is saved in the working directory

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, 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-stars
# popMCMC with snooker update is used
# (this  will take around 4 minutes)

flo <- bergm(flomarriage~edges+kstar(2),
main.iter=5000)

# MCMC diagnostics for the overall posterior
# and second chain

mcmc.output(flo,lags=200,chain=3)

# Bayesian goodness-of-fit test

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

Run the code above in your browser using DataLab