2

I want to see relationships in my data on a network and have used the qgraph package to do so, my data, combined.data, is used. The correlation of my data which I passed as an input has a lot of NA values. The command I used to get the network plot is

   qgraph(cor(combined.data, method="spearman"),layout="spring", groups=gr, labels=nm, 
   label.scale=FALSE, label.cex=1) 
   # I chose spearman because the data variables are on ordinal scale

gr is list of the groups, nm is a vector containing the tags/labels of the nodes. The command runs well but comes with a warning

  Warning message:
  In qgraph(cor(combined.data, method = "spearman"), layout = "spring",  :
  Non-finite weights are omitted

The network has a lot of empty edges (non-finite weights) and I want to remove the nodes with the non-finite weights. I have tried to set the minimum and maximum arguments but it still comes up with those redundant nodes. Any suggestion on how to achieve this will be appreciated.

Julius Vainora
  • 47,421
  • 9
  • 90
  • 102
Tunde Awosanya
  • 335
  • 2
  • 6
  • 16

1 Answers1

1

Probably you have missing data leading to NA in the correlation matrix? I always use cor(combined.data, method="spearman", use = "pairwise.complete.obs") which gives no NA correlations.

Alternatively, easiest is to change the input:

foo <- cor(combined.data, method="spearman")
foo[!is.finite(foo)] <- 0
qgraph(foo)
Sacha Epskamp
  • 46,463
  • 20
  • 113
  • 131
  • I have used your suggestions, the development is that the graph comes up without warning but I want to get rid of those nodes that don't have connecting edges. How can go about eliminating (there a lots of them) those redundant nodes? – Tunde Awosanya Jan 17 '14 at 22:51
  • 1
    There is no argument in qgraph to omit nodes. It is easiest to do that by changing the input. e.g., by removing all rows and columns in the correlation matrix that have only zeroes in their non-diagonal cells. – Sacha Epskamp Jan 19 '14 at 02:20