Learn R Programming

clusterGGM (version 0.1.1)

clusterpath_weights: Compute the Weight Matrix for the Clusterpath Penalty

Description

Compute the (possibly sparse) weight matrix for the clusterpath penalty in the clusterpath estimator of the Gaussian graphical model (CGGM). Weights are computed based on a distance measure so that variables that are close are clustered more quickly (higher weight) than variables that are far apart (lower weight). Only neighboring variables thereby receive a nonzero weight. Additionally, groups of variables that would not be connected via nonzero weights due to the sparsity of the weight matrix can still be connected by applying a minimum spanning tree algorithm.

Usage

clusterpath_weights(S, phi, k, connected = TRUE)

Value

A weight matrix for the clusterpath penalty.

Arguments

S

The sample covariance matrix of the data.

phi

Tuning parameter of the weights.

k

The number of nearest neighbors that should be used to set weights to a nonzero value. If 0 < k < ncol(S), the dense weight matrix will be made sparse, otherwise the dense matrix is returned.

connected

A logical indicating whether a connected weight matrix should be enforced. Defaults to TRUE.

Author

Daniel J.W. Touw

References

D.J.W. Touw, A. Alfons, P.J.F. Groenen and I. Wilms (2025) Clusterpath Gaussian Graphical Modeling. arXiv:2407.00644. doi:10.48550/arXiv.2407.00644.

See Also

lasso_weights(), cggm(), cggm_refit(), cggm_cv()

Examples

Run this code
# Generate data
set.seed(3)
Theta <- matrix(
  c(2, 1, 0, 0,
    1, 2, 0, 0,
    0, 0, 4, 1,
    0, 0, 1, 4),
  nrow = 4
)
X <- mvtnorm::rmvnorm(n = 100, sigma = solve(Theta))

# Estimate the covariance matrix
S <- cov(X)

# Compute the weight matrix for the clusterpath (clustering) weights
W_cpath <- clusterpath_weights(S, phi = 1, k = 2)
W_cpath

Run the code above in your browser using DataLab