plot.JANE {JANE} | R Documentation |
Plot JANE fits
Description
S3 plot method for object of class "JANE
".
Usage
## 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,
...
)
Arguments
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 |
... |
Unused. |
Details
The classification of actors into specific clusters is based on a hard clustering rule of \{h | Z_{ih} = max_k Z_{ik}\}
. Additionally, the actor-specific classification uncertainty is derived as 1 - max_k Z_{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}
(i.e., theN \times K
cluster membership probability matrix) between subsequent iterations. The exact quantile of the absolute difference plotted are presented in parentheses and determined by theJANE
control parameterquantile_diff
. For example, the default control parameterquantile_diff
= 1, so the values being plotted are the max absolute difference in\hat{Z}
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}
andU
(i.e., theN \times D
matrix of latent positions) across subsequent iterations (absolute change in\hat{Z}
andU
computed in an identical manner as described above). This metric is only tracked beginning at an iteration determined by then_its_start_CA
control parameter inJANE
. Note, this plot may be empty if the EM algorithm converges before then_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 | Z_{ih} = max_k Z_{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}
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 inU
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 specifictermination_rule
employed andU
across iterations. As previously mentioned, if the EM algorithm converges before then_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.
Value
A plot of the network or trace plot of the EM run.
See Also
surfacePlot
, adjustedRandIndex
, classError
, NMI
Examples
# 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,
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, 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)