Learn R Programming

gdim (version 0.1.1)

plot.eigcv: Plot cross-validated eigenvalues

Description

Plot cross-validated eigenvalues

Usage

# S3 method for eigcv
plot(x, type = c("z-score", "adjacency", "laplacian"), threshold = 2, ...)

Value

A ggplot2 object.

Arguments

x

An eigcv object created by a call to eigcv().

type

Specifies what to plot. Must be one of the following options:

  • "z-score", in which case the Z-statistic test scores are plotted for each value of k (i.e. dimension of the eigenspace).

  • "adjacency" in which case the cross-validated eigenvalues of the adjacency matrix are plotted for each value of k.

  • "laplacian" in which case the cross-validated eigenvalues of the graph Laplacian matrix are plotted for each value of k.

threshold

Only used when type == "z-score". Adds a horizontal line at the value of threshold, which should be a numeric of length one. Defaults to 2.

...

Ignored.

Examples

Run this code

library(fastRG)

set.seed(27)

B <- matrix(0.1, 5, 5)
diag(B) <- 0.3

model <- sbm(
  n = 200,
  B = B,
  expected_degree = 20,
  poisson_edges = FALSE,
  allow_self_loops = FALSE
)

A <- sample_sparse(model)

eigs<- eigcv(A, k_max = 7)
eigs

plot(eigs, type = "z-score")    # default
plot(eigs, type = "adjacency")
plot(eigs, type = "laplacian")


Run the code above in your browser using DataLab