Learn R Programming

EpiModel (version 0.95)

plot.epiNet.simNet: Plot Diagnostics from an epiNet.simNet Object

Description

This function plots values from diagnostic simulations in epiNet.simNet.

Usage

## S3 method for class 'epiNet.simNet':
plot(x, type = "formation", sim, dx.start, dx.end,
  dx.leg = TRUE, plots.joined, alpha, lwd, ...)

Arguments

x
an EpiModel object of class epiNet.simNet.
type
plot type, with options either of type="formation" for partnership formation statistics or other network statistics specified in epiNet.simNet, or type="duration" to plot the mean ages of partnerships over ti
sim
network simulation number to plot, with default to plot all simulations in epiNet.simNet object.
dx.start
start time for diagnostic plots. This must be a positive integer.
dx.end
end time for diagnostic plots. This must be less than or equal to the number of time steps simulated in the epiNet.est diagnostics.
dx.leg
if TRUE, show legend (only if plots.joined=TRUE)
plots.joined
if TRUE, combine all target statistics in one plot, versus one plot per target statistic if FALSE.
alpha
transparency level for lines, where 0 = transparent and 1 = opaque.
lwd
line width for output values.
...
additional arguments to pass to main plot.

Details

The plot function for epiNet.simNet objects will generate plots of two types of model diagnostic statistics that were run as part of the diagnostic tools within that simulation function. The formation plot shows the summary statistics requested in stats.form, which defaults to those in the formation formula. The duration plot shows the average age of all partnerships at each time step, up until the maximum time step requested. This is estimated with the edgelist.meanage function.

The plots.joined argument will control whether the target statistics in the formation plot are joined in one plot or plotted separately. The default is based on the number of network statistics requested. The layout of the separate plots within the larger plot window is also based on the number of statistics.

Required for these plots is that the estimation diagnostics are run in epiNet.simNet. This happens by default, and is set with the stats=TRUE argument in that function.

See Also

epiNet.simNet

Examples

Run this code
# See epiNet.est help to understand these steps
nw <- network.initialize(n = 500, directed = FALSE)
nw <- set.vertex.attribute(nw, "race", value = rep(0:1, each = 250))
formation <- ~ edges + nodematch("race") + degree(0) + concurrent
target.stats <- c(225, 187, 180, 90)
dissolution <- ~ offset(edges)
coef.diss <- dissolution.coefs(dissolution, durations = 20)

# Model estimation using the direct STERGM fit, then simulation
est <- epiNet.est(
  nw,
  formation,
  dissolution,
  target.stats,
  coef.diss,
  edapprox = FALSE)
nwsims <- epiNet.simNet(est, nsteps = 250, nsims = 10)

# Default will plot all simulations for target statistics formation plot
plot(nwsims)

# If that is too busy, try adjusting the line width or transparency with alpha
plot(nwsims, lwd=0.5)
plot(nwsims, lwd=0.75, alpha=0.5)

# If still too busy, then split plots
plot(nwsims, plots.joined=FALSE)

# Or plot just a subset of simulations
plot(nwsims, sim=1)
plot(nwsims, sim=4:6, lwd=0.6)

# Or plot just a subset of time
plot(nwsims, dx.start=100, dx.end=150, alpha=0.4)

# Duration plot shows the average age of partnerships along each time step
# Since a nodematch term was used in the dissolution, it will plot
#   partnerships matched and unmatched separately
plot(nwsims, type="duration", alpha=0.5)

# Truncate plot to start after time 100, given the age ramp up period
plot(nwsims, type="duration", dx.start=100, lwd=0.5)

Run the code above in your browser using DataLab