## S3 method for class 'btergm':
gof(object, target = NULL, formula = getformula(object),
nsim = 100, MCMC.interval = 1000, MCMC.burnin = 10000,
parallel = c("no", "multicore", "snow"), ncpus = 1, cl = NULL,
statistics = c(dsp, esp, deg, ideg, geodesic, rocpr,
walktrap.modularity), verbose = TRUE, ...)## S3 method for class 'mtergm':
gof(object, target = NULL, formula = getformula(object),
nsim = 100, MCMC.interval = 1000, MCMC.burnin = 10000,
parallel = c("no", "multicore", "snow"), ncpus = 1, cl = NULL,
statistics = c(dsp, esp, deg, ideg, geodesic, rocpr,
walktrap.modularity), verbose = TRUE, ...)
## S3 method for class 'ergm':
gof(object, target = NULL, formula = getformula(object),
nsim = 100, MCMC.interval = 1000, MCMC.burnin = 10000,
parallel = c("no", "multicore", "snow"), ncpus = 1, cl = NULL,
statistics = c(dsp, esp, deg, ideg, geodesic, rocpr,
walktrap.modularity), verbose = TRUE, ...)
## S3 method for class 'matrix':
gof(object, covariates, coef, target = NULL, nsim = 100,
mcmc = FALSE, MCMC.interval = 1000, MCMC.burnin = 10000,
parallel = c("no", "multicore", "snow"), ncpus = 1, cl = NULL,
statistics = c(dsp, esp, deg, ideg, geodesic, rocpr,
walktrap.modularity), verbose = TRUE, ...)
## S3 method for class 'network':
gof(object, covariates, coef, target = NULL,
nsim = 100, mcmc = FALSE, MCMC.interval = 1000,
MCMC.burnin = 10000, parallel = c("no", "multicore", "snow"),
ncpus = 1, cl = NULL, statistics = c(dsp, esp, deg, ideg,
geodesic, rocpr, walktrap.modularity), verbose = TRUE, ...)
## S3 method for class 'sienaAlgorithm':
gof(object, siena.data, siena.effects,
predict.period = NULL, nsim = 50, parallel = c("no",
"multicore", "snow"), ncpus = 1, cl = NULL, target.na = NA,
target.na.method = "remove", target.structzero = 10,
statistics = c(dsp, esp, deg, ideg, geodesic, rocpr,
walktrap.modularity), verbose = TRUE, ...)
## S3 method for class 'sienaModel':
gof(object, siena.data, siena.effects,
predict.period = NULL, nsim = 50, parallel = c("no",
"multicore", "snow"), ncpus = 1, cl = NULL,
target.na = NA, target.na.method = "remove",
target.structzero = 10, statistics = c(dsp, esp, deg, ideg,
geodesic, rocpr, walktrap.modularity), verbose = TRUE, ...)
parallel = "snow". If not supplied, a cluster on the local machine is created temporarily.edgecov terms.btergm object x is used. It is possible to hand over a formula with only a single response network and/or dyad or edge covariates mcmc = FALSE, new networks are simulated based on predicted tie probabilities of the regression equation.parallel is activated). If the number of cores should be detected automatically on the machine where the code is executed, one can try the detectCores() function fformula and nsim = 100, a total of 600 new networks is simulated. The comparison between simulated and observed networks is onlbtergm, ergm, sienaAlgorithm, or sienaModel object (for the btergm, ergm, sienaAlgorithm, and sienaModel methods, respectively). Or a network object "no" means parallel computing is switched off. If "multicore" is used (only available for sienaAlgorithm and predict.period = 4 for predicting the fourthsiena, which is usually created using the sienaDataCreate function in the RSiena package.sienaEffects, which is usually created using the getEffects() and the includeEffects() function in the RSiena package.btergm object x are used as observed networks.remove drops nodes with missing ties both from the simulations (after running the simulations) and from the obsgof function provides goodness-of-fit measures and degeneracy checks for btergm, mtergm, ergm, SAOM, and custom dyadic-independent models. The user can provide a list of network statistics for comparing simulated networks based on the estimated model with the observed network(s). See gof-statistics. The objects created by these methods can be displayed using various plot and print methods (see gof-plot).In-sample GOF assessment is the default, which means that the same time steps are used for creating simulations and for comparison with the observed network(s). It is possible to do out-of-sample prediction by specifying a (list of) target network(s) using the target argument. If a formula is provided, the simulations are based on the networks and covariates specified in the formula. This is helpful in situations where complex out-of-sample predictions have to be evaluated. A usage scenario could be to simulate from a network at time t (provided through the formula argument) and compare to an observed network at time t + 1 (the target argument). This can be done, for example, to assess predictive performance between time steps of the original networks, or to check whether the model performs well with regard to a newly measured network given the old data from the previous time step.
Predictive fit can also be assessed for stochastic actor-oriented models (SAOM) as implemented in the sienaAlgorithm (for sienaModel (for gof function.
The gof methods for networks and matrices serve to assess the goodness of fit of a dyadic-independence model. To do this, the method requires a vector of coefficients (one coefficient for the intercept or edges term and one coefficient for each covariate), a list of covariates (in matrix or network shape), and a dependent network or matrix. This is useful for assessing the goodness of fit of QAP-adjusted logistic regression models (as implemented in the netlogit function in the glm. Note that this method only works with cross-sectional models and does not accept lists of networks as input data.
# First, create data and fit a TERGM...
networks <- list()
for(i in 1:10){ # create 10 random networks with 10 actors
mat <- matrix(rbinom(100, 1, .25), nrow = 10, ncol = 10)
diag(mat) <- 0 # loops are excluded
nw <- network(mat) # create network object
networks[[i]] <- nw # add network to the list
}
covariates <- list()
for (i in 1:10) { # create 10 matrices as covariate
mat <- matrix(rnorm(100), nrow = 10, ncol = 10)
covariates[[i]] <- mat # add matrix to the list
}
fit <- btergm(networks ~ edges + istar(2) +
edgecov(covariates), R = 100)
# Then assess the goodness of fit:
g <- gof(fit, statistics = c(triad.directed, esp, maxmod.modularity,
rocpr), nsim = 50)
g
plot(g) # see ?"gof-plot" for detailsRun the code above in your browser using DataLab