plot.lrpsadmmpath: Plotting for 'lrpsadmmpath' Objects

Description Usage Arguments See Also Examples

View source: R/fit_path.R

Description

Plots the sparsity and number of edges of S as a function of the tuning parameter lambda (see documentation of lrpsadmmpath). The rank of L as a function of lambda.

The user can also provide a matrix of 0s and 1s to be used as "ground truth". If the location of non-zero entries of S is known (for example because this is simulated data), then the precision/recall metrics are computed and plotted. See examples below.

Usage

1
2
## S3 method for class 'lrpsadmmpath'
plot(x, ground.truth = NULL)

Arguments

x

An object of class lrpsadmmpath output by the function lrpsadmmpath

ground.truth

A binary matrix representing the adjacency matrix of the "true" graph one seeks to recover. Useful mostly on simulated data where the true parameter is known.

See Also

lrpsadmm lrpsadmm.cv

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
set.seed(0)
# Generate data with a well-powered dataset
sim.data <- generate.latent.ggm.data(n=2000, p=100, h=5, outlier.fraction = 0.0,
                                     sparsity = 0.02, sparsity.latent = 0.7)
X <- sim.data$obs.data; Sigma <- cor(X) # Sample correlation matrix


gamma <- 0.1 # Some reasonble value for gamma
# We ask for 30 lambdas, but the sparse graph becomes too dense so the
# computation is stopped.
my.path <- lrpsadmm.path(Sigma = Sigma, gamma = gamma,
                         lambda.ratio = 1e-03, n.lambdas = 30, verbose = TRUE)

# This time let us ask for 30 values, but let us narrow down the range by using a
# a smaller ratio
my.path <- lrpsadmm.path(Sigma = Sigma, gamma = gamma,
                         lambda.max = 0.96, lambda.ratio = 0.1, n.lambdas = 30, verbose = TRUE)

# Plot some basic information about the path
plot(my.path)
# Look at the first graph in the path
plot(my.path[[1]]$fit)
# Because this is simulated data, we know the ground truth
# Let us use it to compute the precsion and recall metrics
# along the path
ground.truth <- sim.data$precision.matrix[1:100, 1:100]
# Remove the elements along the diagonal. Keep a matrix of 0s and 1s
ground.truth <- 1 * (( ground.truth - diag(diag(ground.truth)) ) !=0)
# There is a new plot with the precision / recall curve
plot(my.path, ground.truth = ground.truth)

benjaminfrot/lrpsadmm documentation built on Oct. 19, 2019, 8:13 a.m.