Title: Flexible and Accurate Gaussian Graphical Models
Version: 0.1
Description: In order to achieve accurate estimation without sparsity assumption on the precision matrix, element-wise inference on the precision matrix, and joint estimation of multiple Gaussian graphical models, a novel method is proposed and efficient algorithm is implemented. FLAG() is the main function given a data matrix, and FlagOneEdge() will be used when one pair of random variables are interested where their indices should be given. Flexible and Accurate Methods for Estimation and Inference of Gaussian Graphical Models with Applications, see Qian Y (2023) <doi:10.14711/thesis-991013223054603412>, Qian Y, Hu X, Yang C (2023) <doi:10.48550/arXiv.2306.17584>.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.1.2
Imports: stats, MASS
URL: https://github.com/YangLabHKUST/FLAG
BugReports: https://github.com/YangLabHKUST/FLAG/issues
NeedsCompilation: no
Packaged: 2025-04-10 09:36:49 UTC; asus
Author: Yueqi QIAN ORCID iD [aut, cre]
Maintainer: Yueqi QIAN <yqianai@connect.ust.hk>
Repository: CRAN
Date/Publication: 2025-04-12 08:10:06 UTC

FLAG is the main function to fulfill the whole process.

Description

FLAG is the main function to fulfill the whole process.

Usage

FLAG(
  data,
  scale.var = TRUE,
  low.rank = NULL,
  infer = "llr",
  eps = 1e-07,
  crit.loglik = 1e-04
)

Arguments

data

Matrix, with size n*p.

scale.var

Logical, whether to scale the variance of X to 1/p, default to be T(RUE).

low.rank

Logical, whether to use low rank update to shrink the time of eigen-decomposition of XX^T, default to be TRUE when sample size larger than 1000.

infer

Character, option of different tests of inference where 'llr' for likelihood ratio test and 'wald' for Wald test based on Fisher Information Matrix.

eps

Numeric, a small term to avoid numerical problems, default to be 1e-7.

crit.loglik

Numeric, the criteria of the change ratio of log likelihood to stop.

Value

List, the estimated precision matrix, the p-value of precision matrix estimation, the edge existence using Bonferroni correction, the edge existence using false discovery rate, the matrix of estimated eta, the standard error or estimated eta, the matrix of estimated partial correlation rho, the standard error or estimated partial correlation rho, the p-value of partial correlation matrix estimation, the matrix of estimated sigma_a^2, the standard error or estimated sigma_b^2, the execution time.

Examples

N = 20
P = 10
pi = 0.2
Pre = matrix(sample(c(0.2, 0.4), P*P, replace = TRUE) * rbinom(P*P, 1, pi), nrow = P, ncol = P )
Pre[lower.tri(Pre)] = t(Pre)[lower.tri(Pre)]
diag(Pre) = 1
vals <- eigen(Pre)$values
Sigma = solve(Pre)
Z = MASS::mvrnorm(N, rep(0, P), Sigma)
Z.c = scale(Z, center = TRUE, scale = FALSE)
results = FLAG(Z.c)


Use FLAG to infer one edge. Given n*p data matrix, when we only interest in the conditional dependence between i-th and j-th variables.

Description

Use FLAG to infer one edge. Given n*p data matrix, when we only interest in the conditional dependence between i-th and j-th variables.

Usage

FlagOneEdge(data, i, j, scale.var = TRUE, infer = "llr", eps = 1e-07)

Arguments

data

Matrix, with size n*p.

i

integer, the index of one element.

j

integer, the index of another element.

scale.var

Logical, whether to scale the variance of X to 1/p, default to be T(RUE).

infer

Character, option of different tests of inference where 'llr' for likelihood ratio test and 'wald' for Wald test based on Fisher Information Matrix.

eps

Numeric, a small term to avoid numerical problems, default to be 1e-7.

Value

List, the list of log likelihood during iterations, the estimated precision value, the p-value of precision value estimation, the estimated Gamma_beta matrix with size 22, in the random effects model, the estimated Gamma_epsilon matrix with size 22, in the random effects model, the estimated off-diagonal element eta in the matrix Gamma_epsilon, the standard error of eta, the estimated partial correlation rho, the standard error of rho, the p-value of rho, the execution time.

Examples


FlagOneEdge(matrix, i, j)


FLAG for one pair of random variables, using random effects model. This is a repeated function for FLAG.

Description

FLAG for one pair of random variables, using random effects model. This is a repeated function for FLAG.

Usage

FlagOnePair(
  Y,
  X,
  Gamma_beta = NULL,
  Gamma_e = NULL,
  infer = "llr",
  fix.eta = FALSE,
  eps = 1e-07,
  max.iter = 5000,
  crit.loglik = 1e-04
)

Arguments

Y

Matrix, with size n*2.

X

Matrix, with size n*(p-2).

Gamma_beta

Matrix, with size 2*2.

Gamma_e

Matrix, with size 2*2.

infer

Character, option of different tests of inference where 'llr' for likelihood ratio test and 'wald' for Wald test based on Fisher Information Matrix.

fix.eta

Logical, whether to fix eta, default to be FALSE.

eps

Numeric, a small term to avoid numerical problems, default to be 1e-7.

max.iter

Integer, the maximum number of iterations, default to be 5000.

crit.loglik

Numeric, the criteria of the change ratio of log likelihood to stop.

Value

List, the list of log likelihood during iterations, the estimated Gamma_beta matrix with size 22, in the random effects model, the estimated Gamma_epsilon matrix with size 22, in the random effects model, the estimated 2*2 submatrix of the precision matrix, the covariance matrix, which is the inverse of the Fisher information matrix, inferred by the Wald test, the estimated off-diagonal element eta in the matrix Gamma_epsilon, the standard error of eta, the p-value of eta, the estimated partial correlation rho, the standard error of rho, the p-value of rho.

Examples


FlagOnePair(Y, X)


FLAG for one pair of random variables fixing eta as zero, using likelihood-ratio test.

Description

FLAG for one pair of random variables fixing eta as zero, using likelihood-ratio test.

Usage

FlagOnePairEta0(
  Y,
  X,
  Gamma_beta,
  Gamma_e,
  eps = 1e-07,
  max.iter = 5000,
  crit.loglik = 1e-04
)

Arguments

Y

Matrix, with size n*2.

X

Matrix, with size n*(p-2).

Gamma_beta

Matrix, with size 2*2.

Gamma_e

Matrix, with size 2*2.

eps

Numeric, a small term to avoid numerical problems, default to be 1e-4.

max.iter

Integer, the maximum number of iterations, default to be 5000.

crit.loglik

Numeric, the criteria of the change ratio of log likelihood to stop.

Value

List, the list of log likelihood during iterations, Numeric, the log likelihood of the last iterations, the estimated Gamma_beta matrix with size 22, in the random effects model, the estimated Gamma_epsilon matrix with size 22, in the random effects model, the estimated 2*2 submatrix of the precision matrix.

Examples


FlagOnePairEta0(Y, X, Gamma_beta, Gamma_e)


Get the standard error of rho.

Description

Get the standard error of rho.

Usage

GetSeRho(Gamma_e, Gamma_e_cov)

Arguments

Gamma_e

Matrix, with size 2*2.

Gamma_e_cov

Matrix, with size 2*2.

Value

Numeric.

Examples


GetSeRho(Gamma_e,Gamma_e_cov)


Infer by the Wald test.

Description

Infer by the Wald test.

Usage

InferWald(Omega.inv, n, K, Y.vec, Gamma_e)

Arguments

Omega.inv

Matrix, with size (2n)*(2n).

n

Integer.

K

Matrix, with size n*n.

Y.vec

Matrix, with size (2*n)*1, the vectorized Y.

Gamma_e

Matrix, with size 2*2.

Value

List, the covariance matrix, which is the inverse of the Fisher information matrix, inferred by the Wald test, the estimated off-diagonal element eta in the matrix Gamma_epsilon, the standard error of eta, the p-value of eta, the estimated partial correlation rho, the standard error of rho, the p-value of rho.

Examples


InferWald(Omega.inv, n, K, Y.vec, Gamma_e)