Title: | Bayesian Structure Learning in Graphical Models using Birth-Death MCMC |
---|---|
Description: | Advanced statistical tools for Bayesian structure learning in undirected graphical models, accommodating continuous, ordinal, discrete, count, and mixed data. It integrates recent advancements in Bayesian graphical models as presented in the literature, including the works of Mohammadi and Wit (2015) <doi:10.1214/14-BA889>, Mohammadi et al. (2021) <doi:10.1080/01621459.2021.1996377>, Dobra and Mohammadi (2018) <doi:10.1214/18-AOAS1164>, and Mohammadi et al. (2023) <doi:10.48550/arXiv.2307.00127>. |
Authors: | Reza Mohammadi [aut, cre] , Ernst Wit [aut] , Adrian Dobra [ctb] |
Maintainer: | Reza Mohammadi <[email protected]> |
License: | GPL (>= 2) |
Version: | 2.73 |
Built: | 2024-11-22 06:52:45 UTC |
Source: | CRAN |
The R
package BDgraph provides statistical tools for Bayesian structure learning in undirected graphical models for continuous, ordinal/count/dicrete, binary, and mixed data. The package is implemented the recent improvements in the Bayesian graphical models' literature, including Mohammadi and Wit (2015), Mohammadi et al. (2023), Mohammadi et al. (2017), and Dobra and Mohammadi (2018). To speed up the computations, the intensive tasks of the package are implemented in parallel using OpenMP in C++
and interfaced with R
. Besides, the package contains several functions for simulation and visualization, as well as several multivariate datasets taken from the literature.
To cite BDgraph in publications use:
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Reza Mohammadi [aut, cre] (<https://orcid.org/0000-0001-9538-0648>),
Ernst Wit [aut] (<https://orcid.org/0000-0002-3671-9610>),
Adrian Dobra [ctb] (<https://orcid.org/0000-0001-7793-2197>).
Maintainer: Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
Mohammadi, A., et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645, doi:10.1111/rssc.12171
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845, doi:10.1214/18-AOAS1164
Vogels, L., Mohammadi, R., Schoonhoven, M., and Birbil, S.I. (2023) Bayesian Structure Learning in Undirected Gaussian Graphical Models: Literature Review with Empirical Comparison, arXiv preprint, doi:10.48550/arXiv.2307.02603
Mohammadi, R., Schoonhoven, M., Vogels, L., and Birbil, S.I. (2023) Large-scale Bayesian Structure Learning for Gaussian Graphical Models using Marginal Pseudo-likelihood, arXiv preprint, doi:10.48550/arXiv.2307.00127
Vinciotti, V., Behrouzi, P., and Mohammadi, R. (2022) Bayesian structural learning of microbiota systems from count metagenomic data, arXiv preprint, doi:10.48550/arXiv.2203.10118
Dobra, A. and Lenkoski, A. (2011). Copula Gaussian graphical models and their application to modeling functional disability data, The Annals of Applied Statistics, 5(2A):969-93, doi:10.1214/10-AOAS397
Dobra, A., et al. (2011). Bayesian inference for general Gaussian graphical models with application to multivariate lattice data. Journal of the American Statistical Association, 106(496):1418-33, doi:10.1198/jasa.2011.tm10465
Mohammadi, A. and Dobra, A. (2017). The R
Package BDgraph for Bayesian Structure Learning in Graphical Models, ISBA Bulletin, 24(4):11-16
Lenkoski, A. (2013). A direct sampler for G-Wishart variates, Stat, 2(1):119-28, doi:10.1002/sta4.23
Pensar, J. et al (2017) Marginal pseudo-likelihood learning of discrete Markov network structures, Bayesian Analysis, 12(4):1195-215, doi:10.1214/16-BA1032
bdgraph
, bdgraph.mpl
, bdgraph.dw
, bdgraph.sim
, compare
, rgwish
## Not run: library( BDgraph ) set.seed( 10 ) # Generating multivariate normal data from a 'scale-free' graph data.sim <- bdgraph.sim( n = 100, p = 10, graph = "scale-free", vis = TRUE ) # Running algorithm based on GGMs bdgraph.obj <- bdgraph( data = data.sim, iter = 5000 ) summary( bdgraph.obj ) # To compare the result with true graph compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ), vis = TRUE ) # Confusion Matrix conf.mat( actual = data.sim, pred = bdgraph.obj ) conf.mat.plot( actual = data.sim, pred = bdgraph.obj ) # Running algorithm based on GGMs and marginal pseudo-likelihood bdgraph.mpl.obj <- bdgraph.mpl( data = data.sim, iter = 5000 ) summary( bdgraph.mpl.obj ) # Confusion Matrix conf.mat( actual = data.sim, pred = bdgraph.mpl.obj ) conf.mat.plot( actual = data.sim, pred = bdgraph.mpl.obj ) # To compare the results of both algorithms with true graph compare( list( bdgraph.obj, bdgraph.mpl.obj ), data.sim, main = c( "Target", "BDgraph", "BDgraph_mpl" ), vis = TRUE ) ## End(Not run)
## Not run: library( BDgraph ) set.seed( 10 ) # Generating multivariate normal data from a 'scale-free' graph data.sim <- bdgraph.sim( n = 100, p = 10, graph = "scale-free", vis = TRUE ) # Running algorithm based on GGMs bdgraph.obj <- bdgraph( data = data.sim, iter = 5000 ) summary( bdgraph.obj ) # To compare the result with true graph compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ), vis = TRUE ) # Confusion Matrix conf.mat( actual = data.sim, pred = bdgraph.obj ) conf.mat.plot( actual = data.sim, pred = bdgraph.obj ) # Running algorithm based on GGMs and marginal pseudo-likelihood bdgraph.mpl.obj <- bdgraph.mpl( data = data.sim, iter = 5000 ) summary( bdgraph.mpl.obj ) # Confusion Matrix conf.mat( actual = data.sim, pred = bdgraph.mpl.obj ) conf.mat.plot( actual = data.sim, pred = bdgraph.mpl.obj ) # To compare the results of both algorithms with true graph compare( list( bdgraph.obj, bdgraph.mpl.obj ), data.sim, main = c( "Target", "BDgraph", "BDgraph_mpl" ), vis = TRUE ) ## End(Not run)
Extract links from an adjacency matrix or an object of calsses "sim
" from function bdgraph.sim
and
"graph"
from function graph.sim
.
adj2link( adj )
adj2link( adj )
adj |
adjacency matrix corresponding to a graph structure in which |
matrix corresponding to the extracted links from graph structure.
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
# Generating a 'random' graph adj <- graph.sim( p = 6, vis = TRUE ) adj2link( adj )
# Generating a 'random' graph adj <- graph.sim( p = 6, vis = TRUE ) adj2link( adj )
This function computes the numeric value of area under the ROC curve (AUC) specifically for graph structure learning.
auc( pred, actual, cut = 200, calibrate = TRUE )
auc( pred, actual, cut = 200, calibrate = TRUE )
pred |
adjacency matrix corresponding to an estimated graph.
It can be an object with |
actual |
adjacency matrix corresponding to the actual graph structure in which |
cut |
number of cut points. |
calibrate |
If |
The numeric AUC value
Reza Mohammadi [email protected]; Lucas Vogels [email protected]
Tom Fawcett (2006) “An introduction to ROC analysis”. Pattern Recognition Letters 27, 861–874, doi:10.1016/j.patrec.2005.10.010
Xavier Robin, Natacha Turck, Alexandre Hainard, et al. (2011) “pROC: an open-source package for R and S+ to analyze and compare ROC curves”. BMC Bioinformatics, 7, 77, doi:10.1186/1471-2105-12-77.
plotroc
, pROC::plot.roc()
, pROC::auc()
, pROC::print.roc()
, bdgraph
, bdgraph.mpl
, compare
## Not run: set.seed( 5 ) # Generating multivariate normal data from a 'scale-free' graph data.sim = bdgraph.sim( n = 200, p = 15, graph = "scale-free", vis = TRUE ) # Running BDMCMC algorithm sample.bdmcmc = bdgraph( data = data.sim, algorithm = "bdmcmc", iter = 10000 ) BDgraph::auc( pred = sample.bdmcmc, actual = data.sim, calibrate = TRUE ) ## End(Not run)
## Not run: set.seed( 5 ) # Generating multivariate normal data from a 'scale-free' graph data.sim = bdgraph.sim( n = 200, p = 15, graph = "scale-free", vis = TRUE ) # Running BDMCMC algorithm sample.bdmcmc = bdgraph( data = data.sim, algorithm = "bdmcmc", iter = 10000 ) BDgraph::auc( pred = sample.bdmcmc, actual = data.sim, calibrate = TRUE ) ## End(Not run)
As the main function of the BDgraph package,
this function consists of several MCMC sampling algorithms for Bayesian model determination in undirected graphical models.
To speed up the computations, the birth-death MCMC sampling algorithms are implemented in parallel using OpenMP in C++
.
bdgraph( data, n = NULL, method = "ggm", algorithm = "bdmcmc", iter = 5000, burnin = iter / 2, not.cont = NULL, g.prior = 0.2, df.prior = 3, g.start = "empty", jump = NULL, save = FALSE, cores = NULL, threshold = 1e-8, verbose = TRUE, nu = 1 )
bdgraph( data, n = NULL, method = "ggm", algorithm = "bdmcmc", iter = 5000, burnin = iter / 2, not.cont = NULL, g.prior = 0.2, df.prior = 3, g.start = "empty", jump = NULL, save = FALSE, cores = NULL, threshold = 1e-8, verbose = TRUE, nu = 1 )
data |
there are two options: (1) an ( |
n |
number of observations. It is needed if the " |
method |
character with two options " |
algorithm |
character with two options " |
iter |
number of iteration for the sampling algorithm. |
burnin |
number of burn-in iteration for the sampling algorithm. |
not.cont |
for the case |
g.prior |
for determining the prior distribution of each edge in the graph.
There are two options: a single value between |
df.prior |
degree of freedom for G-Wishart distribution, |
g.start |
corresponds to a starting point of the graph. It could be an ( |
jump |
it is only for the BDMCMC algorithm ( |
save |
logical: if FALSE (default), the adjacency matrices are NOT saved. If TRUE, the adjacency matrices after burn-in are saved. |
cores |
number of cores to use for parallel execution.
The case |
threshold |
threshold value for the convergence of sampling algorithm from G-Wishart for the precision matrix. |
verbose |
logical: if TRUE (default), report/print the MCMC running time. |
nu |
prior parameter for option |
An object with S3
class "bdgraph
" is returned:
p_links |
upper triangular matrix which corresponds the estimated posterior probabilities of all possible links. |
K_hat |
posterior estimation of the precision matrix. |
For the case "save
= TRUE
" is returned:
sample_graphs |
vector of strings which includes the adjacency matrices of visited graphs after burn-in. |
graph_weights |
vector which includes the waiting times of visited graphs after burn-in. |
all_graphs |
vector which includes the identity of the adjacency matrices for all iterations after burn-in. It is needed for monitoring the convergence of the BD-MCMC algorithm. |
all_weights |
vector which includes the waiting times for all iterations after burn-in. It is needed for monitoring the convergence of the BD-MCMC algorithm. |
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645, doi:10.1111/rssc.12171
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845, doi:10.1214/18-AOAS1164
Vogels, L., Mohammadi, R., Schoonhoven, M., and Birbil, S.I. (2023) Bayesian Structure Learning in Undirected Gaussian Graphical Models: Literature Review with Empirical Comparison, arXiv preprint, doi:10.48550/arXiv.2307.02603
Mohammadi, R., Schoonhoven, M., Vogels, L., and Birbil, S.I. (2023) Large-scale Bayesian Structure Learning for Gaussian Graphical Models using Marginal Pseudo-likelihood, arXiv preprint, doi:10.48550/arXiv.2307.00127
Mohammadi, A. and Dobra A. (2017). The R
Package BDgraph for Bayesian Structure Learning in Graphical Models, ISBA Bulletin, 24(4):11-16
bdgraph.mpl
, bdgraph.dw
, bdgraph.sim
, summary.bdgraph
, compare
## Not run: set.seed( 10 ) # - - Example 1 # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 100, p = 10, size = 15, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, iter = 1000, save = TRUE ) summary( bdgraph.obj ) # Confusion Matrix conf.mat( actual = data.sim, pred = bdgraph.obj ) conf.mat.plot( actual = data.sim, pred = bdgraph.obj ) # To compare our result with true graph compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ), vis = T ) # Running algorithm with starting points from previous run bdgraph.obj2 <- bdgraph( data = data.sim, g.start = bdgraph.obj ) compare( list( bdgraph.obj, bdgraph.obj2 ), data.sim, main = c( "Target", "Frist run", "Second run" ) ) # - - Example 2 # Generating mixed data from a 'scale-free' graph data.sim <- bdgraph.sim( n = 200, p = 7, type = "mixed", graph = "scale-free", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, method = "gcgm" ) summary( bdgraph.obj ) compare( bdgraph.obj, data.sim, vis = T ) conf.mat( actual = data.sim, pred = bdgraph.obj ) conf.mat.plot( actual = data.sim, pred = bdgraph.obj ) ## End(Not run)
## Not run: set.seed( 10 ) # - - Example 1 # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 100, p = 10, size = 15, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, iter = 1000, save = TRUE ) summary( bdgraph.obj ) # Confusion Matrix conf.mat( actual = data.sim, pred = bdgraph.obj ) conf.mat.plot( actual = data.sim, pred = bdgraph.obj ) # To compare our result with true graph compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ), vis = T ) # Running algorithm with starting points from previous run bdgraph.obj2 <- bdgraph( data = data.sim, g.start = bdgraph.obj ) compare( list( bdgraph.obj, bdgraph.obj2 ), data.sim, main = c( "Target", "Frist run", "Second run" ) ) # - - Example 2 # Generating mixed data from a 'scale-free' graph data.sim <- bdgraph.sim( n = 200, p = 7, type = "mixed", graph = "scale-free", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, method = "gcgm" ) summary( bdgraph.obj ) compare( bdgraph.obj, data.sim, vis = T ) conf.mat( actual = data.sim, pred = bdgraph.obj ) conf.mat.plot( actual = data.sim, pred = bdgraph.obj ) ## End(Not run)
This function consists of several sampling algorithms for Bayesian structure learning in undirected graphical models for count data. It is based on Gaussian copula graphical models with discrete Weibull distributed marginals.
To speed up the computations, the birth-death MCMC sampling algorithms are implemented in parallel using OpenMP in C++
.
bdgraph.dw( data, x = NULL, formula = y ~ ., n = NULL, algorithm = "bdmcmc", iter = 5000, burnin = iter / 2, g.prior = 0.2, df.prior = 3, ZI = FALSE, iter_bdw = 5000, g.start = "empty", jump = NULL, save = FALSE, q = NULL, beta = NULL, pii = NULL, cores = NULL, threshold = 1e-8, verbose = TRUE )
bdgraph.dw( data, x = NULL, formula = y ~ ., n = NULL, algorithm = "bdmcmc", iter = 5000, burnin = iter / 2, g.prior = 0.2, df.prior = 3, ZI = FALSE, iter_bdw = 5000, g.start = "empty", jump = NULL, save = FALSE, q = NULL, beta = NULL, pii = NULL, cores = NULL, threshold = 1e-8, verbose = TRUE )
data |
( |
x |
( |
formula |
object of class formula as a symbolic description of the model for linking each node to the predictors. For the case of |
n |
number of observations. It is needed if the " |
algorithm |
character with two options " |
iter |
number of iterations for the sampling algorithm for graph learning. |
burnin |
number of burn-in iterations for the sampling algorithm for graph learning. |
g.prior |
for determining the prior distribution of each edge in the graph.
There are two options: a single value between |
df.prior |
degree of freedom for G-Wishart distribution, |
ZI |
logical. If FALSE (default), the conditional distribution of each response variable is assumed to be Discrete Weibull given the predictors |
iter_bdw |
number of iterations for the sampling algorithm to estimate the regression parameters for the Discrete Weibull distribution. It is passed to the |
g.start |
corresponds to a starting point of the graph. It could be an ( |
jump |
it is only for the BDMCMC algorithm ( |
save |
logical: if FALSE (default), the adjacency matrices are NOT saved. If TRUE, the adjacency matrices after burn-in are saved. |
q , beta
|
parameters of the discrete Weibull distribution used for the marginals. They should be given either as a ( |
pii |
vector or matrix of zero-inflation parameters of the zero-inflated discrete Weibull distributions used for the marginals. If NULL (default), this parameter is estimated by the |
cores |
number of cores to use for parallel execution.
The case |
threshold |
threshold value for the convergence of the sampling algorithm from G-Wishart for the precision matrix. |
verbose |
logical: if TRUE (default), report/print the MCMC running time. |
An object with S3
class "bdgraph
" is returned, containing:
p_links |
upper triangular matrix corresponding to the estimated posterior probabilities of all possible links. |
K_hat |
posterior estimation of the precision matrix. |
sample_marginals |
posterior samples of the regression coefficients of the marginal distributions. |
For the case "save
= TRUE
", the code returns:
sample_graphs |
vector of strings which includes the adjacency matrices of the graphs visited after burn-in. |
graph_weights |
vector which includes the waiting times of the graphs visited after burn-in. |
all_graphs |
vector which includes the identity of the adjacency matrices for all iterations after burn-in. It is needed for monitoring the convergence of the BDMCMC algorithm. |
all_weights |
vector which includes the waiting times for all iterations after burn-in. It is needed for monitoring the convergence of the BDMCMC algorithm. |
Reza Mohammadi [email protected], Veronica Vinciotti, and Pariya Behrouzi
Vinciotti, V., Behrouzi, P., and Mohammadi, R. (2022) Bayesian structural learning of microbiota systems from count metagenomic data, arXiv preprint, doi:10.48550/arXiv.2203.10118
Peluso, A., Vinciotti, V., and Yu, K. (2018) Discrete Weibull generalized additive model: an application to count fertility, Journal of the Royal Statistical Society: Series C, 68(3):565-583, doi:10.1111/rssc.12311
Haselimashhadi, H., Vinciotti, V., and Yu, K. (2018) A novel Bayesian regression model for counts with an application to health data, Journal of Applied Statistics, 45(6):1085-1105, doi:10.1080/02664763.2017.1342782
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645, doi:10.1111/rssc.12171
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
bdgraph
, bdgraph.mpl
, bdw.reg
, bdgraph.sim
, summary.bdgraph
, compare
## Not run: # - - Example 1 # Generating multivariate Discrete Weibull data based on 'random' graph data.sim <- bdgraph.sim( n = 100, p = 10, type = "dw", vis = TRUE ) bdgraph.obj <- bdgraph.dw( data = data.sim, iter = 5000 ) summary( bdgraph.obj ) # To compare the result with true graph compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ), vis = TRUE ) # - - Example 2 # Generating multivariate Discrete Weibull data based on a 'scale-free' graph data.sim <- bdgraph.sim( n = 100, p = 10, type = "dw", graph = "scale-free", vis = TRUE ) bdgraph.obj <- bdgraph.dw( data = data.sim, iter = 10000 ) summary( bdgraph.obj ) compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ), vis = TRUE ) ## End(Not run)
## Not run: # - - Example 1 # Generating multivariate Discrete Weibull data based on 'random' graph data.sim <- bdgraph.sim( n = 100, p = 10, type = "dw", vis = TRUE ) bdgraph.obj <- bdgraph.dw( data = data.sim, iter = 5000 ) summary( bdgraph.obj ) # To compare the result with true graph compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ), vis = TRUE ) # - - Example 2 # Generating multivariate Discrete Weibull data based on a 'scale-free' graph data.sim <- bdgraph.sim( n = 100, p = 10, type = "dw", graph = "scale-free", vis = TRUE ) bdgraph.obj <- bdgraph.dw( data = data.sim, iter = 10000 ) summary( bdgraph.obj ) compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ), vis = TRUE ) ## End(Not run)
This function consists of several sampling algorithms for Bayesian model determination in undirected graphical models based on mariginal pseudo-likelihood.
To speed up the computations, the birth-death MCMC sampling algorithms are implemented in parallel using OpenMP in C++
.
bdgraph.mpl( data, n = NULL, method = "ggm", transfer = TRUE, algorithm = "bdmcmc", iter = 5000, burnin = iter / 2, g.prior = 0.2, g.start = "empty", jump = NULL, alpha = 0.5, save = FALSE, cores = NULL, operator = "or", verbose = TRUE )
bdgraph.mpl( data, n = NULL, method = "ggm", transfer = TRUE, algorithm = "bdmcmc", iter = 5000, burnin = iter / 2, g.prior = 0.2, g.start = "empty", jump = NULL, alpha = 0.5, save = FALSE, cores = NULL, operator = "or", verbose = TRUE )
data |
there are two options: (1) an ( |
n |
number of observations. It is needed if the " |
method |
character with two options " |
transfer |
for only |
algorithm |
character with two options " |
iter |
number of iteration for the sampling algorithm. |
burnin |
number of burn-in iteration for the sampling algorithm. |
g.prior |
for determining the prior distribution of each edge in the graph.
There are two options: a single value between |
g.start |
corresponds to a starting point of the graph. It could be an ( |
jump |
it is only for the BDMCMC algorithm ( |
alpha |
value of the hyper parameter of Dirichlet, which is a prior distribution. |
save |
logical: if FALSE (default), the adjacency matrices are NOT saved. If TRUE, the adjacency matrices after burn-in are saved. |
cores |
number of cores to use for parallel execution.
The case |
operator |
character with two options " |
verbose |
logical: if TRUE (default), report/print the MCMC running time. |
An object with S3
class "bdgraph
" is returned:
p_links |
upper triangular matrix which corresponds the estimated posterior probabilities of all possible links. |
For the case "save
= TRUE
" is returned:
sample_graphs |
vector of strings which includes the adjacency matrices of visited graphs after burn-in. |
graph_weights |
vector which includes the waiting times of visited graphs after burn-in. |
all_graphs |
vector which includes the identity of the adjacency matrices for all iterations after burn-in. It is needed for monitoring the convergence of the BD-MCMC algorithm. |
all_weights |
vector which includes the waiting times for all iterations after burn-in. It is needed for monitoring the convergence of the BD-MCMC algorithm. |
Reza Mohammadi [email protected], Adrian Dobra, and Johan Pensar
Mohammadi, R., Schoonhoven, M., Vogels, L., and Birbil, S.I. (2023) Large-scale Bayesian Structure Learning for Gaussian Graphical Models using Marginal Pseudo-likelihood, arXiv preprint, doi:10.48550/arXiv.2307.00127
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845, doi:10.1214/18-AOAS1164
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Vogels, L., Mohammadi, R., Schoonhoven, M., and Birbil, S.I. (2023) Bayesian Structure Learning in Undirected Gaussian Graphical Models: Literature Review with Empirical Comparison, arXiv preprint, doi:10.48550/arXiv.2307.02603
Mohammadi, A. and Dobra, A. (2017). The R
Package BDgraph for Bayesian Structure Learning in Graphical Models, ISBA Bulletin, 24(4):11-16
Pensar, J. et al (2017) Marginal pseudo-likelihood learning of discrete Markov network structures, Bayesian Analysis, 12(4):1195-215, doi:10.1214/16-BA1032
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
bdgraph
, bdgraph.dw
, bdgraph.sim
, summary.bdgraph
, compare
# Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 70, p = 5, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph.mpl( data = data.sim, iter = 500 ) summary( bdgraph.obj ) # To compare the result with true graph compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ) )
# Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 70, p = 5, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph.mpl( data = data.sim, iter = 500 ) summary( bdgraph.obj ) # To compare the result with true graph compare( bdgraph.obj, data.sim, main = c( "Target", "BDgraph" ) )
Transfers non-Gaussian data to Gaussian.
bdgraph.npn( data, npn = "shrinkage", npn.thresh = NULL )
bdgraph.npn( data, npn = "shrinkage", npn.thresh = NULL )
data |
( |
npn |
character with three options |
npn.thresh |
truncation threshold; it is only for the truncated transformation ( |
() matrix of transferred data, if
npn = "shrinkage" or "truncation"
, and
a non-paranormal correlation () matrix, if
npn = "skeptic"
.
Reza Mohammadi [email protected]
Liu, H., et al (2012). High Dimensional Semiparametric Gaussian Copula Graphical Models, Annals of Statistics, 40(4):2293-2326
Zhao, T. and Liu, H. (2012). The huge Package for High-dimensional Undirected Graph Estimation in R
, Journal of Machine Learning Research, 13:1059-1062
bdgraph.sim
, bdgraph
, bdgraph.mpl
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 6, p = 4, size = 4 ) data <- ( data.sim $ data - 3 ) ^ 4 data # Transfer the data by truncation bdgraph.npn( data, npn = "truncation" ) # Transfer the data by shrunken bdgraph.npn( data, npn = "shrunken" ) # Transfer the data by skeptic bdgraph.npn( data, npn = "skeptic" ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 6, p = 4, size = 4 ) data <- ( data.sim $ data - 3 ) ^ 4 data # Transfer the data by truncation bdgraph.npn( data, npn = "truncation" ) # Transfer the data by shrunken bdgraph.npn( data, npn = "shrunken" ) # Transfer the data by skeptic bdgraph.npn( data, npn = "skeptic" ) ## End(Not run)
Simulating multivariate distributions with different types of underlying graph structures, including
"random
", "cluster
", "smallworld
", "scale-free
", "lattice
", "hub
", "star
", "circle
", "AR(1)
", and "AR(2)
".
Based on the underlying graph structure, the function generates different types of multivariate data, including "Gaussian", "non-Gaussian", "categorical", "pois" (Poisson), "nbinom" (negative binomial), "dweibull" (discrete Weibull), "binary", "t" (t-distribution), "alternative-t", or "mixed" data.
This function can be used also for simulating only graphs by setting the option n=0
(default).
bdgraph.sim( p = 10, graph = "random", n = 0, type = "Gaussian", prob = 0.2, size = NULL, mean = 0, class = NULL, cut = 4, b = 3, D = diag( p ), K = NULL, sigma = NULL, q = exp(-1), beta = 1, vis = FALSE, rewire = 0.05, range.mu = c( 3, 5 ), range.dispersion = c( 0.01, 0.1 ), nu = 1 )
bdgraph.sim( p = 10, graph = "random", n = 0, type = "Gaussian", prob = 0.2, size = NULL, mean = 0, class = NULL, cut = 4, b = 3, D = diag( p ), K = NULL, sigma = NULL, q = exp(-1), beta = 1, vis = FALSE, rewire = 0.05, range.mu = c( 3, 5 ), range.dispersion = c( 0.01, 0.1 ), nu = 1 )
p |
number of variables (nodes). |
graph |
graph structure with options
" |
n |
number of samples required. Note that for the case |
type |
type of data with options " |
prob |
if |
size |
number of links in the true graph (graph size). |
mean |
vector specifying the mean of the variables. |
class |
if |
cut |
if |
b |
degree of freedom for G-Wishart distribution, |
D |
positive definite |
K |
if |
sigma |
if |
q , beta
|
if
They can be given either as a vector of length p or as an ( |
vis |
visualize the true graph structure. |
rewire |
rewiring probability for smallworld network. Must be between 0 and 1. |
range.mu , range.dispersion
|
if |
nu |
if |
An object with S3
class "sim
" is returned:
data |
generated data as an ( |
sigma |
covariance matrix of the generated data. |
K |
precision matrix of the generated data. |
G |
adjacency matrix corresponding to the true graph structure. |
Reza Mohammadi [email protected], Pariya Behrouzi, Veronica Vinciotti, Ernst Wit, and Alexander Christensen
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
graph.sim
, bdgraph
, bdgraph.mpl
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( p = 10, n = 50, prob = 0.3, vis = TRUE ) print( data.sim ) # Generating multivariate normal data from a 'hub' graph data.sim <- bdgraph.sim( p = 6, n = 3, graph = "hub", vis = FALSE ) round( data.sim $ data, 2 ) # Generating mixed data from a 'hub' graph data.sim <- bdgraph.sim( p = 8, n = 10, graph = "hub", type = "mixed" ) round( data.sim $ data, 2 ) # Generating only a 'scale-free' graph (with no data) graph.sim <- bdgraph.sim( p = 8, graph = "scale-free" ) plot( graph.sim ) graph.sim $ G ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( p = 10, n = 50, prob = 0.3, vis = TRUE ) print( data.sim ) # Generating multivariate normal data from a 'hub' graph data.sim <- bdgraph.sim( p = 6, n = 3, graph = "hub", vis = FALSE ) round( data.sim $ data, 2 ) # Generating mixed data from a 'hub' graph data.sim <- bdgraph.sim( p = 8, n = 10, graph = "hub", type = "mixed" ) round( data.sim $ data, 2 ) # Generating only a 'scale-free' graph (with no data) graph.sim <- bdgraph.sim( p = 8, graph = "scale-free" ) plot( graph.sim ) graph.sim $ G ## End(Not run)
Bayesian estimation of the parameters for Discrete Weibull (DW) regression. The conditional distribution of the response given the predictors is assumed to be DW with parameters q and beta, dependent on the predictors, and, with an additional parameter pi under zero inflation.
bdw.reg( data, formula = NA, iter = 5000, burnin = NULL, dist.q = dnorm, dist.beta = dnorm, par.q = c( 0, 1 ), par.beta = c( 0, 1 ), par.pi = c( 1, 1 ), initial.q = NULL, initial.beta = NULL, initial.pi = NULL, ZI = FALSE, scale.proposal = NULL, adapt = TRUE, print = TRUE )
bdw.reg( data, formula = NA, iter = 5000, burnin = NULL, dist.q = dnorm, dist.beta = dnorm, par.q = c( 0, 1 ), par.beta = c( 0, 1 ), par.pi = c( 1, 1 ), initial.q = NULL, initial.beta = NULL, initial.pi = NULL, ZI = FALSE, scale.proposal = NULL, adapt = TRUE, print = TRUE )
data |
|
formula |
object of class formula as a symbolic description of the model to be fitted. For the case of |
iter |
number of iterations for the sampling algorithm. |
burnin |
number of burn-in iterations for the sampling algorithm. |
dist.q |
Prior density for the regression coefficients associated to the parameter |
dist.beta |
Prior density for the regression coefficients associated to the parameter |
par.q |
vector of length two corresponding to the parameters of |
par.beta |
vector of length two corresponding to the parameters of |
par.pi |
vector of length two corresponding to the parameters of the |
initial.q , initial.beta , initial.pi
|
vector of initial values for the regression coefficients and for |
ZI |
logical: if FALSE (default), the conditional distribution of the response given the predictors is assumed to be DW with parameters |
scale.proposal |
scale of the proposal function. Setting to lower values results in an increase in the acceptance rate of the sampler. |
adapt |
logical: if TRUE (default), the proposals will be adapted. If FALSE, no adapting will be applied. |
print |
logical: if TRUE (default), tracing information is printed. |
The regression model uses a logit link function on q
and a log link function on beta
, the two parameters of a DW distribution, with probability mass function given by
For the case of zero inflation (ZI
= TRUE
), a zero-inflated DW is considered:
where and
is an indicator for the point mass at zero for the response
y
.
sample |
MCMC samples |
q.est |
posterior estimates of |
beta.est |
posterior estimates of |
pi.est |
posterior estimates of |
accept.rate |
acceptance rate of the MCMC algorithm |
Veronica Vinciotti, Reza Mohammadi [email protected], and Pariya Behrouzi
Vinciotti, V., Behrouzi, P., and Mohammadi, R. (2022) Bayesian structural learning of microbiota systems from count metagenomic data, arXiv preprint, doi:10.48550/arXiv.2203.10118
Peluso, A., Vinciotti, V., and Yu, K. (2018) Discrete Weibull generalized additive model: an application to count fertility, Journal of the Royal Statistical Society: Series C, 68(3):565-583, doi:10.1111/rssc.12311
Haselimashhadi, H., Vinciotti, V. and Yu, K. (2018) A novel Bayesian regression model for counts with an application to health data, Journal of Applied Statistics, 45(6):1085-1105, doi:10.1080/02664763.2017.1342782
bdgraph.dw
, bdgraph
, ddweibull
, bdgraph.sim
## Not run: # - - Example 1 q = 0.6 beta = 1.1 n = 500 y = BDgraph::rdweibull( n = n, q = q, beta = beta ) output = bdw.reg( data = y, y ~ ., iter = 5000 ) output $ q.est output $ beta.est traceplot( output $ sample[ , 1 ], acf = T, pacf = T ) traceplot( output $ sample[ , 2 ], acf = T, pacf = T ) # - - Example 2 q = 0.6 beta = 1.1 pii = 0.8 n = 500 y_dw = BDgraph::rdweibull( n = n, q = q, beta = beta ) z = rbinom( n = n, size = 1, prob = pii ) y = z * y_dw output = bdw.reg( data = y, iter = 5000, ZI = TRUE ) output $ q.est output $ beta.est output $ pi.est traceplot( output $ sample[ , 1 ], acf = T, pacf = T ) traceplot( output $ sample[ , 2 ], acf = T, pacf = T ) traceplot( output $ sample[ , 3 ], acf = T, pacf = T ) # - - Example 3 theta.q = c( 0.1, -0.1, 0.34 ) # true parameter theta.beta = c( 0.1, -.15, 0.5 ) # true parameter n = 500 x1 = runif( n = n, min = 0, max = 1.5 ) x2 = runif( n = n, min = 0, max = 1.5 ) reg_q = theta.q[ 1 ] + x1 * theta.q[ 2 ] + x2 * theta.q[ 3 ] q = 1 / ( 1 + exp( - reg_q ) ) reg_beta = theta.beta[ 1 ] + x1 * theta.beta[ 2 ] + x2 * theta.beta[ 3 ] beta = exp( reg_beta ) y = BDgraph::rdweibull( n = n, q = q, beta = beta ) data = data.frame( x1, x2, y ) output = bdw.reg( data, y ~. , iter = 5000 ) # - - Example 4 theta.q = c( 1, -1, 0.8 ) # true parameter theta.beta = c( 1, -1, 0.3 ) # true parameter pii = 0.8 n = 500 x1 = runif( n = n, min = 0, max = 1.5 ) x2 = runif( n = n, min = 0, max = 1.5 ) reg_q = theta.q[ 1 ] + x1 * theta.q[ 2 ] + x2 * theta.q[ 3 ] q = 1 / ( 1 + exp( - reg_q ) ) reg_beta = theta.beta[ 1 ] + x1 * theta.beta[ 2 ] + x2 * theta.beta[ 3 ] beta = exp( reg_beta ) y_dw = BDgraph::rdweibull( n = n, q = q, beta = beta ) z = rbinom( n = n, size = 1, prob = pii ) y = z * y_dw data = data.frame( x1, x2, y ) output = bdw.reg( data, y ~. , iter = 5000, ZI = TRUE ) ## End(Not run)
## Not run: # - - Example 1 q = 0.6 beta = 1.1 n = 500 y = BDgraph::rdweibull( n = n, q = q, beta = beta ) output = bdw.reg( data = y, y ~ ., iter = 5000 ) output $ q.est output $ beta.est traceplot( output $ sample[ , 1 ], acf = T, pacf = T ) traceplot( output $ sample[ , 2 ], acf = T, pacf = T ) # - - Example 2 q = 0.6 beta = 1.1 pii = 0.8 n = 500 y_dw = BDgraph::rdweibull( n = n, q = q, beta = beta ) z = rbinom( n = n, size = 1, prob = pii ) y = z * y_dw output = bdw.reg( data = y, iter = 5000, ZI = TRUE ) output $ q.est output $ beta.est output $ pi.est traceplot( output $ sample[ , 1 ], acf = T, pacf = T ) traceplot( output $ sample[ , 2 ], acf = T, pacf = T ) traceplot( output $ sample[ , 3 ], acf = T, pacf = T ) # - - Example 3 theta.q = c( 0.1, -0.1, 0.34 ) # true parameter theta.beta = c( 0.1, -.15, 0.5 ) # true parameter n = 500 x1 = runif( n = n, min = 0, max = 1.5 ) x2 = runif( n = n, min = 0, max = 1.5 ) reg_q = theta.q[ 1 ] + x1 * theta.q[ 2 ] + x2 * theta.q[ 3 ] q = 1 / ( 1 + exp( - reg_q ) ) reg_beta = theta.beta[ 1 ] + x1 * theta.beta[ 2 ] + x2 * theta.beta[ 3 ] beta = exp( reg_beta ) y = BDgraph::rdweibull( n = n, q = q, beta = beta ) data = data.frame( x1, x2, y ) output = bdw.reg( data, y ~. , iter = 5000 ) # - - Example 4 theta.q = c( 1, -1, 0.8 ) # true parameter theta.beta = c( 1, -1, 0.3 ) # true parameter pii = 0.8 n = 500 x1 = runif( n = n, min = 0, max = 1.5 ) x2 = runif( n = n, min = 0, max = 1.5 ) reg_q = theta.q[ 1 ] + x1 * theta.q[ 2 ] + x2 * theta.q[ 3 ] q = 1 / ( 1 + exp( - reg_q ) ) reg_beta = theta.beta[ 1 ] + x1 * theta.beta[ 2 ] + x2 * theta.beta[ 3 ] beta = exp( reg_beta ) y_dw = BDgraph::rdweibull( n = n, q = q, beta = beta ) z = rbinom( n = n, size = 1, prob = pii ) y = z * y_dw data = data.frame( x1, x2, y ) output = bdw.reg( data, y ~. , iter = 5000, ZI = TRUE ) ## End(Not run)
Compute the Bayes factor for two graph structures.
bf( num, den, bdgraph.obj, log = TRUE )
bf( num, den, bdgraph.obj, log = TRUE )
num , den
|
adjacency matrix corresponding to the true graph structure in which |
bdgraph.obj |
object of |
log |
character value. If TRUE the Bayes factor is given as log(BF). |
single numeric value, the Bayes factor of the two graph structures num
and den
.
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
bdgraph
, bdgraph.mpl
, compare
, bdgraph.sim
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 50, p = 6, graph = "circle", vis = TRUE ) # Running sampling algorithm bdgraph.obj <- bdgraph( data = data.sim ) graph_1 <- graph.sim( p = 6, vis = TRUE ) graph_2 <- graph.sim( p = 6, vis = TRUE ) bf( num = graph_1, den = graph_2, bdgraph.obj = bdgraph.obj ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 50, p = 6, graph = "circle", vis = TRUE ) # Running sampling algorithm bdgraph.obj <- bdgraph( data = data.sim ) graph_1 <- graph.sim( p = 6, vis = TRUE ) graph_2 <- graph.sim( p = 6, vis = TRUE ) bf( num = graph_1, den = graph_2, bdgraph.obj = bdgraph.obj ) ## End(Not run)
This function provides several measures to assess the performance of the graphical structure learning.
compare( pred, actual, main = NULL, vis = FALSE )
compare( pred, actual, main = NULL, vis = FALSE )
pred |
adjacency matrix corresponding to an estimated graph.
It can be an object with |
actual |
adjacency matrix corresponding to the true graph structure in which |
main |
character vector giving the names for the result table. |
vis |
logical: if TRUE, visualize the true graph and estimated graph structures. |
True positive |
number of correctly estimated links. |
True negative |
number of true non-existing links which is correctly estimated. |
False positive |
number of links which they are not in the true graph, but are incorrectly estimated. |
False negative |
number of links which they are in the true graph, but are not estimated. |
F1-score |
weighted average of the |
Specificity |
Specificity value reaches its best value at 1 and worst score at 0. |
Sensitivity |
Sensitivity value reaches its best value at 1 and worst score at 0. |
MCC |
Matthews Correlation Coefficients (MCC) value reaches its best value at 1 and worst score at 0. |
Reza Mohammadi [email protected], Antonio Abbruzzo, and Ivan Vujacic
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
bdgraph
, bdgraph.mpl
, bdgraph.sim
, plotroc
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) # Running sampling algorithm based on GGMs sample.ggm <- bdgraph( data = data.sim, method = "ggm", iter = 10000 ) # Comparing the results compare( sample.ggm, data.sim, main = c( "True", "GGM" ), vis = TRUE ) # Running sampling algorithm based on GCGMs sample.gcgm <- bdgraph( data = data.sim, method = "gcgm", iter = 10000 ) # Comparing GGM and GCGM methods compare( list( sample.ggm, sample.gcgm ), data.sim, main = c( "True", "GGM", "GCGM" ), vis = TRUE ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) # Running sampling algorithm based on GGMs sample.ggm <- bdgraph( data = data.sim, method = "ggm", iter = 10000 ) # Comparing the results compare( sample.ggm, data.sim, main = c( "True", "GGM" ), vis = TRUE ) # Running sampling algorithm based on GCGMs sample.gcgm <- bdgraph( data = data.sim, method = "gcgm", iter = 10000 ) # Comparing GGM and GCGM methods compare( list( sample.ggm, sample.gcgm ), data.sim, main = c( "True", "GGM", "GCGM" ), vis = TRUE ) ## End(Not run)
Create a Confusion Matrix.
conf.mat( pred, actual, cutoff = 0.5, proportion = FALSE, dnn = c( "Prediction", "Actual" ), ... )
conf.mat( pred, actual, cutoff = 0.5, proportion = FALSE, dnn = c( "Prediction", "Actual" ), ... )
pred |
adjacency matrix corresponding to an estimated graph.
It can be an object with |
actual |
adjacency matrix corresponding to the actual graph structure in which |
cutoff |
cutoff value for the case that |
proportion |
logical: FALSE (default) for a confusion matrix with number of cases. TRUE, for a confusion matrix with the proportion of cases. |
dnn |
names to be given to the dimensions in the result (the dimnames names). |
... |
further arguments to be passed to |
the results of table
on pred
and actual
.
Reza Mohammadi [email protected]
conf.mat.plot
, compare
, roc
, bdgraph
## Not run: set.seed( 100 ) # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) # Running sampling algorithm based on GGMs sample.ggm <- bdgraph( data = data.sim, method = "ggm", iter = 10000 ) # Confusion Matrix for GGM method conf.mat( pred = sample.ggm, actual = data.sim ) ## End(Not run)
## Not run: set.seed( 100 ) # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) # Running sampling algorithm based on GGMs sample.ggm <- bdgraph( data = data.sim, method = "ggm", iter = 10000 ) # Confusion Matrix for GGM method conf.mat( pred = sample.ggm, actual = data.sim ) ## End(Not run)
Plot a Confusion Matrix.
conf.mat.plot( pred, actual, cutoff = 0.5, conf.level = 0, margin = 1, color = c( "#ff83a8", "#83ff9b" ), ... )
conf.mat.plot( pred, actual, cutoff = 0.5, conf.level = 0, margin = 1, color = c( "#ff83a8", "#83ff9b" ), ... )
pred |
adjacency matrix corresponding to an estimated graph.
It can be an object with |
actual |
adjacency matrix corresponding to the actual graph structure in which |
cutoff |
cutoff value for the case that |
conf.level |
confidence level used for the confidence rings on the odds ratios. Must be a single nonnegative number less than 1; if set to 0 (the default), confidence rings are suppressed. |
margin |
numeric vector with the margins to equate. Must be one of 1 (the default), 2, or c(1, 2), which corresponds to standardizing the row, column, or both margins in each 2 by 2 table. Only used if std equals "margins". |
color |
vector of length 2 specifying the colors to use for the smaller and larger diagonals of each 2 by 2 table. |
... |
options to be passed to |
Reza Mohammadi [email protected]
conf.mat
, compare
, roc
, bdgraph
## Not run: set.seed( 100 ) # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) # Running sampling algorithm based on GGMs sample.ggm <- bdgraph( data = data.sim, method = "ggm", iter = 10000 ) # Confusion Matrix for GGM method conf.mat.plot( pred = sample.ggm, actual = data.sim ) ## End(Not run)
## Not run: set.seed( 100 ) # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) # Running sampling algorithm based on GGMs sample.ggm <- bdgraph( data = data.sim, method = "ggm", iter = 10000 ) # Confusion Matrix for GGM method conf.mat.plot( pred = sample.ggm, actual = data.sim ) ## End(Not run)
Provides the estimated covariance matrix.
covariance( bdgraph.obj, round = 2 )
covariance( bdgraph.obj, round = 2 )
bdgraph.obj |
object of |
round |
value for rounding all probabilities to the specified number of decimal places. |
matrix which corresponds the estimated covariance matrix.
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 70, p = 6, graph = "circle", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) covariance( bdgraph.obj ) # Estimated covariance matrix data.sim $ sigma # True covariance matrix ## End(Not run)
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 70, p = 6, graph = "circle", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) covariance( bdgraph.obj ) # Estimated covariance matrix data.sim $ sigma # True covariance matrix ## End(Not run)
Density, distribution function, quantile function and random generation for the discrete Weibull distribution (type I) with parameters and
.
ddweibull( x, q = exp( -1 ), beta = 1, zero = TRUE ) pdweibull( x, q = exp( -1 ), beta = 1, zero = TRUE ) qdweibull( p, q = exp( -1 ), beta = 1, zero = TRUE ) rdweibull( n, q = exp( -1 ), beta = 1, zero = TRUE )
ddweibull( x, q = exp( -1 ), beta = 1, zero = TRUE ) pdweibull( x, q = exp( -1 ), beta = 1, zero = TRUE ) qdweibull( p, q = exp( -1 ), beta = 1, zero = TRUE ) rdweibull( n, q = exp( -1 ), beta = 1, zero = TRUE )
x |
vector of quantiles. |
p |
vector of probabilities. |
q , beta
|
shape and scale parameters, the latter defaulting to 1. |
zero |
logical; if |
n |
number of observations. If |
The discrete Weibull distribution has density given by
For the case zero
= FALSE
:
Cumulative distribution function
For the case zero
= FALSE
, x+1
should replaced by x
.
ddweibull
gives the density, pdweibull
gives the distribution function, qdweibull
gives the quantile function, and rdweibull
generates random values.
Reza Mohammadi [email protected], Pariya Behrouzi, Veronica Vinciotti
Nakagawa, T. and Osaki, S. (1975). The Discrete Weibull Distribution. IEEE Transactions on Reliability, R-24, 300-301, doi:10.1109/TR.1975.5214915
n = 1000 q = 0.4 beta = 0.8 set.seed( 7 ) rdw = rdweibull( n = n, q = q, beta = beta ) plot( prop.table( table( rdw ) ), type = "h", col = "gray50" ) x = 0:max( rdw ) lines( x, ddweibull( x = x, q = q, beta = beta ), type = "o", col = "blue", lwd = 2 ) hist( pdweibull( x = rdw, q = q, beta = beta ) ) plot( ecdf( rdw ) ) lines( x, pdweibull( x, q = q, beta = beta ), col = "blue", lwd = 2, type = "s" )
n = 1000 q = 0.4 beta = 0.8 set.seed( 7 ) rdw = rdweibull( n = n, q = q, beta = beta ) plot( prop.table( table( rdw ) ), type = "h", col = "gray50" ) x = 0:max( rdw ) lines( x, ddweibull( x = x, q = q, beta = beta ), type = "o", col = "blue", lwd = 2 ) hist( pdweibull( x = rdw, q = q, beta = beta ) ) plot( ecdf( rdw ) ) lines( x, pdweibull( x, q = q, beta = beta ), col = "blue", lwd = 2, type = "s" )
The dataset contains human gene expression of transcripts (with unique Illumina TargetID) measured on
unrelated individuals.
data( geneExpression )
data( geneExpression )
The format is a matrix with 60 rows (number of individuals) and 100 column (number of transcripts).
Bhadra, A. and Mallick, B. K. (2013). Joint High Dimensional Bayesian Variable and Covariance Selection with an Application to eQTL Analysis, Biometrics, 69(2):447-457, doi:10.1111/biom.12021
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
data( geneExpression ) dim( geneExpression ) head( geneExpression )
data( geneExpression ) dim( geneExpression ) head( geneExpression )
Calculates log of the normalizing constant of G-Wishart distribution based on the Monte Carlo method, developed by Atay-Kayis and Massam (2005).
gnorm( adj, b = 3, D = diag( ncol( adj ) ), iter = 100 )
gnorm( adj, b = 3, D = diag( ncol( adj ) ), iter = 100 )
adj |
adjacency matrix corresponding to the graph structure. It is an upper triangular matrix in which
|
b |
degree of freedom for G-Wishart distribution, |
D |
positive definite |
iter |
number of iteration for the Monte Carlo approximation. |
Log of the normalizing constant approximation using Monte Carlo method for a G-Wishart distribution, , with density:
Log of the normalizing constant of G-Wishart distribution.
Reza Mohammadi [email protected]
Atay-Kayis, A. and Massam, H. (2005). A monte carlo method for computing the marginal likelihood in nondecomposable Gaussian graphical models, Biometrika, 92(2):317-335, doi:10.1093/biomet/92.2.317
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
Uhler, C., et al (2018) Exact formulas for the normalizing constants of Wishart distributions for graphical models, The Annals of Statistics 46(1):90-118, doi:10.1214/17-AOS1543
## Not run: # adj: adjacency matrix of graph with 3 nodes and 2 links adj <- matrix( c( 0, 0, 1, 0, 0, 1, 0, 0, 0 ), 3, 3, byrow = TRUE ) gnorm( adj, b = 3, D = diag( 3 ) ) ## End(Not run)
## Not run: # adj: adjacency matrix of graph with 3 nodes and 2 links adj <- matrix( c( 0, 0, 1, 0, 0, 1, 0, 0, 0 ), 3, 3, byrow = TRUE ) gnorm( adj, b = 3, D = diag( 3 ) ) ## End(Not run)
Simulating undirected graph structures, including
"random
", "cluster
", "scale-free
", "lattice
", "hub
", "star
", and "circle
".
graph.sim( p = 10, graph = "random", prob = 0.2, size = NULL, class = NULL, vis = FALSE, rewire = 0.05 )
graph.sim( p = 10, graph = "random", prob = 0.2, size = NULL, class = NULL, vis = FALSE, rewire = 0.05 )
p |
number of variables (nodes). |
graph |
undirected graph with options
" |
prob |
if |
size |
number of links in the true graph (graph size). |
class |
if |
vis |
visualize the true graph structure. |
rewire |
rewiring probability for smallworld network. Must be between 0 and 1. |
The adjacency matrix corresponding to the simulated graph structure, as an object with S3
class "graph"
.
Reza Mohammadi [email protected] and Alexander Christensen
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
bdgraph.sim
, bdgraph
, bdgraph.mpl
# Generating a 'hub' graph adj <- graph.sim( p = 8, graph = "scale-free" ) plot( adj ) adj
# Generating a 'hub' graph adj <- graph.sim( p = 8, graph = "scale-free" ) plot( adj ) adj
Extract links from an adjacency matrix or an object of calsses "sim
" from function bdgraph.sim
and
"graph"
from function graph.sim
.
link2adj( link, p = NULL )
link2adj( link, p = NULL )
link |
( |
p |
number of nodes of the graph. |
An adjacency matrix corresponding to a graph structure in which if there is a link between notes
and
, otherwise
.
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
# Generating a 'random' graph adj <- graph.sim( p = 6, vis = TRUE ) link <- adj2link( adj ) link2adj( link, p = 6 )
# Generating a 'random' graph adj <- graph.sim( p = 6, vis = TRUE ) link <- adj2link( adj ) link2adj( link, p = 6 )
Computes (weighted) mean squared error.
mse( pred, actual, weight = FALSE )
mse( pred, actual, weight = FALSE )
pred |
adjacency matrix corresponding to an estimated graph.
It can be an object with |
actual |
adjacency matrix corresponding to the true graph structure in which |
weight |
for the case of weighted MSE. |
Reza Mohammadi [email protected]; Lucas Vogels [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
compare
, auc
, bdgraph
, bdgraph.mpl
, bdgraph.sim
, plotroc
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) # Running sampling algorithm based on GGMs sample.ggm <- bdgraph( data = data.sim, method = "ggm", iter = 10000 ) # To compute the value of MSE mse( pred = sample.ggm, actual = data.sim ) # To compute the value of weighted MSE mse( pred = sample.ggm, actual = data.sim, weight = 0.5 ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) # Running sampling algorithm based on GGMs sample.ggm <- bdgraph( data = data.sim, method = "ggm", iter = 10000 ) # To compute the value of MSE mse( pred = sample.ggm, actual = data.sim ) # To compute the value of weighted MSE mse( pred = sample.ggm, actual = data.sim, weight = 0.5 ) ## End(Not run)
Provides the estimated posterior probabilities for the most likely graphs or a specific graph.
pgraph( bdgraph.obj, number.g = 4, adj = NULL )
pgraph( bdgraph.obj, number.g = 4, adj = NULL )
bdgraph.obj |
object of |
number.g |
number of graphs with the highest posterior probabilities to be shown.
This option is ignored if |
adj |
adjacency matrix corresponding to a graph structure. It is an upper triangular matrix in which
|
selected_g |
adjacency matrices which corresponding to the graphs with the highest posterior probabilities. |
prob_g |
vector of the posterior probabilities of the graphs corresponding to |
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 6, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, save = TRUE ) # Estimated posterior probability of the true graph pgraph( bdgraph.obj, adj = data.sim ) # Estimated posterior probability of first and second graphs with highest probabilities pgraph( bdgraph.obj, number.g = 2 ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 6, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, save = TRUE ) # Estimated posterior probability of the true graph pgraph( bdgraph.obj, adj = data.sim ) # Estimated posterior probability of first and second graphs with highest probabilities pgraph( bdgraph.obj, number.g = 2 ) ## End(Not run)
Provides the estimated posterior link probabilities for all possible links in the graph.
plinks( bdgraph.obj, round = 2, burnin = NULL )
plinks( bdgraph.obj, round = 2, burnin = NULL )
bdgraph.obj |
object of |
round |
value for rounding all probabilities to the specified number of decimal places. |
burnin |
number of burn-in iteration to scape. |
An upper triangular matrix which corresponds the estimated posterior probabilities for all possible links.
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845, doi:10.1214/18-AOAS1164
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645, doi:10.1111/rssc.12171
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 70, p = 6, graph = "circle", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, iter = 10000 ) plinks( bdgraph.obj, round = 2 ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 70, p = 6, graph = "circle", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, iter = 10000 ) plinks( bdgraph.obj, round = 2 ) ## End(Not run)
S3
class "bdgraph
" Visualizes structure of the selected graphs which could be a graph with links for which their estimated posterior probabilities are greater than 0.5 or graph with the highest posterior probability.
## S3 method for class 'bdgraph' plot( x, cut = 0.5, number.g = NULL, main = NULL, layout = igraph::layout_with_fr, vertex.size = 2, vertex.color = "orange", vertex.frame.color = "orange", vertex.label = NULL, vertex.label.dist = 0.5, vertex.label.color = "blue", edge.color = "lightblue", ... )
## S3 method for class 'bdgraph' plot( x, cut = 0.5, number.g = NULL, main = NULL, layout = igraph::layout_with_fr, vertex.size = 2, vertex.color = "orange", vertex.frame.color = "orange", vertex.label = NULL, vertex.label.dist = 0.5, vertex.label.color = "blue", edge.color = "lightblue", ... )
x |
object of |
cut |
threshold for including the links in the selected graph based on the estimated posterior probabilities of the links; See the examples. |
number.g |
number of graphs with the highest probabilities. This option works for the case running function |
main |
Graphical parameter (see plot). |
layout |
vertex placement which is according to |
vertex.size |
vertex size which is according to |
vertex.color |
vertex color which is according to |
vertex.frame.color |
vertex frame color which is according to |
vertex.label |
vertex label. The default vertex labels are the vertex ids. |
vertex.label.dist |
vertex label distance which is according to |
vertex.label.color |
vertex label color which is according to |
edge.color |
edge color which is according to |
... |
additional plotting parameters. For the complete list, see |
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
## Not run: set.seed( 100 ) # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 100, p = 15, graph = "random", prob = 0.2, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) plot( bdgraph.obj ) bdgraph.obj <- bdgraph( data = data.sim, save = TRUE ) plot( bdgraph.obj, cut = 0.5 ) plot( bdgraph.obj, number.g = 4 ) ## End(Not run)
## Not run: set.seed( 100 ) # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 100, p = 15, graph = "random", prob = 0.2, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) plot( bdgraph.obj ) bdgraph.obj <- bdgraph( data = data.sim, save = TRUE ) plot( bdgraph.obj, cut = 0.5 ) plot( bdgraph.obj, number.g = 4 ) ## End(Not run)
S3
class "graph"
Visualizes structure of the graph.
## S3 method for class 'graph' plot( x, cut = 0.5, mode = "undirected", diag = FALSE, main = NULL, layout = igraph::layout_with_fr, vertex.size = 2, vertex.color = "orange", vertex.frame.color = "orange", vertex.label = NULL, vertex.label.dist = 0.5, vertex.label.color = "blue", edge.color = "lightblue", ... )
## S3 method for class 'graph' plot( x, cut = 0.5, mode = "undirected", diag = FALSE, main = NULL, layout = igraph::layout_with_fr, vertex.size = 2, vertex.color = "orange", vertex.frame.color = "orange", vertex.label = NULL, vertex.label.dist = 0.5, vertex.label.color = "blue", edge.color = "lightblue", ... )
x |
object of |
cut |
for the case where input ' |
mode |
type of graph which is according to |
diag |
logical which is according to |
main |
graphical parameter (see plot). |
layout |
vertex placement which is according to |
vertex.size |
vertex size which is according to |
vertex.color |
vertex color which is according to |
vertex.frame.color |
vertex frame color which is according to |
vertex.label |
vertex label. The default vertex labels are the vertex ids. |
vertex.label.dist |
vertex label distance which is according to |
vertex.label.color |
vertex label color which is according to |
edge.color |
edge color which is according to |
... |
additional plotting parameters. For the complete list, see |
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
graph.sim
, bdgraph.sim
, plot.igraph
# Generating a 'scale-free' graph adj <- graph.sim( p = 20, graph = "scale-free" ) plot( adj )
# Generating a 'scale-free' graph adj <- graph.sim( p = 20, graph = "scale-free" ) plot( adj )
S3
class "sim
" Visualizes structure of the simulated graph for an object of S3
class "sim
", from function bdgraph.sim
.
## S3 method for class 'sim' plot( x, ... )
## S3 method for class 'sim' plot( x, ... )
x |
object of |
... |
additional plotting parameters. See |
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
graph.sim
, bdgraph.sim
, plot.graph
, plot.igraph
set.seed( 10 ) # Generating synthetic multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 10, p = 15 ) plot( data.sim )
set.seed( 10 ) # Generating synthetic multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 10, p = 15 ) plot( data.sim )
Visualizes the cumulative occupancy fractions of all possible links in the graph. It can be used for monitoring the convergence of the sampling algorithms, BDMCMC and RJMCMC.
plotcoda( bdgraph.obj, thin = NULL, control = TRUE, main = NULL, verbose = TRUE, ... )
plotcoda( bdgraph.obj, thin = NULL, control = TRUE, main = NULL, verbose = TRUE, ... )
bdgraph.obj |
object of |
thin |
option for getting fast result for a cumulative plot according to part of the iteration. |
control |
logical: if TRUE (default) and the number of nodes is greater than 15, then 100 links randomly is selected for visualization. |
main |
graphical parameter (see plot). |
verbose |
logical: if TRUE (default), report/print the calculation progress. |
... |
system reserved (no specific usage). |
Note that a spending time for this function depends on the number of nodes.
For fast result, you can choose bigger value for the 'thin'
option.
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
bdgraph
, bdgraph.mpl
, traceplot
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 50, p = 6, graph = "circle", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, iter = 10000, burnin = 0 , save = TRUE ) plotcoda( bdgraph.obj ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 50, p = 6, graph = "circle", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, iter = 10000, burnin = 0 , save = TRUE ) plotcoda( bdgraph.obj ) ## End(Not run)
Draws the receiver operating characteristic (ROC) curve according to the true graph structure for object of S3
class "bdgraph
", from function bdgraph
.
plotroc( pred, actual, cut = 200, smooth = FALSE, calibrate = TRUE, linetype = NULL, color = NULL, size = 1, main = "ROC Curve", xlab = "False Postive Rate", ylab = "True Postive Rate", legend = TRUE, legend.size = 17, legend.position = c( 0.7, 0.3 ), labels = NULL, auc = TRUE, theme = ggplot2::theme_minimal() )
plotroc( pred, actual, cut = 200, smooth = FALSE, calibrate = TRUE, linetype = NULL, color = NULL, size = 1, main = "ROC Curve", xlab = "False Postive Rate", ylab = "True Postive Rate", legend = TRUE, legend.size = 17, legend.position = c( 0.7, 0.3 ), labels = NULL, auc = TRUE, theme = ggplot2::theme_minimal() )
pred |
upper triangular matrix corresponding to the estimated posterior probabilities for all possible links.
It can be an object with |
actual |
adjacency matrix corresponding to the true graph structure in which |
cut |
number of cut points. |
smooth |
logical: for smoothing the ROC curve. |
calibrate |
If |
linetype |
specification for the default plotting line type. |
color |
specification for the default plotting color. |
size |
specification for the default plotting line size. |
main |
overall title for the plot. |
xlab |
title for the x axis. |
ylab |
title for the y axis. |
legend |
logical: for adding legend to the ROC plot. |
legend.size |
title for the x axis. |
legend.position |
title for the y axis. |
labels |
for legends of the legend to the ROC plot. |
auc |
logical: to report AUC with legend. |
theme |
theme for the plot from the function |
Reza Mohammadi [email protected]; Lucas Vogels [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
roc
, pROC::plot.roc()
, pROC::auc()
, bdgraph
, bdgraph.mpl
, compare
## Not run: # To generate multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 30, p = 6, size = 7, vis = TRUE ) # To Run sampling algorithm bdgraph.obj <- bdgraph( data = data.sim, iter = 10000 ) # To compare the results plotroc( bdgraph.ob2j, data.sim ) # To compare the results based on CGGMs approach bdgraph.obj2 <- bdgraph( data = data.sim, method = "gcgm", iter = 10000 ) # To Compare the resultss plotroc( list( bdgraph.obj, bdgraph.obj2 ), data.sim, legend = FALSE ) ## End(Not run)
## Not run: # To generate multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 30, p = 6, size = 7, vis = TRUE ) # To Run sampling algorithm bdgraph.obj <- bdgraph( data = data.sim, iter = 10000 ) # To compare the results plotroc( bdgraph.ob2j, data.sim ) # To compare the results based on CGGMs approach bdgraph.obj2 <- bdgraph( data = data.sim, method = "gcgm", iter = 10000 ) # To Compare the resultss plotroc( list( bdgraph.obj, bdgraph.obj2 ), data.sim, legend = FALSE ) ## End(Not run)
Provides samples from the posterior predictive distribution.
posterior.predict( object, iter = 1, ... )
posterior.predict( object, iter = 1, ... )
object |
object of |
iter |
number of predictions. |
... |
additional parameters. |
a matrix
containing the predicted datasets, corresponding to the samples from the joint posterior disribtuion.
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845, doi:10.1214/18-AOAS1164
Vogels, L., Mohammadi, R., Schoonhoven, M., and Birbil, S.I. (2023) Bayesian Structure Learning in Undirected Gaussian Graphical Models: Literature Review with Empirical Comparison, arXiv preprint, doi:10.48550/arXiv.2307.02603
Mohammadi, R., Schoonhoven, M., Vogels, L., and Birbil, S.I. (2023) Large-scale Bayesian Structure Learning for Gaussian Graphical Models using Marginal Pseudo-likelihood, arXiv preprint, doi:10.48550/arXiv.2307.00127
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645, doi:10.1111/rssc.12171
bdgraph
, bdgraph.mpl
, bdgraph.dw
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) posterior.predict( bdgraph.obj, iter = 20 ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) posterior.predict( bdgraph.obj, iter = 20 ) ## End(Not run)
Provides the estimated precision matrix.
precision( bdgraph.obj, round = 2 )
precision( bdgraph.obj, round = 2 )
bdgraph.obj |
object of |
round |
value for rounding all probabilities to the specified number of decimal places. |
matrix which corresponds the estimated precision matrix.
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 70, p = 6, graph = "circle", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) precision( bdgraph.obj ) # Estimated precision matrix data.sim $ K # True precision matrix ## End(Not run)
## Not run: # Generating multivariate normal data from a 'circle' graph data.sim <- bdgraph.sim( n = 70, p = 6, graph = "circle", vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) precision( bdgraph.obj ) # Estimated precision matrix data.sim $ K # True precision matrix ## End(Not run)
S3
class "bdgraph
" Provides predict values of the results for function bdgraph
.
## S3 method for class 'bdgraph' predict( object, iter = 1, ... )
## S3 method for class 'bdgraph' predict( object, iter = 1, ... )
object |
object of |
iter |
number of predictions. |
... |
additional parameters. |
a matrix
containing the predicted datasets, corresponding to the samples from the joint posterior disribtuion.
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845, doi:10.1214/18-AOAS1164
Vogels, L., Mohammadi, R., Schoonhoven, M., and Birbil, S.I. (2023) Bayesian Structure Learning in Undirected Gaussian Graphical Models: Literature Review with Empirical Comparison, arXiv preprint, doi:10.48550/arXiv.2307.02603
Mohammadi, R., Schoonhoven, M., Vogels, L., and Birbil, S.I. (2023) Large-scale Bayesian Structure Learning for Gaussian Graphical Models using Marginal Pseudo-likelihood, arXiv preprint, doi:10.48550/arXiv.2307.00127
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645, doi:10.1111/rssc.12171
bdgraph
, bdgraph.mpl
, bdgraph.dw
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) predict( bdgraph.obj, iter = 20 ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) predict( bdgraph.obj, iter = 20 ) ## End(Not run)
S3
class "bdgraph
" Prints the information about the selected graph which could be a graph with links for which their estimated posterior probabilities are greater than 0.5 or graph with the highest posterior probability. It provides adjacency matrix, size and posterior probability of the selected graph.
## S3 method for class 'bdgraph' print( x, ... )
## S3 method for class 'bdgraph' print( x, ... )
x |
object of |
... |
system reserved (no specific usage). |
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) print( bdgraph.obj ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) print( bdgraph.obj ) ## End(Not run)
S3
class "sim
" Prints the information about the type of data, the sample size, the graph type, the number of nodes, number of links and sparsity of the true graph.
## S3 method for class 'sim' print( x, ... )
## S3 method for class 'sim' print( x, ... )
x |
object of |
... |
system reserved (no specific usage). |
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
# Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 20, p = 10, vis = TRUE ) print( data.sim )
# Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 20, p = 10, vis = TRUE ) print( data.sim )
The dataset consist of discrete variables as the potential risk factors of coronary heart disease.
The data collected from
men employed of a car factory in Czechoslovakia (Reinis et al. 1981).
data( reinis )
data( reinis )
The format is a matrix with rows (number of individuals) and
column (number of variables).
Edwards and Havranek (1985). A fast procedure for model search in multidimensional contingency tables, Biometrika, 72:339-351
Reinis et al (1981). Prognostic significance of the risk profile in the prevention of coronary heart disease, Bratis. lek. Listy, 76:137-150
Mohammadi, A. and Dobra, A. (2017). The R
Package BDgraph for Bayesian Structure Learning in Graphical Models, ISBA Bulletin, 24(4):11-16
data( reinis ) summary( reinis )
data( reinis ) summary( reinis )
Generates random matrices, distributed according to the G-Wishart distribution with parameters and
,
with respect to the graph structure
.
Note this fuction works for both non-decomposable and decomposable graphs.
rgwish( n = 1, adj = NULL, b = 3, D = NULL, threshold = 1e-8 )
rgwish( n = 1, adj = NULL, b = 3, D = NULL, threshold = 1e-8 )
n |
number of samples required. |
adj |
adjacency matrix corresponding to the graph structure which can be non-decomposable or decomposable. It should be an upper triangular matrix in which |
b |
degree of freedom for G-Wishart distribution, |
D |
positive definite |
threshold |
threshold value for the convergence of sampling algorithm from G-Wishart. |
Sampling from G-Wishart distribution, , with density:
which is the degree of freedom and
is a symmetric positive definite matrix.
A numeric array, say , of dimension
, where each
is a positive
definite matrix, a realization of the G-Wishart distribution,
.
Note, for the case
, the output is a matrix.
Reza Mohammadi [email protected]
Lenkoski, A. (2013). A direct sampler for G-Wishart variates, Stat, 2:119-128, doi:10.1002/sta4.23
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
# Generating a 'circle' graph as a non-decomposable graph adj <- graph.sim( p = 5, graph = "circle" ) adj # adjacency of graph with 5 nodes sample <- rgwish( n = 1, adj = adj, b = 3, D = diag( 5 ) ) round( sample, 2 ) sample <- rgwish( n = 5, adj = adj ) round( sample, 2 )
# Generating a 'circle' graph as a non-decomposable graph adj <- graph.sim( p = 5, graph = "circle" ) adj # adjacency of graph with 5 nodes sample <- rgwish( n = 1, adj = adj, b = 3, D = diag( 5 ) ) round( sample, 2 ) sample <- rgwish( n = 5, adj = adj ) round( sample, 2 )
Random generation function from the multivariate Normal distribution with mean equal to and covariance matrix
.
rmvnorm( n = 10, mean = rep( 0, length = ncol( sigma ) ), sigma = diag( length( mean ) ) )
rmvnorm( n = 10, mean = rep( 0, length = ncol( sigma ) ), sigma = diag( length( mean ) ) )
n |
Number of observations. |
mean |
Mean vector, default is |
sigma |
positive definite covariance matrix, default is |
A numeric matrix with rows equal to and columns equal to
.
Reza Mohammadi [email protected]
mean <- c( 5, 20 ) sigma <- matrix( c( 4, 2, 2, 5 ), 2, 2 ) # covariance matrix sample <- rmvnorm( n = 500, mean = mean, sigma = sigma ) plot( sample )
mean <- c( 5, 20 ) sigma <- matrix( c( 4, 2, 2, 5 ), 2, 2 ) # covariance matrix sample <- rmvnorm( n = 500, mean = mean, sigma = sigma ) plot( sample )
This function builds a ROC curve specifically for graph structure learning and returns a “roc” object, a list of class
“roc”. This object can be prin
ted, plot
ted, or
passed to the functions pROC::roc()
, pROC::ci()
, pROC::smooth.roc()
and pROC::coords()
. Additionally, two roc
objects can be compared with pROC::roc.test()
.
This function is based on the roc
function of R
package pROC
.
roc( pred, actual, auc = TRUE, smooth = FALSE, plot = FALSE, quiet = TRUE, ... )
roc( pred, actual, auc = TRUE, smooth = FALSE, plot = FALSE, quiet = TRUE, ... )
pred |
adjacency matrix (or a vector) corresponding to an estimated graph.
It can be an object with |
actual |
adjacency matrix (or a vector) corresponding to the actual graph structure in which |
smooth |
if TRUE, the ROC curve is passed to |
auc |
compute the area under the curve (AUC)? If |
plot |
plot the ROC curve? If |
quiet |
if |
... |
further arguments to be passed to |
If the data contained any NA
value and na.rm=FALSE
, NA
is
returned. Otherwise, if smooth=FALSE
, a list of class
“roc” with the following fields:
auc |
if called with |
ci |
if called with |
response |
the response vector. Patients whose response is not
|
predictor |
predictor vector converted to numeric as used to build the ROC
curve. Patients whose response is not |
original.predictor , original.response
|
response and predictor vectors as passed in argument. |
levels |
levels of the response as defined in argument. |
controls |
predictor values for the control observations. |
cases |
predictor values for the cases. |
percent |
if the sensitivities, specificities and AUC are reported in percent, as defined in argument. |
direction |
direction of the comparison, as defined in argument. |
fun.sesp |
function used to compute sensitivities and specificities. Will be re-used in bootstrap operations. |
sensitivities |
sensitivities defining the ROC curve. |
specificities |
specificities defining the ROC curve. |
thresholds |
thresholds at which the sensitivities and specificities were computed. See below for details. |
call |
how the function was called. See function |
If smooth=TRUE
a list of class “smooth.roc” as returned
by pROC::smooth()
, with or without additional elements
auc
and ci
(according to the call).
Reza Mohammadi [email protected]; Lucas Vogels [email protected]
Tom Fawcett (2006) “An introduction to ROC analysis”. Pattern Recognition Letters 27, 861–874, doi:10.1016/j.patrec.2005.10.010
Xavier Robin, Natacha Turck, Alexandre Hainard, et al. (2011) “pROC: an open-source package for R and S+ to analyze and compare ROC curves”. BMC Bioinformatics, 7, 77, doi:10.1186/1471-2105-12-77.
plotroc
, pROC::plot.roc()
, pROC::auc()
, pROC::print.roc()
, bdgraph
, bdgraph.mpl
, compare
## Not run: set.seed( 5 ) # Generating multivariate normal data from a 'scale-free' graph data.sim = bdgraph.sim( n = 200, p = 15, graph = "scale-free", vis = TRUE ) # Running BDMCMC algorithm sample.bdmcmc = bdgraph( data = data.sim, algorithm = "bdmcmc", iter = 10000 ) # ROC curve for BDMCMC algorithm roc.bdmcmc = BDgraph::roc( pred = sample.bdmcmc, actual = data.sim, plot = TRUE ) # Running RJMCMC algorithm sample.rjmcmc = bdgraph( data = data.sim, algorithm = "rjmcmc", iter = 10000 ) # ROC curve for RJMCMC algorithm roc.rjmcmc = BDgraph::roc( pred = sample.rjmcmc, actual = data.sim, plot = TRUE ) # ROC curve for both BDMCMC and RJMCMC algorithms pROC::ggroc( list( BDMCMC = roc.bdmcmc, RJMCMC = roc.rjmcmc ) ) ## End(Not run)
## Not run: set.seed( 5 ) # Generating multivariate normal data from a 'scale-free' graph data.sim = bdgraph.sim( n = 200, p = 15, graph = "scale-free", vis = TRUE ) # Running BDMCMC algorithm sample.bdmcmc = bdgraph( data = data.sim, algorithm = "bdmcmc", iter = 10000 ) # ROC curve for BDMCMC algorithm roc.bdmcmc = BDgraph::roc( pred = sample.bdmcmc, actual = data.sim, plot = TRUE ) # Running RJMCMC algorithm sample.rjmcmc = bdgraph( data = data.sim, algorithm = "rjmcmc", iter = 10000 ) # ROC curve for RJMCMC algorithm roc.rjmcmc = BDgraph::roc( pred = sample.rjmcmc, actual = data.sim, plot = TRUE ) # ROC curve for both BDMCMC and RJMCMC algorithms pROC::ggroc( list( BDMCMC = roc.bdmcmc, RJMCMC = roc.rjmcmc ) ) ## End(Not run)
Generates random matrices, distributed according to the Wishart distribution with parameters and
,
.
rwish( n = 1, p = 2, b = 3, D = diag( p ) )
rwish( n = 1, p = 2, b = 3, D = diag( p ) )
n |
number of samples required. |
p |
number of variables (nodes). |
b |
degree of freedom for Wishart distribution, |
D |
positive definite |
Sampling from Wishart distribution, , with density:
which is the degree of freedom and
is a symmetric positive definite matrix.
A numeric array, say , of dimension
, where each
is a positive
definite matrix, a realization of the Wishart distribution
.
Note, for the case
, the output is a matrix.
Reza Mohammadi [email protected]
Lenkoski, A. (2013). A direct sampler for G-Wishart variates, Stat, 2:119-128, doi:10.1002/sta4.23
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
sample <- rwish( n = 3, p = 5, b = 3, D = diag( 5 ) ) round( sample, 2 )
sample <- rwish( n = 3, p = 5, b = 3, D = diag( 5 ) ) round( sample, 2 )
Provides the selected graph which, based on input, could be a graph with links for which their estimated posterior probabilities are greater than 0.5 (default) or a graph with the highest posterior probability; see examples.
select( bdgraph.obj, cut = NULL, vis = FALSE )
select( bdgraph.obj, cut = NULL, vis = FALSE )
bdgraph.obj |
matrix in which each element response to the weight of the links.
It can be an object of |
cut |
threshold for including the links in the selected graph based on the estimated posterior probabilities of the links; see the examples. |
vis |
visualize the selected graph structure. |
An adjacency matrix corresponding to the selected graph.
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Mohammadi, R., Massam, H. and Letac, G. (2023). Accelerating Bayesian Structure Learning in Sparse Gaussian Graphical Models, Journal of the American Statistical Association, doi:10.1080/01621459.2021.1996377
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845, doi:10.1214/18-AOAS1164
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645, doi:10.1111/rssc.12171
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) select( bdgraph.obj ) bdgraph.obj <- bdgraph( data = data.sim, save = TRUE ) select( bdgraph.obj ) select( bdgraph.obj, cut = 0.5, vis = TRUE ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) select( bdgraph.obj ) bdgraph.obj <- bdgraph( data = data.sim, save = TRUE ) select( bdgraph.obj ) select( bdgraph.obj, cut = 0.5, vis = TRUE ) ## End(Not run)
Compute the sparsity of a graph/network or an object of calss "graph"
from function graph.sim
or an object of calss "sim
" from function bdgraph.sim
.
sparsity( adj )
sparsity( adj )
adj |
adjacency matrix corresponding to a graph structure in which |
value corresponding to the graph sparsity which is the proportion of the non-links (non-zero elements) in adj
.
Reza Mohammadi [email protected]
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
# Generating a 'random' graph adj <- graph.sim( p = 10, graph = "random", prob = 0.4, vis = TRUE ) sparsity( adj )
# Generating a 'random' graph adj <- graph.sim( p = 10, graph = "random", prob = 0.4, vis = TRUE ) sparsity( adj )
S3
class "bdgraph
" Provides a summary of the results for function bdgraph
.
## S3 method for class 'bdgraph' summary( object, round = 2, vis = TRUE, ... )
## S3 method for class 'bdgraph' summary( object, round = 2, vis = TRUE, ... )
object |
object of |
round |
value for rounding all probabilities to the specified number of decimal places. |
vis |
visualize the results. |
... |
additional plotting parameters for the case |
selected_g |
adjacency matrix corresponding to the selected graph which has the highest posterior probability. |
p_links |
upper triangular matrix corresponding to the posterior probabilities of all possible links. |
K_hat |
estimated precision matrix. |
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) summary( bdgraph.obj ) bdgraph.obj <- bdgraph( data = data.sim, save = TRUE ) summary( bdgraph.obj ) summary( bdgraph.obj, vis = FALSE ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim ) summary( bdgraph.obj ) bdgraph.obj <- bdgraph( data = data.sim, save = TRUE ) summary( bdgraph.obj ) summary( bdgraph.obj, vis = FALSE ) ## End(Not run)
The survey dataset concerns 1002 males in the U.S labor force, described by Hoff (2007). The seven observed variables which have been measured on various scales are as follow: the income (income), degree (degree), the number of children (children), parents income (pincome), parents degree (pdegree), number of parents children (pchildren), and age (age).
data( surveyData )
data( surveyData )
The format is a matrix with 1002 rows (number of individuals) and 7 column (number of variables).
Hoff, P. (2007). Extending the rank likelihood for semiparametric copula estimation, The Annals of Applied Statistics, 1(1), 265-283.
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
data( surveyData ) summary( surveyData )
data( surveyData ) summary( surveyData )
Trace plot for graph size for the objects of S3
class "bdgraph
", from function bdgraph
.
It is a tool for monitoring the convergence of the sampling algorithms, BDMCMC and RJMCMC.
traceplot ( bdgraph.obj, acf = FALSE, pacf = FALSE, main = NULL, ... )
traceplot ( bdgraph.obj, acf = FALSE, pacf = FALSE, main = NULL, ... )
bdgraph.obj |
object of |
acf |
visualize the autocorrelation functions for graph size. |
pacf |
visualize the partial autocorrelations for graph size. |
main |
graphical parameter (see plot). |
... |
system reserved (no specific usage). |
Reza Mohammadi [email protected] and Ernst Wit
Mohammadi, R. and Wit, E. C. (2019). BDgraph: An R
Package for Bayesian Structure Learning in Graphical Models, Journal of Statistical Software, 89(3):1-30, doi:10.18637/jss.v089.i03
Mohammadi, A. and Wit, E. C. (2015). Bayesian Structure Learning in Sparse Gaussian Graphical Models, Bayesian Analysis, 10(1):109-138, doi:10.1214/14-BA889
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845, doi:10.1214/18-AOAS1164
Mohammadi, A. et al (2017). Bayesian modelling of Dupuytren disease by using Gaussian copula graphical models, Journal of the Royal Statistical Society: Series C, 66(3):629-645, doi:10.1111/rssc.12171
Mohammadi, A. and Dobra, A. (2017). The R
Package BDgraph for Bayesian Structure Learning in Graphical Models, ISBA Bulletin, 24(4):11-16
plotcoda
, bdgraph
, bdgraph.mpl
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, iter = 10000, burnin = 0, save = TRUE ) traceplot( bdgraph.obj ) traceplot( bdgraph.obj, acf = TRUE, pacf = TRUE ) ## End(Not run)
## Not run: # Generating multivariate normal data from a 'random' graph data.sim <- bdgraph.sim( n = 50, p = 6, size = 7, vis = TRUE ) bdgraph.obj <- bdgraph( data = data.sim, iter = 10000, burnin = 0, save = TRUE ) traceplot( bdgraph.obj ) traceplot( bdgraph.obj, acf = TRUE, pacf = TRUE ) ## End(Not run)
Transfers count data, by counting the duplicated rows.
transfer( r_data )
transfer( r_data )
r_data |
( |
() matrix of transferred data, in which the last column is the frequency of duplicated rows.
Reza Mohammadi [email protected] and Adrian Dobra
Mohammadi, A. and Dobra, A. (2017). The R
Package BDgraph for Bayesian Structure Learning in Graphical Models, ISBA Bulletin, 24(4):11-16
Dobra, A. and Mohammadi, R. (2018). Loglinear Model Selection and Human Mobility, Annals of Applied Statistics, 12(2):815-845, doi:10.1214/18-AOAS1164
# Generating multivariate binary data from a 'random' graph data.sim <- bdgraph.sim( n = 12, p = 4, size = 4, type = "binary" ) r_data <- data.sim $ data r_data # Transfer the data transfer( r_data )
# Generating multivariate binary data from a 'random' graph data.sim <- bdgraph.sim( n = 12, p = 4, size = 4, type = "binary" ) r_data <- data.sim $ data r_data # Transfer the data transfer( r_data )