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 class "JANE", a result of a call to JANE.

type

A character string to select the type of plot:

  • 'lsnc': plot the network using the estimated latent positions and color-code actors by cluster (default)

  • 'misclassified': (can only be used if true_labels is !NULL) similar to 'lsnc', but will color misclassified actors in black

  • 'uncertainty': similar to 'lsnc', but here the color gradient applied represents the actor-specific classification uncertainty

  • 'trace_plot': presents various trace plots across the iterations of the EM algorithm

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 TRUE then plots fit using the starting parameters used in the EM algorithm (default is FALSE, i.e., the results after the EM algorithm is run are plotted).

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 swap_axes = TRUE) through the specified angle about the origin (default is 0 degrees). Only relevant when D (i.e., dimension of the latent space) >= 2 and type != 'trace_plot'.

alpha_edge

A numeric value in [0,1] that controls the transparency of the network edges (default is 0.1).

alpha_node

A numeric value in [0,1] that controls the transparency of the actors in the network (default is 1).

swap_axes

A logical; if TRUE will swap the x and y axes (default is FALSE).

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 K.

...

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:

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)


[Package JANE version 0.2.1 Index]