
Last chance! 50% off unlimited learning
Sale ends in
Plots dynamic network model diagnostics calculated in
netdx
.
# S3 method for netdx
plot(
x,
type = "formation",
method = "l",
sims,
stats,
sim.lines,
sim.col,
sim.lwd,
mean.line = TRUE,
mean.smooth = TRUE,
mean.col,
mean.lwd = 2,
mean.lty = 1,
qnts = 0.5,
qnts.col,
qnts.alpha,
qnts.smooth = TRUE,
targ.line = TRUE,
targ.col,
targ.lwd = 2,
targ.lty = 2,
plots.joined,
legend,
grid = FALSE,
...
)
An EpiModel
object of class netdx
.
Plot type, with options of "formation"
for network
model formation statistics, "duration"
for dissolution model
statistics for average edge duration, or "dissolution"
for
dissolution model statistics for proportion of ties dissolved per time
step.
Plot method, with options of "l"
for line plots and
"b"
for boxplots.
If type="epi"
or "formation"
, a vector of
simulation numbers to plot. If type="network"
, a single
simulation number for network plot, or else "min"
to plot the
simulation number with the lowest disease prevalence, "max"
for
the simulation with the highest disease prevalence, or "mean"
for the simulation with the prevalance closest to the mean across
simulations at the specified time step.
Network statistics to plot, among those specified in the call
to netdx
, with the default to plot all statistics
contained in the object.
If TRUE
, plot individual simulation lines. Default is
to plot lines for one-group models but not for two-group models.
Vector of any standard R color format for simulation lines.
Line width for simulation lines.
If TRUE
, plot mean of simulations across time.
If TRUE
, use a lowess smoother on the mean line.
Vector of any standard R color format for mean lines.
Line width for mean lines.
Line type for mean lines.
If numeric, plot polygon of simulation quantiles based on the
range implied by the argument (see details). If FALSE
, suppress
polygon from plot.
Vector of any standard R color format for polygons.
Transparency level for quantile polygons, where 0 =
transparent and 1 = opaque (see transco
).
If TRUE
, use a lowess smoother on quantile polygons.
If TRUE
, plot target or expected value line for
the statistic of interest.
Vector of standard R colors for target statistic lines, with
default colors based on RColorBrewer
color palettes.
Line width for the line showing the target statistic values.
Line type for the line showing the target statistic values.
If TRUE
and type="formation"
, combine all
target statistics in one plot, versus one plot per target statistic if
FALSE
.
If TRUE
, plot default legend.
If TRUE
, a grid is added to the background of plot
(see grid
for details), with default of nx by ny.
additional arguments to pass.
The plot function for netdx
objects will generate plots of two types of
model diagnostic statistics that run as part of the diagnostic tools within
that function. The formation
plot shows the summary statistics
requested in nwstats.formula
, where the default includes those
statistics in the network model formation formula specified in the original
call to netest
.
The duration
plot shows the average age of existing edges at each time
step, up until the maximum time step requested. This is calculated with the
edgelist_meanage
function. The age is used as an estimator of
the average duration of edges in the equilibrium state.
The dissolution
plot shows the proportion of the extant ties that are
dissolved at each time step, up until the maximum time step requested.
Typically, the proportion of ties that are dissolved is the reciprocal of the
mean relational duration. This plot thus contains similar information to that
in the duration plot, but should reach its expected value more quickly, since
it is not subject to censoring.
The plots.joined
argument will control whether the 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.
# NOT RUN {
# Network initialization and model parameterization
nw <- network.initialize(100, directed = FALSE)
nw <- set.vertex.attribute(nw, "sex", rbinom(100, 1, 0.5))
formation <- ~edges + nodematch("sex")
target.stats <- c(50, 40)
coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 50)
# Estimate the model
est <- netest(nw, formation, target.stats, coef.diss, verbose = FALSE)
# Static diagnostics
dx1 <- netdx(est, nsims = 1e4, dynamic = FALSE,
nwstats.formula = ~edges + meandeg + concurrent +
nodefactor("sex", base = 0) +
nodematch("sex"))
dx1
# Plot diagnostics
plot(dx1)
plot(dx1, stats = c("edges", "concurrent"), mean.col = "black",
sim.lines = TRUE, plots.joined = FALSE)
plot(dx1, stats = "edges", method = "b",
col = "seagreen3", grid = TRUE)
# Dynamic diagnostics
dx2 <- netdx(est, nsims = 10, nsteps = 500,
nwstats.formula = ~edges + meandeg + concurrent +
nodefactor("sex", base = 0) +
nodematch("sex"))
dx2
# Formation statistics plots, joined and separate
plot(dx2, grid = TRUE)
plot(dx2, type = "formation", plots.joined = TRUE)
plot(dx2, type = "formation", sims = 1, plots.joined = TRUE,
qnts = FALSE, sim.lines = TRUE, mean.line = FALSE)
plot(dx2, type = "formation", plots.joined = FALSE,
stats = c("edges", "concurrent"), grid = TRUE)
plot(dx2, method = "b", col = "bisque", grid = TRUE)
plot(dx2, method = "b", stats = "meandeg", col = "dodgerblue")
# Duration statistics plot
plot(dx2, type = "duration", mean.col = "black", grid = TRUE)
plot(dx2, type = "duration", sims = 10, mean.line = FALSE, sim.line = TRUE,
sim.col = "steelblue", sim.lwd = 3, targ.lty = 1, targ.lwd = 0.5)
# Dissolution statistics plot
plot(dx2, type = "dissolution", mean.col = "black", grid = TRUE)
plot(dx2, type = "dissolution", method = "b", col = "pink1")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab