Learn R Programming

ernm (version 1.0.4)

ernm_gof: Goodness of fit for ERNM model

Description

Goodness of fit plot for ERNM models, particularly suited for comparing models

Usage

ernm_gof(
  models,
  observed_network = NULL,
  stats_formula,
  style = "histogram",
  scales = "fixed",
  print = TRUE,
  n_sim = 10000,
  burnin = 10000,
  interval = 100,
  hist_bins = 30
)

Value

A list containing goodness-of-fit plots and simulated statistics

Arguments

models

named list of ernm models to be to be compared (can be length 1

observed_network

the observed network

stats_formula

the formula for the statistics (see ernm-formula)

style

the style of the plot, either 'histogram' or 'boxplot'

scales

the scales of the plot, either 'fixed' or 'free'

print

whether to print the plot

n_sim

the number of simulations to run

burnin

the burnin for the MCMC simulation

interval

the sampling interval for MCMC simulation

hist_bins

number of bins for histogram

Details

Goodness of fit in ERNM is done by comparing simulated networks from the ernm model to the observed network. If the observed network is typical of the simulated networks it is considered to be well fit.

Examples

Run this code
if (FALSE) {
data(samplike)
fit_basic <- ernm(samplike ~ edges() + nodeCount("group") + nodeMatch("group") | group)
fit_tri <- ernm(samplike ~ edges() + nodeCount("group") + nodeMatch("group") + triangles() | group)

# how well is the triangle term fit?
gof <- ernm_gof(
  list(
    basic = fit_basic,
    with_triangles = fit_tri
  ),
  observed_network = samplike,
  stats_formula = samplike ~ triangles(),
  n_sim = 100
)

# look at the fit over all edgewise shared partners
gof <- ernm_gof(
  list(
    basic = fit_basic,
    with_triangles = fit_tri
  ),
  style="boxplot",
  observed_network = samplike,
  stats_formula = samplike ~ esp(1:10),
  n_sim = 100
)
}

Run the code above in your browser using DataLab