Learn R Programming

clusterGGM (version 0.1.1)

get_Theta: Extract the Estimated Precision Matrix

Description

Extract a (block-structured and sparse) precision matrix obtained via the clusterpath estimator of the Gaussian graphical model (CGGM).

Usage

get_Theta(object, ...)

# S3 method for CGGM get_Theta(object, index, ...)

# S3 method for CGGM_refit get_Theta(object, index, ...)

# S3 method for CGGM_CV get_Theta(object, which = NULL, ...)

Value

The estimated (block-structured and sparse) precision matrix.

For the "CGGM_CV" method (see cggm_cv()), the returned precision matrix corresponds to the optimal values of the tuning parameters.

Arguments

object

an object from which to extract the precision matrix.

...

additional arguments are currently ignored.

index

an integer specifying the step along the clusterpath for which to extract the precision matrix.

which

a character string specifying for which solution to extract the precision matrix. Possible values are "refit" for the solution including the refitting step (see cggm_refit()), or "fit" for the solution without without the refitting step (see cggm()). If NULL (the default), the solution with the better cross-validation score is used.

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

cggm(), cggm_refit(), cggm_cv()

get_clusters()

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)

# Compute the weight matrix for the lasso (sparsity) weights
W_lasso <- lasso_weights(S)

# Set values to be used for the aggregation parameter
lambdas <- seq(0, 0.2, by = 0.01)

# Estimate the precision matrix while automatically expanding
# the sequence of values for the aggregation parameter
fit <- cggm(S, W_cpath = W_cpath, lambda_cpath = lambdas,
            W_lasso = W_lasso, lambda_lasso = 0.2,
            expand = TRUE)

# Precision matrix with 2 clusters
get_Theta(fit, index = fit$cluster_solution_index[2])


# Apply the refitting step to the results, estimating the
# precision matrix based on the clustering and sparsity
# patterns but without additional shrinkage
refit <- cggm_refit(fit)

# Precision matrix with 2 clusters
get_Theta(refit, index = refit$cluster_solution_index[2])

Run the code above in your browser using DataLab