plot.netdx | R Documentation |
Plots dynamic network model diagnostics calculated in
netdx
.
## S3 method for class 'netdx'
plot(
x,
type = "formation",
method = "l",
sims = NULL,
stats = NULL,
duration.imputed = TRUE,
sim.lines = FALSE,
sim.col = NULL,
sim.lwd = NULL,
mean.line = TRUE,
mean.smooth = TRUE,
mean.col = NULL,
mean.lwd = 2,
mean.lty = 1,
qnts = 0.5,
qnts.col = NULL,
qnts.alpha = 0.5,
qnts.smooth = TRUE,
targ.line = TRUE,
targ.col = NULL,
targ.lwd = 2,
targ.lty = 2,
plots.joined = NULL,
legend = NULL,
grid = FALSE,
...
)
x |
An |
type |
Plot type, with options of |
method |
Plot method, with options of |
sims |
A vector of simulation numbers to plot. |
stats |
Statistics to plot. For |
duration.imputed |
If |
sim.lines |
If |
sim.col |
Vector of any standard R color format for simulation lines. |
sim.lwd |
Line width for simulation lines. |
mean.line |
If |
mean.smooth |
If |
mean.col |
Vector of any standard R color format for mean lines. |
mean.lwd |
Line width for mean lines. |
mean.lty |
Line type for mean lines. |
qnts |
If numeric, plot polygon of simulation quantiles based on the
range implied by the argument (see details). If |
qnts.col |
Vector of any standard R color format for polygons. |
qnts.alpha |
Transparency level for quantile polygons, where 0 =
transparent and 1 = opaque (see |
qnts.smooth |
If |
targ.line |
If |
targ.col |
Vector of standard R colors for target statistic lines, with
default colors based on |
targ.lwd |
Line width for the line showing the target statistic values. |
targ.lty |
Line type for the line showing the target statistic values. |
plots.joined |
If |
legend |
If |
grid |
If |
... |
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. The age is used as an
estimator of the average duration of edges in the equilibrium state. When
duration.imputed = FALSE
, edges that exist at the beginning of the
simulation are assumed to start with an age of 1, yielding a burn-in period
before the observed mean approaches its target. When
duration.imputed = TRUE
, expected ages prior to the start of the
simulation are calculated from the dissolution model, typically eliminating
the need for a burn-in period.
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
are joined in one plot or plotted separately, assuming there are multiple
statistics in the model. 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.
netdx
## Not run:
# Network initialization and model parameterization
nw <- network_initialize(n = 500)
nw <- set_vertex_attribute(nw, "sex", rbinom(500, 1, 0.5))
formation <- ~edges + nodematch("sex")
target.stats <- c(500, 300)
coef.diss <- dissolution_coefs(dissolution = ~offset(edges) +
offset(nodematch("sex")), duration = c(50, 40))
# 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", levels = NULL) +
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", levels = NULL) +
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
par(mfrow = c(1, 2))
# With duration imputed
plot(dx2, type = "duration", sim.line = TRUE, sim.lwd = 0.3,
targ.lty = 1, targ.lwd = 0.5)
# Without duration imputed
plot(dx2, type = "duration", sim.line = TRUE, sim.lwd = 0.3,
targ.lty = 1, targ.lwd = 0.5, duration.imputed = FALSE)
# Dissolution statistics plot
plot(dx2, type = "dissolution", qnts = 0.25, grid = TRUE)
plot(dx2, type = "dissolution", method = "b", col = "pink1")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.