Closed vandenman closed 11 months ago
Consider the following example:
library(BDgraph) library(easybgm) packageVersion("BDgraph") #> [1] '2.72' packageVersion("easybgm") #> [1] '0.1.1' n <- 100 p <- 7 # simulate a true graph structure set.seed(126) g_obj <- graph.sim(p) g_obj[5, 6] <- g_obj[6, 5] <- 1 g <- unclass(g_obj) # simulate a true precision matrix K <- rgwish(1, adj = g) print(zapsmall(K)) #> [,1] [,2] [,3] [,4] [,5] [,6] [,7] #> [1,] 9.549353 0.000000 0.000000 0.000000 0.321668 0.000000 1.700633 #> [2,] 0.000000 6.022439 0.000000 0.000000 2.067669 0.000000 0.000000 #> [3,] 0.000000 0.000000 4.974015 -2.421315 0.000000 0.000000 0.000000 #> [4,] 0.000000 0.000000 -2.421315 3.206202 0.706456 0.000000 0.000000 #> [5,] 0.321668 2.067669 0.000000 0.706456 6.848114 -0.501471 0.000000 #> [6,] 0.000000 0.000000 0.000000 0.000000 -0.501471 7.512933 0.000000 #> [7,] 1.700633 0.000000 0.000000 0.000000 0.000000 0.000000 4.854756 # invert it to obtain the true covariance matrix Sigma <- solve(K) # simulate the data X <- mvtnorm::rmvnorm(n = n, mean = rep(0, p), sigma = Sigma) # fit easybgm fit <- easybgm(X, type = "continuous") #> 10000 MCMC sampling ... in progress: #> 10%->20%->30%->40%->50%->60%->70%->80%->90%-> done print(fit) #> Error in matrix(rep(names, each = p), ncol = p): 'data' must be of a vector type, was 'NULL' # the object still contains useful stuff str(fit) #> List of 8 #> $ parameters : num [1:7, 1:7] 0 -0.021598 0.000403 0.040694 -0.017792 ... #> $ inc_probs : num [1:7, 1:7] 0 0.33 0.18 0.36 0.37 0.34 1 0.33 0 0.23 ... #> ..- attr(*, "dimnames")=List of 2 #> .. ..$ : NULL #> .. ..$ : NULL #> $ inc_BF : num [1:7, 1:7] 0 0.493 0.22 0.562 0.587 ... #> ..- attr(*, "dimnames")=List of 2 #> .. ..$ : NULL #> .. ..$ : NULL #> $ structure : num [1:7, 1:7] 0 0 0 0 0 0 1 0 0 0 ... #> ..- attr(*, "dimnames")=List of 2 #> .. ..$ : NULL #> .. ..$ : NULL #> $ structure_probabilities: num [1:1818] 2e-04 8e-04 6e-04 2e-04 4e-04 6e-04 2e-04 2e-04 4e-04 2e-04 ... #> $ graph_weights : num [1:1818] 1 4 3 1 2 3 1 1 2 1 ... #> $ sample_graphs : chr [1:1818] "100011011100100100010" "000011011100100100010" "000111011100100100010" "000111111100100100010" ... #> $ model : chr "ggm" #> - attr(*, "class")= chr [1:2] "package_bdgraph" "easybgm"
Created on 2023-11-22 with reprex v2.0.2
Here, print(fit) throws an error, but it should not.
print(fit)
In addition, I noticed that the samples from BDgraph are weighted. Is this accounted for in e.g., the centrality measures?
the issue was the lack of column names of the dataframe. fixed it to now impute column names
fixed with 66e5bd1
Consider the following example:
Created on 2023-11-22 with reprex v2.0.2
Here,
print(fit)
throws an error, but it should not.In addition, I noticed that the samples from BDgraph are weighted. Is this accounted for in e.g., the centrality measures?