SachaEpskamp / qgraph

Developmental version of qgraph
GNU General Public License v2.0
68 stars 21 forks source link

Question on relation between qgrap output and correlation matrix, color of the edges #52

Closed lsnadeau closed 3 years ago

lsnadeau commented 3 years ago

My question is about having red edges that do not correspond to negative numbers in the network correlation matrix.

I just start learning network analysis and to start I decided to replicate the The application of a network approach to Health-Related Quality of Life (HRQoL): introducing a new method for assessing HRQoL in healthy adults and cancer patients. Because I have cohort of subjects who answered sf36 (n=737). I use the programs associate to the article: R program in https://osf.io/rwvm6/ I first replicated fig2 for the 36 items, I get a similar diagrams. I think some items may have been code in the opposite order, this is why I get some red edges where you don’t. Also, when I visually look at numbers of the correlation matrix the color and the size of the edges are coherent, ie negative correlations are in red, positive correlations are in green, bigger correlations are associated to larger edges. To get 2 groups, I split the cohort in 2, a group who answered that they often feel lonely and a group who answered sometimes or never feel lonely. When I replicate fig 3 for the 8 domains, I get different results. First I get red edges but when I look at the correlation matrix, I don’t have any negative correlation. I don’t understand why I get red edges. This is what I did I ran this program for the sf36 domains for 737 subjects I get the graph from those functions labels2 <- c("PF","RP","BP","GH","VT","SF","RE","MH","DS") Layout_Graph <- qgraph(graph_all, graph = "glasso", layout = "spring", sampleSize = nrow(data_all)) L1 <- averageLayout(Layout_Graph) graph_all <- cor_auto(data_all) Data_all has 737 row. DS=0 feel lonely often, DS=1 feel lonely sometimes or never

Graph_all <- qgraph(graph_all, graph = "glasso", layout = L1, sampleSize = nrow(data_all), esize = 20, cut = 0.1, minimum = 0, maximum = 1, color= c("yellow", "cornflowerblue", "purple", "grey", "orange", "green", "maroon1", "red", "chocolate3"), borders = FALSE, vsize= 10, labels = labels2, legend = FALSE) mtext("(c)", cex = 1.25, side = 1, line = 8.7, las = 1)

Here is the correlation matrix

dput(graph_all)

structure(c(1, 0.499931025056832, 0.553243490045503, 0.545853343556307, 0.408656958778119, 0.369330666775307, 0.289046953664939, 0.241953860982174, 0.19901569137775, 0.499931025056832, 1, 0.624401817605508, 0.54310418084152, 0.622747868221131, 0.641736656112912, 0.624778121078169, 0.470886680477519, 0.307696679449673, 0.553243490045503, 0.624401817605508, 1, 0.500283796401499, 0.4860506368617, 0.510760344253669, 0.403820838305521, 0.343061789506324, 0.180888071514773, 0.545853343556308, 0.54310418084152, 0.500283796401499, 1, 0.607091736780751, 0.491133953414105, 0.421119329051919, 0.475705823397117, 0.396924015777883, 0.408656958778119, 0.622747868221131, 0.4860506368617, 0.607091736780751, 1, 0.648335463054217, 0.557489184128694, 0.694982986114683, 0.449182711222666, 0.369330666775307, 0.641736656112912, 0.510760344253669, 0.491133953414105, 0.648335463054217, 1, 0.618408390041698, 0.642642564387107, 0.464702190917403, 0.289046953664939, 0.624778121078169, 0.403820838305521, 0.421119329051918, 0.557489184128694, 0.618408390041698, 1, 0.590310670736049, 0.406601300770822, 0.241953860982174, 0.470886680477519, 0.343061789506324, 0.475705823397117, 0.694982986114683, 0.642642564387107, 0.590310670736049, 1, 0.594106900304187, 0.19901569137775, 0.307696679449673, 0.180888071514773, 0.396924015777883, 0.449182711222666, 0.464702190917403, 0.406601300770822, 0.594106900304187, 1), .Dim = c(9L, 9L), .Dimnames = list(c("pf", "rp", "bp", "gh", "vt", "sf", "re", "mh", "DS"), c("pf", "rp", "bp", "gh", "vt", "sf", "re", "mh", "DS")))

The result of the qgraph is in the pdf document below, network (c) with the 2 groups together (lonely and sometimes or never lonely). I do not include information for network (a) and (b) but I get the same results with red edges and no negative correlation in the corresponding matrix.

Fig3domains.pdf

Thank you Lyne

SachaEpskamp commented 3 years ago

Using graph = "glasso" computes a regularized partial correlation network, whereas graph_all should then be the marginal correlation matrix on which that is based. graph_all in this case does not encode the weights matrix of the graph. It can very well be that partial correlations are negative while marginal correlations are positive.