qgraph( adj, ... )
factanal
using
promax rotation and 'nfact' factors (defaults to half of the number of variables). An undirected graph is made in which each variable is connected
to another variable if they both load higher then the value of 'cut' on the same factor.
An edgelist can also be used. This is a matrix (not a list!) with two columns and a row for each edge. The first column indicates the number
of the start of the edge and the second column indicates the number of the end of the edge. Numbering must start with 1. If any
integer is missing between 1 and the highest specified number then that is regarded as a node with no edges (if there is
supposed to be more nodes with no edges after the highest number in the edgelist the 'nNodes' argument can be used).
To create a weighted graph edge weights can be added as a third column in the edgelist.par
.
Edges with an absolute value under the 'minimum' argument are omitted (useful to keep filesizes from inflating in very large
graphs). If the 'cut' argument equals 0 (see next paragraph) An (hypothetical) edge with an absolute weight of the minimum value would be white and has width 1, Edges
with absolute weights higher than the minimum will be wider and more colorful, and the edge with the strongest absolute
weight will be full red (negative) or green (positive) and have the width specified with 'esize'. It is possible to set this strongest edge by using
the 'maximum' argument. When 'maximum' is set to a value above any absolute weight in the graph that value is considered the strongest
edge (this must be done to compare different graphs).
In larger graphs the above edge settings can become very uninterpretable, and setting a cutoff score is advised.
This can be done with the 'cut' argument. With the 'cut' argument a cutoff value can be set which splits scaling
of color and width. Edges with absolute weights under the cutoff score will have width 1 and become more colorful
as they approach the cutoff score, and edges with absolute weights over the cutoff score will be full red or green
and become wider the stronger they are.
The size of the nodes can be set with the 'vsize' argument. If this has two values then the nodes will be scaled according
to their degree (sum of the row and column of the node).qgraph.layout.fruchtermanreingold
.
By default, 'layout' is set to "spring" for unweighted and directed graphs, "circle" to weighted undirected graphs (e.g. a correlation matrix)
without 'groups' specified (see next section) and "groups" to weighted undirected graphs when "groups" is specified.rainbow
function.qgraph.svg
can be used to make a battery of svg pictures with hyperlinks
to each other, working like a navigation menu.qgraph
qgraph.efa
qgraph.pca
qgraph.loadings
qgraph.sem
qgraph.svg
#### VISUALIZE CORRELATION MATRIX ###
eta=matrix(rnorm(200*5),ncol=5)
lam=matrix(0,nrow=100,ncol=5)
for (i in 1:5) lam[(20*i-19):(20*i),i]=rnorm(20,0.7,0.3)
eps=matrix(rnorm(200*100),ncol=100)
Y=eta%*%t(lam)+eps
## run qgraph:
Q=qgraph(cor(Y),groups=list(1:20,21:40,41:60,61:80,81:100),cut=0.4,vsize=3)
## Same graph but now with spring layout:
qgraph(cor(Y),layout="spring",Q)
#### UNWEIGHTED DIRECTED GRAPHS ###
adj=matrix(sample(0:1,10^2,T,prob=c(0.8,0.2)),nrow=10,ncol=10)
qgraph(adj)
# Save plot to nonsquare pdf file:
qgraph(adj,filetype='pdf',height=5,width=10)
#### EXAMPLES FOR EDGES UNDER DIFFERENT ARGUMENTS ###
# Create edgelist:
E=t(c(1,2))
for (i in 2:11*2) E=rbind(E,(i-1):i)
E=cbind(E,seq(-0.5,0.5,length=11))
# Create layout matrix
L=matrix(1:22,nrow=2)
# Run qgraph with default settings:
Q=qgraph(E,layout=L,labels=FALSE,width=7,height=4,edge.labels=T)
# Default settings with different minimum and maximum:
qgraph(E,Q,maximum=1,minimum=0.1)
# Default settings with cutoff score:
qgraph(E,Q,cut=0.3)
Run the code above in your browser using DataLab