| covdepGE | R Documentation |
Model the conditional dependence structure of X as a function
of Z as described in (1)
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 )
X |
n x p numeric matrix; data matrix. For best results, n should be greater than p |
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 (0, 1); if |
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 [1, Inf]; norm to use when
calculating weights. |
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 (0, 1); a graph for each observation
will be constructed by including an edge between variable i and
variable j if, and only if, the (i, j) entry of the symmetrized
posterior inclusion probability matrix corresponding to the observation is
greater than |
sym_method |
|
parallel |
logical; if doParallel::registerDoParallel(num_workers)
|
num_workers |
num_workers <- floor(parallel::detectCores() / 2)
|
prog_bar |
logical; if |
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 p lists; the j-th list has the following values for variable j fixed as the response:
|
model_details |
list with the following values:
|
weights |
list with the following values:
|
(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.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.