plot.JANE | R Documentation |
S3 plot method for object of class "JANE
".
## S3 method for class 'JANE'
plot(
x,
type = "lsnc",
true_labels,
initial_values = FALSE,
zoom = 100,
density_type = "contour",
rotation_angle = 0,
alpha_edge = 0.1,
alpha_node = 1,
swap_axes = FALSE,
main,
xlab,
ylab,
cluster_cols,
remove_noise_edges = FALSE,
...
)
x |
An object of S3 |
type |
A character string to select the type of plot:
|
true_labels |
(optional) A numeric, character, or factor vector of known true cluster labels. Must have the same length as number of actors in the fitted network. Need to account for potential isolates removed. |
initial_values |
A logical; if |
zoom |
A numeric value > 0 that controls the % magnification of the plot (default is 100%). |
density_type |
Choose from one of the following three options: 'contour' (default), 'hdr', 'image', and 'persp' indicating the density plot type. |
rotation_angle |
A numeric value that rotates the estimated latent positions and contours of the multivariate normal distributions clockwise (or counterclockwise if |
alpha_edge |
A numeric value in |
alpha_node |
A numeric value in |
swap_axes |
A logical; if |
main |
An optional overall title for the plot. |
xlab |
An optional title for the x axis. |
ylab |
An optional title for the y axis. |
cluster_cols |
An optional vector of colors for the clusters. Must have a length of at least |
remove_noise_edges |
(only applicable if |
... |
Unused. |
The classification of actors into specific clusters is based on a hard clustering rule of \{h | \hat{Z}^{U}_{ih} = max_k \hat{Z}^{U}_{ik}\}
. Additionally, the actor-specific classification uncertainty is derived as 1 - max_k \hat{Z}^{U}_{ik}
.
The trace plot contains up to five unique plots tracking various metrics across the iterations of the EM algorithm, depending on the JANE
control parameter termination_rule
:
termination_rule = 'prob_mat'
: Five plots will be presented. Specifically, in the top panel, the plot on the left presents the change in the absolute difference in {\hat{Z}^U}
(i.e., the N \times K
cluster membership probability matrix) between subsequent iterations and, if noise_weights = TRUE
, the change in the absolute difference in {\hat{Z}^W}
(i.e., the |E| \times 2
edge weight cluster membership probability matrix) between subsequent iterations. The exact quantile of the absolute difference plotted are presented in parentheses and determined by the JANE
control parameter quantile_diff
. For example, the default control parameter quantile_diff
= 1, so the values being plotted are the max absolute difference in {\hat{Z}^U}
(and potentially {\hat{Z}^W}
) between subsequent iterations. The plot on the right of the top panel presents the absolute difference in the cumulative average of the absolute change in {\hat{Z}^U}
(and potentially {\hat{Z}^W}
) and \hat{U}
(i.e., the N \times D
matrix of latent positions) across subsequent iterations (absolute change in {\hat{Z}^U}
, {\hat{Z}^W}
, and \hat{U}
are computed in an identical manner as described previously). This metric is only tracked beginning at an iteration determined by the n_its_start_CA
control parameter in JANE
. Note, this plot may be empty if the EM algorithm converges before the n_its_start_CA
-th iteration. Finally, the bottom panel presents ARI, NMI, and CER values comparing the classifications between subsequent iterations, respectively. Specifically, at a given iteration we determine the classification of actors in clusters based on a hard clustering rule of \{h | \hat{Z}^{U}_{ih} = max_k \hat{Z}^{U}_{ik}\}
and given these labels from two subsequent iterations, we compute and plot the ARI, NMI and CER.
termination_rule = 'Q'
: Plots generated are similar to those described in the previous bullet point. However, instead of tracking the change in {\hat{Z}^U}
(and potentially {\hat{Z}^W}
) over iterations, here the absolute difference in the objective function of the E-step evaluated using parameters from subsequent iterations is tracked. Furthermore, the cumulative average of the absolute change in \hat{U}
is no longer tracked.
termination_rule %in% c('ARI', 'NMI', 'CER')
: Four plots will be presented. Specifically, the top left panel presents a plot of the absolute difference in the cumulative average of the absolute change in the specific termination_rule
employed and \hat{U}
across iterations. As previously mentioned, if the EM algorithm converges before the n_its_start_CA
-th iteration then this will be an empty plot. Furthermore, the other three plots present ARI, NMI, and CER values comparing the classifications between subsequent iterations, respectively.
A plot of the network or trace plot of the EM run.
If an error interrupts the plotting process, the graphics device may be left in a state where par("new") = TRUE. This can cause subsequent plots to be overlaid. To reset the graphics state, call plot.new() or close and reopen the device with dev.off(); dev.new().
surfacePlot
, adjustedRandIndex
, classError
, NMI
# Simulate network
mus <- matrix(c(-1,-1,1,-1,1,1),
nrow = 3,
ncol = 2,
byrow = TRUE)
omegas <- array(c(diag(rep(7,2)),
diag(rep(7,2)),
diag(rep(7,2))),
dim = c(2,2,3))
p <- rep(1/3, 3)
beta0 <- 1.0
sim_data <- JANE::sim_A(N = 100L,
model = "NDH",
mus = mus,
omegas = omegas,
p = p,
params_LR = list(beta0 = beta0),
remove_isolates = TRUE)
# Run JANE on simulated data
res <- JANE::JANE(A = sim_data$A,
D = 2L,
K = 3L,
initialization = "GNN",
model = "NDH",
case_control = FALSE,
DA_type = "none")
# plot trace plot
plot(res, type = "trace_plot")
# plot network
plot(res)
# plot network - misclassified
plot(res, type = "misclassified", true_labels = apply(sim_data$Z_U, 1, which.max))
# plot network - uncertainty and swap axes
plot(res, type = "uncertainty", swap_axes = TRUE)
# plot network - but only show contours of MVNs
plot(res, swap_axes = TRUE, alpha_edge = 0, alpha_node = 0)
# plot using starting values of EM algorithm
plot(res, initial_values = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.