covdepGE {covdepGE} | R Documentation |
Covariate Dependent Graph Estimation
Description
Model the conditional dependence structure of X
as a function
of Z
as described in (1)
Usage
covdepGE(
X,
Z = NULL,
hp_method = "hybrid",
ssq = NULL,
sbsq = NULL,
pip = NULL,
nssq = 5,
nsbsq = 5,
npip = 5,
ssq_mult = 1.5,
ssq_lower = 1e-05,
snr_upper = 25,
sbsq_lower = 1e-05,
pip_lower = 1e-05,
pip_upper = NULL,
tau = NULL,
norm = 2,
center_X = TRUE,
scale_Z = TRUE,
alpha_tol = 1e-05,
max_iter_grid = 10,
max_iter = 100,
edge_threshold = 0.5,
sym_method = "mean",
parallel = FALSE,
num_workers = NULL,
prog_bar = TRUE
)
Arguments
X |
|
Z |
Z <- rep(0, nrow(X)) If |
hp_method |
|
ssq |
ssq <- seq(ssq_lower, ssq_upper, length.out = nssq)
|
sbsq |
sbsq <- seq(sbsq_lower, sbsq_upper, length.out = nsbsq)
|
pip |
pip <- seq(pip_lower, pi_upper, length.out = npip)
|
nssq |
positive integer; number of points to generate for |
nsbsq |
positive integer; number of points to generate for |
npip |
positive integer; number of points to generate for |
ssq_mult |
positive numeric; if ssq_upper <- ssq_mult * stats::var(X_j) Then, |
ssq_lower |
positive numeric; if |
snr_upper |
positive numeric; upper bound on the signal-to-noise ratio.
If s2_sum <- sum(apply(X, 2, stats::var)) sbsq_upper <- snr_upper / (pip_upper * s2_sum) Then, |
sbsq_lower |
positive numeric; if |
pip_lower |
numeric in |
pip_upper |
lasso <- glmnet::cv.glmnet(X, X_j) non0 <- sum(glmnet::coef.glmnet(lasso, s = "lambda.1se")[-1] != 0) non0 <- min(max(non0, 1), p - 1) pip_upper <- non0 / p
|
tau |
|
norm |
numeric in |
center_X |
logical; if |
scale_Z |
logical; if |
alpha_tol |
positive numeric; end CAVI when the Frobenius norm of the
change in the alpha matrix is within |
max_iter_grid |
positive integer; if tolerance criteria has not been
met by |
max_iter |
positive integer; if tolerance criteria has not been met by
|
edge_threshold |
numeric in |
sym_method |
|
parallel |
logical; if doParallel::registerDoParallel(num_workers)
|
num_workers |
num_workers <- floor(parallel::detectCores() / 2)
|
prog_bar |
logical; if |
Value
Returns object of class covdepGE
with the following values:
graphs |
list with the following values:
|
variational_params |
list with the following values:
|
hyperparameters |
list of
|
model_details |
list with the following values:
|
weights |
list with the following values:
|
References
(1) Sutanoy Dasgupta, Peng Zhao, Prasenjit Ghosh, Debdeep Pati, and Bani Mallick. An approximate Bayesian approach to covariate-dependent graphical modeling. pages 1–59, 2022.
(2) Sutanoy Dasgupta, Debdeep Pati, and Anuj Srivastava. A Two-Step Geometric Framework For Density Modeling. Statistica Sinica, 30(4):2155–2177, 2020.
Examples
## Not run:
library(ggplot2)
# get the data
set.seed(12)
data <- generateData()
X <- data$X
Z <- data$Z
interval <- data$interval
prec <- data$true_precision
# get overall and within interval sample sizes
n <- nrow(X)
n1 <- sum(interval == 1)
n2 <- sum(interval == 2)
n3 <- sum(interval == 3)
# visualize the distribution of the extraneous covariate
ggplot(data.frame(Z = Z, interval = as.factor(interval))) +
geom_histogram(aes(Z, fill = interval), color = "black", bins = n %/% 5)
# visualize the true precision matrices in each of the intervals
# interval 1
matViz(prec[[1]], incl_val = TRUE) +
ggtitle(paste0("True precision matrix, interval 1, observations 1,...,", n1))
# interval 2 (varies continuously with Z)
cat("\nInterval 2, observations ", n1 + 1, ",...,", n1 + n2, sep = "")
int2_mats <- prec[interval == 2]
int2_inds <- c(5, n2 %/% 2, n2 - 5)
lapply(int2_inds, function(j) matViz(int2_mats[[j]], incl_val = TRUE) +
ggtitle(paste("True precision matrix, interval 2, observation", j + n1)))
# interval 3
matViz(prec[[length(prec)]], incl_val = TRUE) +
ggtitle(paste0("True precision matrix, interval 3, observations ",
n1 + n2 + 1, ",...,", n1 + n2 + n3))
# fit the model and visualize the estimated graphs
(out <- covdepGE(X, Z))
plot(out)
# visualize the posterior inclusion probabilities for variables (1, 3) and (1, 2)
inclusionCurve(out, 1, 2)
inclusionCurve(out, 1, 3)
## End(Not run)