library("xergm")
data("alliances")
# btergm formulas look very similar to ERGM formulas.
# Note the R argument; usually want R > 1000.
# Here it is set to 50 to limit computation time.
# First, set the seed for replicability.
set.seed(123)
model <- btergm(allyNet ~ edges + gwesp(0, fixed = TRUE)
+ edgecov(lNet) + edgecov(LSP) + edgecov(warNet)
+ nodecov("polity") + nodecov("cinc") + absdiff("polity")
+ absdiff("cinc") + edgecov(contigMat) + nodecov("year"),
R = 50)
# View estimates and confidence intervals.
summary(model)
# Evaluate model fit. Simulate 100 networks for each time point.
# Calculate edgewise shared partners, degree and geodesic distance
# distance distributions.
alliance_gof <- gof(model, statistics = c(deg, esp, geodesic))
# Plot goodness of fit.
plot(alliance_gof)
Run the code above in your browser using DataLab