the qgraph package for network visualizations of ... · qgraph i a r package (cran link) i can be...

90
The qgraph package for network visualizations of psychometric data in R Sacha Epskamp University of Amsterdam Department of Psychological Methods AmstRdam

Upload: others

Post on 28-May-2020

16 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The qgraph package for network visualizations ofpsychometric data in R

Sacha Epskamp

University of AmsterdamDepartment of Psychological Methods

AmstRdam

Page 2: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Outline

IntroductionWhat is qgraph?Graphs

Creating graphsInput modesLayout modes

Visualizing statisticsCorrelation matricesFactor loadingsConfirmatory Factor Analysis

Concluding commentsReferences

Page 3: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:

I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraph

I Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 4: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:

I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraph

I Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 5: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphs

I Different from other R packages (e.g. igraph Csardi &Nepusz, 2006) in:

I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraph

I Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 6: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:

I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraph

I Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 7: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:I Focus on Weighted Graphs

I Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraph

I Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 8: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:I Focus on Weighted GraphsI Intended for visualization of data as graphs

I Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraph

I Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 9: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraph

I Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 10: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraph

I Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 11: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraphI Simple input

I Summarize a large amount of statistics without needing datareduction methods.

I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 12: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraphI Simple inputI Summarize a large amount of statistics without needing data

reduction methods.

I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 13: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraphI Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 14: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

qgraph

I A R package (CRAN link)

I Can be used to plot various types of graphsI Different from other R packages (e.g. igraph Csardi &

Nepusz, 2006) in:I Focus on Weighted GraphsI Intended for visualization of data as graphsI Optimized for vector-type image files (e.g. PDF, SVG)

I Aims in qgraphI Simple inputI Summarize a large amount of statistics without needing data

reduction methods.I Visualize relations between variables

I Main idea: Show variables as nodes, relationships as edges

Page 15: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Graphs

I A graph is a network that consists of n nodes (or vertices)that are connected with m edges.

I Each edge has a weight indicating the strength of thatconnection

I An edge can be directed (have an arrow) or undirected

Page 16: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Graphs

I A graph is a network that consists of n nodes (or vertices)that are connected with m edges.

I Each edge has a weight indicating the strength of thatconnection

I An edge can be directed (have an arrow) or undirected

Page 17: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Graphs

I A graph is a network that consists of n nodes (or vertices)that are connected with m edges.

I Each edge has a weight indicating the strength of thatconnection

I An edge can be directed (have an arrow) or undirected

Page 18: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Graphs

I A graph is a network that consists of n nodes (or vertices)that are connected with m edges.

I Each edge has a weight indicating the strength of thatconnection

I An edge can be directed (have an arrow) or undirected

Page 19: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Unweighted graph

1

2

3

4

5

6

7

8

9

10

Page 20: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Weighted graph

1

2

3

4

5

6

7

8

9

10

Page 21: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Weighted graph

1

2

3

4

5

6

7

8

9

10

Page 22: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Directed graph

1

2

3

4

5

6

7

8

9

10

Page 23: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Outline

IntroductionWhat is qgraph?Graphs

Creating graphsInput modesLayout modes

Visualizing statisticsCorrelation matricesFactor loadingsConfirmatory Factor Analysis

Concluding commentsReferences

Page 24: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The qgraph() function

I The main function in qgraph is qgraph()

I Most other functions are either wrapping functions usingqgraph() or functions used in qgraph()

I The qgraph() function requires only one argument (adj)

I A lot of other arguments can be specified, but these are alloptional

Usage:

qgraph( adj, ... )

Page 25: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The qgraph() function

I The main function in qgraph is qgraph()I Most other functions are either wrapping functions using

qgraph() or functions used in qgraph()

I The qgraph() function requires only one argument (adj)

I A lot of other arguments can be specified, but these are alloptional

Usage:

qgraph( adj, ... )

Page 26: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The qgraph() function

I The main function in qgraph is qgraph()I Most other functions are either wrapping functions using

qgraph() or functions used in qgraph()

I The qgraph() function requires only one argument (adj)

I A lot of other arguments can be specified, but these are alloptional

Usage:

qgraph( adj, ... )

Page 27: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The qgraph() function

I The main function in qgraph is qgraph()I Most other functions are either wrapping functions using

qgraph() or functions used in qgraph()

I The qgraph() function requires only one argument (adj)

I A lot of other arguments can be specified, but these are alloptional

Usage:

qgraph( adj, ... )

Page 28: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:

I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:

I A 1 indicating a connection (unweighted graphs)I CorrelationsI Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 29: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:

I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:

I A 1 indicating a connection (unweighted graphs)I CorrelationsI Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 30: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:

I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:

I A 1 indicating a connection (unweighted graphs)I CorrelationsI Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 31: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:I A 0 indicates no relationship

I Absolute negative values are similar in strength to positivevalues

I Examples:

I A 1 indicating a connection (unweighted graphs)I CorrelationsI Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 32: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:

I A 1 indicating a connection (unweighted graphs)I CorrelationsI Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 33: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:

I A 1 indicating a connection (unweighted graphs)I CorrelationsI Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 34: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:I A 1 indicating a connection (unweighted graphs)

I CorrelationsI Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 35: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:I A 1 indicating a connection (unweighted graphs)I Correlations

I Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 36: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:I A 1 indicating a connection (unweighted graphs)I CorrelationsI Regression parameters

I Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 37: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:I A 1 indicating a connection (unweighted graphs)I CorrelationsI Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 38: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The adjacency matrix

I The adj argument is the input. This can be an adjacencymatrix

I An adjacency matrix is a square n by n matrix in which eachelement indicates the relationship between two variables

I Any relationship can be used as long as:I A 0 indicates no relationshipI Absolute negative values are similar in strength to positive

values

I Examples:I A 1 indicating a connection (unweighted graphs)I CorrelationsI Regression parametersI Factor loadings

I Adjacency matrices occur naturally in statistics!

Page 39: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

[,1] [,2] [,3]

[1,] 0 1 1

[2,] 0 0 1

[3,] 0 0 0

1

23

Page 40: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The Big 5

Included is a dataset in which the Dutch translation of a commonlyused personality test, the NEO-PI-R (Costa & McCrae, 1992;Hoekstra, Fruyt, & Ormel, 2003), was administered to 500 firstyear psychology students (Dolan, Oort, Stoel, & Wicherts, 2009).The NEO-PI-R consists of 240 items designed to measure the fivecentral personality factors:

I Neuroticism

I Extroversion

I Agreeableness

I Openess to Experience

I Conscientiousness

Page 41: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

N1 N6 N11 N16 N21 N26 N31 N36 N41 N46N51

N56N61

N66N71

N76N81

N86N91

N96N101

N106N111

N116

N121

N126

N131

N136

N141

N146

N151

N156

N161

N166

N171

N176

N181

N186

N191

N196

N201

N206

N211

N216

N221

N226

N231

N236

E2

E7

E12

E17

E22

E27

E32

E37

E42

E47

E52

E57

E62

E67

E72

E77

E82

E87

E92

E97

E102

E107

E112

E117

E122

E127

E132

E137

E142

E147

E152

E157

E162

E167

E172

E177

E182

E187

E192

E197

E202

E207

E212

E217

E222

E227

E232

E237

O3O8

O13O18

O23O28

O33O38

O43O48

O53O58

O63O68

O73O78O83O88O93O98O103O108O113O118O123O128O133O138O143O148O153O158O163O168

O173O178

O183O188

O193O198

O203O208

O213O218

O223O228

O233O238

A4A9

A14

A19

A24

A29

A34

A39

A44

A49

A54

A59

A64

A69

A74

A79

A84

A89

A94

A99

A104

A109

A114

A119

A124

A129

A134

A139

A144

A149

A154

A159

A164

A169

A174

A179

A184

A189

A194

A199

A204

A209

A214

A219

A224

A229

A234

A239

C5

C10

C15

C20

C25

C30

C35

C40

C45

C50

C55

C60

C65

C70

C75

C80

C85

C90

C95

C100

C105

C110

C115

C120

C125C130

C135C140

C145C150

C155C160

C165C170

C175C180

C185C190

C195C200C205C210C215C220C225C230C235C240

N

E

O

A

C

Page 42: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The Big 5

> data(big5)

> str(big5)

num [1:500, 1:240] 2 3 4 4 5 2 2 1 4 2 ...

- attr(*, "dimnames")=List of 2

..$ : NULL

..$ : chr [1:240] "N1" "E2" "O3" "A4" ...

Page 43: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

The Big 5

> cor(big5)[1:15, 1:3]

N1 E2 O3

N1 1.000000e+00 -0.1855271104 0.095361021

E2 -1.855271e-01 1.0000000000 0.082879486

O3 9.536102e-02 0.0828794862 1.000000000

A4 -1.388302e-01 0.2639947325 -0.077486908

C5 -6.958419e-02 0.0433073349 -0.019451268

N6 1.901235e-01 -0.1144449337 0.052585940

E7 -8.556772e-02 0.1968042360 -0.001360255

O8 3.599480e-02 0.0380351107 0.143715099

A9 3.775956e-02 0.0918642940 -0.147722360

C10 7.113742e-02 -0.1250087306 0.005001674

N11 3.491657e-01 -0.1085540815 0.072827947

E12 -2.680803e-01 0.0456805867 -0.003996781

O13 9.768583e-02 -0.0002757219 0.218802592

A14 4.512596e-05 0.1133985066 0.009208309

C15 5.859827e-03 0.0988472658 -0.051836728

Page 44: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

> qgraph(cor(big5), minimum = 0.2)

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●

●●●●●●

●●●●

●●●●

●●●●

●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●

●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●

●●●●●●

●●●●●

●●●●

●●●●

●●●●

●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●

●●●●●●●

●●●●●●●●●●●●1 2 3 4 5 6 7 8 910111213141516171819202122232425262728

2930

3132

3334

353637383940414243444546474849505152535455565758596061626364656667686970717273

7475

7677

7879

8081

8283

8485

8687

8889

9091

9293

949596979899100

101102

103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138

139140

141142

143144

145146

147148

149150

151152

153154

155156

157158

159160

161162

163164

165166

167168

169170

171172

173174175176177178179180181182183184185186187188189190191192193194195196197

198199

200201

202203

204205

206207

208209

210211

212213

214215

216217

218219

220221

222223

224225226227228229230231232233234235236237238239240

Page 45: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

> data(big5groups)

> qgraph(cor(big5), groups = big5groups, minimum = 0.2)

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

1

2

34

5

6

7

89

10

11

12

1314

15

16

17

1819

20

21

22

2324

25

26

27

2829

30

31

32

3334

35

36

37

3839

40

41

42

4344

45

46

47

4849

50

51

52

5354

55

56

57

5859

60

61

62

6364

65

66

67

6869

70

71

72

7374

75

76

77

7879

80

81

82

8384

85

86

87

8889

90

91

92

9394

95

96

97

9899

100

101

102

103104

105

106

107

108109

110

111

112

113114

115

116

117

118119

120

121

122

123124

125

126

127

128129

130

131

132

133134

135

136

137

138139

140

141

142

143144

145

146

147

148149

150

151

152

153154

155

156

157

158159

160

161

162

163164

165

166

167

168169

170

171

172

173174

175

176

177

178179

180

181

182

183184

185

186

187

188189

190

191

192

193194

195

196

197

198199

200

201

202

203204

205

206

207

208209

210

211

212

213214

215

216

217

218219

220

221

222

223224

225

226

227

228229

230

231

232

233234

235

236

237

238239

240

NeuroticismExtraversionOpennessAgreeablenessConscientiousness

NeuroticismExtraversionOpennessAgreeablenessConscientiousness

Page 46: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Fruchterman-Reingold layout (20 iterations)

Page 47: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

> data(big5groups)

> Q <- qgraph(cor(big5), groups = big5groups,

+ minimum = 0.2, layout = "spring")

●●

●●

● ●

●●

●●

●●

●●

●●

● ●●

● ●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

● ●

● ●

● ●

● ●

●●

●●

● ●

●●

●●

●●

●●

●●

● ●●

● ●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

● ●

●●

●●

●●

●●

● ●

● ●

● ●

● ●

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26 27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

7677

78

79

80

8182

83

84

85

86

87

88

89

90

91 92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116 117

118

119

120

121

122

123

124

125

126

127

128

129130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216217

218

219

220

221222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239240

NeuroticismExtraversionOpennessAgreeablenessConscientiousness

NeuroticismExtraversionOpennessAgreeablenessConscientiousness

Page 48: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

> Q <- qgraph(Q, legend = FALSE)

●●

● ●

●●

●●

●●

●●

●●

● ●●

● ●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

● ●

● ●

●●

● ●

●●

●●

●●

●●

●●

● ●●

● ●

●●

●●

●●

● ●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

● ●

● ●

● ●

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26 27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

7677

78

79

80

8182

83

84

85

86

87

88

89

90

91 92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116 117

118

119

120

121

122

123

124

125

126

127

128

129130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216217

218

219

220

221222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239240

Page 49: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

> Q <- qgraph(Q, vsize = 2, borders = FALSE,

+ vTrans = 150)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26 27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

7677

78

79

80

8182

83

84

85

86

87

88

89

90

91 92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116 117

118

119

120

121

122

123

124

125

126

127

128

129130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216217

218

219

220

221222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239240

Page 50: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

> Q <- qgraph(Q, overlay = TRUE)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26 27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

7677

78

79

80

8182

83

84

85

86

87

88

89

90

91 92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116 117

118

119

120

121

122

123

124

125

126

127

128

129130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216217

218

219

220

221222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239240

Page 51: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

> qgraph(Q, transparency = T, bg = T, bgcontrol = 5,

+ filetype = "png", filename = "bg", res = 144,

+ width = 7, height = 7)

Page 52: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph
Page 53: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Outline

IntroductionWhat is qgraph?Graphs

Creating graphsInput modesLayout modes

Visualizing statisticsCorrelation matricesFactor loadingsConfirmatory Factor Analysis

Concluding commentsReferences

Page 54: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Association

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26 27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

7677

78

79

80

8182

83

84

85

86

87

88

89

90

91 92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116 117

118

119

120

121

122

123

124

125

126

127

128

129130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216217

218

219

220

221222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239240

NeuroticismExtraversionOpennessAgreeablenessConscientiousness

NeuroticismExtraversionOpennessAgreeablenessConscientiousness

Page 55: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Significance

> qgraph(cor(big5), Q, graph = "sig")

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26 27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

7677

78

79

80

8182

83

84

85

86

87

88

89

90

91 92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116 117

118

119

120

121

122

123

124

125

126

127

128

129130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216217

218

219

220

221222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239240

NeuroticismExtraversionOpennessAgreeablenessConscientiousness

NeuroticismExtraversionOpennessAgreeablenessConscientiousness

p < 0.05p < 0.01p < 0.001p < 1e−04

Page 56: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Factor loadings

I A factor loadings matrix can be visualized usingqgraph.loadings()

I There are two wrapper functions that perform an analysis andsend the results to qgraph.loadings():

I qgraph.efa() performs an exploratory factor analysis (EFA)using stats:::factanal

I qgraph.pca() performs a principal component analysis (PCA)using psych:::principal (Revelle, 2010)

I These functions use a correlation or covariance matrix as input

Page 57: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Factor loadings

I A factor loadings matrix can be visualized usingqgraph.loadings()

I There are two wrapper functions that perform an analysis andsend the results to qgraph.loadings():

I qgraph.efa() performs an exploratory factor analysis (EFA)using stats:::factanal

I qgraph.pca() performs a principal component analysis (PCA)using psych:::principal (Revelle, 2010)

I These functions use a correlation or covariance matrix as input

Page 58: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Factor loadings

I A factor loadings matrix can be visualized usingqgraph.loadings()

I There are two wrapper functions that perform an analysis andsend the results to qgraph.loadings():

I qgraph.efa() performs an exploratory factor analysis (EFA)using stats:::factanal

I qgraph.pca() performs a principal component analysis (PCA)using psych:::principal (Revelle, 2010)

I These functions use a correlation or covariance matrix as input

Page 59: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Factor loadings

I A factor loadings matrix can be visualized usingqgraph.loadings()

I There are two wrapper functions that perform an analysis andsend the results to qgraph.loadings():

I qgraph.efa() performs an exploratory factor analysis (EFA)using stats:::factanal

I qgraph.pca() performs a principal component analysis (PCA)using psych:::principal (Revelle, 2010)

I These functions use a correlation or covariance matrix as input

Page 60: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Factor loadings

I A factor loadings matrix can be visualized usingqgraph.loadings()

I There are two wrapper functions that perform an analysis andsend the results to qgraph.loadings():

I qgraph.efa() performs an exploratory factor analysis (EFA)using stats:::factanal

I qgraph.pca() performs a principal component analysis (PCA)using psych:::principal (Revelle, 2010)

I These functions use a correlation or covariance matrix as input

Page 61: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Factor loadings: EFA

> qgraph.efa(big5, 5, groups = big5groups,

+ rotation = "promax", minimum = 0.2, cut = 0.4,

+ vsize = c(1, 15), borders = FALSE, asize = 0.07,

+ esize = 4, vTrans = 200)

1

23

4 5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

Neuroticism

Extraversion

Conscientiousness

Agreeableness

Openness

Page 62: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Factor loadings: EFA crossloadings

> qgraph.efa(big5, 5, groups = big5groups,

+ rotation = "promax", minimum = 0.2, cut = 0.4,

+ vsize = c(1, 15), borders = FALSE, asize = 0.07,

+ esize = 4, vTrans = 200, crossloadings = TRUE)

1

23

4 5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

Neuroticism

Extraversion

Conscientiousness

Agreeableness

Openness

Page 63: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Factor loadings: PCA

> qgraph.pca(cor(big5), 5, groups = big5groups,

+ rotation = "promax", minimum = 0.2, cut = 0.4,

+ vsize = c(1, 15), borders = FALSE, asize = 0.07,

+ esize = 4, vTrans = 200)

1

23

4 5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

Neuroticism

Extraversion

Conscientiousness

Agreeableness

Openness

Page 64: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Confirmatory Factor Analysis

I qgraph.cfa() can be used to fit a simple confirmatory factormodel

I Each variable loads on only one factorI Factors are correlatedI Scaling by fixing first loading of each factor to 1

I This can be done with the sem (Fox, 2006) or lavaan(Rosseel, 2011) packages

I Returns a "sem" or lavaan object

I Results can be send to qgraph.sem() or qgraph.lavaan()for a full report

Page 65: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Confirmatory Factor Analysis

I qgraph.cfa() can be used to fit a simple confirmatory factormodel

I Each variable loads on only one factor

I Factors are correlatedI Scaling by fixing first loading of each factor to 1

I This can be done with the sem (Fox, 2006) or lavaan(Rosseel, 2011) packages

I Returns a "sem" or lavaan object

I Results can be send to qgraph.sem() or qgraph.lavaan()for a full report

Page 66: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Confirmatory Factor Analysis

I qgraph.cfa() can be used to fit a simple confirmatory factormodel

I Each variable loads on only one factorI Factors are correlated

I Scaling by fixing first loading of each factor to 1

I This can be done with the sem (Fox, 2006) or lavaan(Rosseel, 2011) packages

I Returns a "sem" or lavaan object

I Results can be send to qgraph.sem() or qgraph.lavaan()for a full report

Page 67: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Confirmatory Factor Analysis

I qgraph.cfa() can be used to fit a simple confirmatory factormodel

I Each variable loads on only one factorI Factors are correlatedI Scaling by fixing first loading of each factor to 1

I This can be done with the sem (Fox, 2006) or lavaan(Rosseel, 2011) packages

I Returns a "sem" or lavaan object

I Results can be send to qgraph.sem() or qgraph.lavaan()for a full report

Page 68: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Confirmatory Factor Analysis

I qgraph.cfa() can be used to fit a simple confirmatory factormodel

I Each variable loads on only one factorI Factors are correlatedI Scaling by fixing first loading of each factor to 1

I This can be done with the sem (Fox, 2006) or lavaan(Rosseel, 2011) packages

I Returns a "sem" or lavaan object

I Results can be send to qgraph.sem() or qgraph.lavaan()for a full report

Page 69: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Confirmatory Factor Analysis

I qgraph.cfa() can be used to fit a simple confirmatory factormodel

I Each variable loads on only one factorI Factors are correlatedI Scaling by fixing first loading of each factor to 1

I This can be done with the sem (Fox, 2006) or lavaan(Rosseel, 2011) packages

I Returns a "sem" or lavaan object

I Results can be send to qgraph.sem() or qgraph.lavaan()for a full report

Page 70: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Confirmatory Factor Analysis

I qgraph.cfa() can be used to fit a simple confirmatory factormodel

I Each variable loads on only one factorI Factors are correlatedI Scaling by fixing first loading of each factor to 1

I This can be done with the sem (Fox, 2006) or lavaan(Rosseel, 2011) packages

I Returns a "sem" or lavaan object

I Results can be send to qgraph.sem() or qgraph.lavaan()for a full report

Page 71: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Confirmatory Factor Analysis

> names(big5groups) <- strtrim(names(big5groups),

+ 1)

> names(big5) <- 1:ncol(big5)

> fit <- qgraph.cfa(cov(big5), nrow(big5),

+ big5groups, pkg = "lavaan", opts = list(se = "none"),

+ vsize.man = 1, vsize.lat = 6, edge.label.cex = 0.5)

> print(fit)

Lavaan (0.4-8) converged normally after 161 iterations

Number of observations 500

Estimator ML

Minimum Function Chi-square 60838.192

Degrees of freedom 28430

P-value 0.000

Page 72: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Confirmatory Factor Analysis> pdf("big5cfaModel%03d.pdf", width = 7, height = 7,

+ onefile = FALSE)

> qgraph.lavaan(fit, filetype = "", include = 1:7,

+ vsize.man = 1, vsize.lat = 6, edge.label.cex = 0.5,

+ residSize = 0.1, groups = big5groups,

+ titles = FALSE)

> dev.off()

pdf

2

> pdf("big5cfaRes%03d.pdf", width = 14, height = 7,

+ onefile = FALSE)

> qgraph.lavaan(fit, filetype = "", include = 8:12,

+ vsize.man = 1, vsize.lat = 6, edge.label.cex = 0.5,

+ residSize = 0.1, groups = big5groups,

+ titles = FALSE, minimum = 0.15)

> dev.off()

pdf

2

Page 73: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Model

N1 N6 N11 N16 N21 N26 N31 N36 N41 N46N51

N56N61

N66N71

N76N81

N86N91

N96N101

N106N111

N116

N121

N126

N131

N136

N141

N146

N151

N156

N161

N166

N171

N176

N181

N186

N191

N196

N201

N206

N211

N216

N221

N226

N231

N236

E2

E7

E12

E17

E22

E27

E32

E37

E42

E47

E52

E57

E62

E67

E72

E77

E82

E87

E92

E97

E102

E107

E112

E117

E122

E127

E132

E137

E142

E147

E152

E157

E162

E167

E172

E177

E182

E187

E192

E197

E202

E207

E212

E217

E222

E227

E232

E237

O3O8

O13O18

O23O28

O33O38

O43O48

O53O58

O63O68

O73O78O83O88O93O98O103O108O113O118O123O128O133O138O143O148O153O158O163O168

O173O178

O183O188

O193O198

O203O208

O213O218

O223O228

O233O238

A4A9

A14

A19

A24

A29

A34

A39

A44

A49

A54

A59

A64

A69

A74

A79

A84

A89

A94

A99

A104

A109

A114

A119

A124

A129

A134

A139

A144

A149

A154

A159

A164

A169

A174

A179

A184

A189

A194

A199

A204

A209

A214

A219

A224

A229

A234

A239

C5

C10

C15

C20

C25

C30

C35

C40

C45

C50

C55

C60

C65

C70

C75

C80

C85

C90

C95

C100

C105

C110

C115

C120

C125C130

C135C140

C145C150

C155C160

C165C170

C175C180

C185C190

C195C200C205C210C215C220C225C230C235C240

N

E

O

A

C

Page 74: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Results

10.651.140.830.021.040.90.541.33−0.060.350.451.080.31.220.810.221.031.010.360.50.710.180.530.970.410.580.83−0.110.751.090.450.910.310.40.60.630.651.350.640.240.431.050.691.030.40.661.04

11.571.52−0.990.451.581.441.631.221.180.7510.811.071.070.780.681.861.270.640.991.950.391.441.180.950.751.891.091.921.770.360.670.130.671.71.181.341.010.570.851.340.861.651.221.590.721.29

11.470.760.270.780.520.780.840.680.780.90.381.040.980.340.270.520.170.941.310.620.710.550.350.991.690.620.310.440.330.410.960.410.440.740.40.671.670.40.290.520.10.610.790.980.460.770.33

11.161.260.870.940.340.831.510.490.450.450.680.860.870.950.540.950.540.440.970.580.710.640.650.580.460.540.410.680.480.61.410.260.721.040.860.861.380.710.610.660.550.610.90.870.690.740.03

10.540.781.271.540.94−0.41.481.111.681.631.190.981.491.331.31.180.670.971.170.591.671.791.010.671.120.80.761.340.80.990.740.531.161.561.210.630.141.291.070.950.621.721.251.080.962.130.88

0.950.640.740.780.970.620.610.720.710.780.950.420.830.80.731.290.960.780.510.91.080.910.950.610.70.560.730.550.520.83

0.610.97

0.620.77

1.50.420.781.110.560.870.890.340.840.99

0.60.870.760.470.660.910.810.590.90.970.660.631.10.641.450.520.411.02

10.951.060.9

0.760.6

0.920.7

1.280.750.31

1.020.65

0.460.340.5

0.451.4

0.831.05

1.450.26

0.550.52

0.740.75

1.161.28

0.450.79

0.930.411.060.410.580.980.680.621.030.730.760.680.490.630.760.70.691.410.40.671.011.10.70.880.740.991.280.560.750.80.390.771.220.820.890.660.390.761.010.350.950.760.470.850.610.860.470.960.860.980.570.790.690.810.690.60.80.77

0.70.83

0.620.72

0.940.75

0.761.1

0.81.3

0.90.93

0.421.01

0.260.8

0.510.790.4

0.720.680.920.760.610.590.680.280.870.760.510.450.720.480.750.750.630.570.840.570.850.780.90.540.890.490.650.561.090.910.821.040.580.770.620.370.721.02

0.810.47

0.840.73

1.071.480.410.680.770.440.640.40.780.380.760.920.910.670.540.740.730.370.860.470.770.8510.371.121.150.980.590.82

0.41

0.09

0.21

0.2

0.12

−0.11

0.01

−0.04

−0.08

0.04

0.03

0.02

0.04

0

0.03

N1 N6 N11 N16 N21 N26 N31 N36 N41 N46N51

N56N61

N66N71

N76N81

N86N91

N96N101

N106N111

N116

N121

N126

N131

N136

N141

N146

N151

N156

N161

N166

N171

N176

N181

N186

N191

N196

N201

N206

N211

N216

N221

N226

N231

N236

E2

E7

E12

E17

E22

E27

E32

E37

E42

E47

E52

E57

E62

E67

E72

E77

E82

E87

E92

E97

E102

E107

E112

E117

E122

E127

E132

E137

E142

E147

E152

E157

E162

E167

E172

E177

E182

E187

E192

E197

E202

E207

E212

E217

E222

E227

E232

E237

O3O8

O13O18

O23O28

O33O38

O43O48

O53O58

O63O68

O73O78O83O88O93O98O103O108O113O118O123O128O133O138O143O148O153O158O163O168

O173O178

O183O188

O193O198

O203O208

O213O218

O223O228

O233O238

A4A9

A14

A19

A24

A29

A34

A39

A44

A49

A54

A59

A64

A69

A74

A79

A84

A89

A94

A99

A104

A109

A114

A119

A124

A129

A134

A139

A144

A149

A154

A159

A164

A169

A174

A179

A184

A189

A194

A199

A204

A209

A214

A219

A224

A229

A234

A239

C5

C10

C15

C20

C25

C30

C35

C40

C45

C50

C55

C60

C65

C70

C75

C80

C85

C90

C95

C100

C105

C110

C115

C120

C125C130

C135C140

C145C150

C155C160

C165C170

C175C180

C185C190

C195C200C205C210C215C220C225C230C235C240

N

E

O

A

C

Page 75: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Results

N1 N6 N11 N16 N21 N26 N31 N36 N41 N46N51

N56N61

N66N71

N76N81

N86N91

N96N101

N106N111

N116

N121

N126

N131

N136

N141

N146

N151

N156

N161

N166

N171

N176

N181

N186

N191

N196

N201

N206

N211

N216

N221

N226

N231

N236

E2

E7

E12

E17

E22

E27

E32

E37

E42

E47

E52

E57

E62

E67

E72

E77

E82

E87

E92

E97

E102

E107

E112

E117

E122

E127

E132

E137

E142

E147

E152

E157

E162

E167

E172

E177

E182

E187

E192

E197

E202

E207

E212

E217

E222

E227

E232

E237

O3O8

O13O18

O23O28

O33O38

O43O48

O53O58

O63O68

O73O78O83O88O93O98O103O108O113O118O123O128O133O138O143O148O153O158O163O168

O173O178

O183O188

O193O198

O203O208

O213O218

O223O228

O233O238

A4A9

A14

A19

A24

A29

A34

A39

A44

A49

A54

A59

A64

A69

A74

A79

A84

A89

A94

A99

A104

A109

A114

A119

A124

A129

A134

A139

A144

A149

A154

A159

A164

A169

A174

A179

A184

A189

A194

A199

A204

A209

A214

A219

A224

A229

A234

A239

C5

C10

C15

C20

C25

C30

C35

C40

C45

C50

C55

C60

C65

C70

C75

C80

C85

C90

C95

C100

C105

C110

C115

C120

C125C130

C135C140

C145C150

C155C160

C165C170

C175C180

C185C190

C195C200C205C210C215C220C225C230C235C240

N

E

O

A

C

Page 76: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Correlations

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

1 2 3 45

67

89101112131415

1617

1819

2021

2223242526272829

3031

3233

34353637383940

4142

4344

4546 47 48

49 50 51 5253

5455

5657

585960616263

6465

6667

6869

7071727374757677

7879

8081

82838485868788

8990

9192

9394 95 96

97 98 99 100101

102103

104

105

106

107

108

109

110

111

112

113

114

115116

117118

119120121122123124

125126

127

128

129

130

131

132

133

134

135

136

137

138

139140

141142

143 144145 146 147148

149150

151

152

153

154

155

156

157

158

159

160

161

162

163164

165166

167168169170171172

173174

175

176

177

178

179

180

181

182

183

184

185

186

187188

189190

191 192

193 194 195196

197198

199

200

201

202

203

204

205

206

207

208

209

210

211212

213214

215216217218219220

221222

223

224

225

226

227

228

229

230

231

232

233

234

235236

237238

239 240

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●●●●●●●●●●

●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●

●●●●●●●●●●●

●●●●●●

1 2 3 45

67

89101112131415

1617

1819

2021

2223242526272829

3031

3233

34353637383940

4142

4344

4546 47 48

49 50 51 5253

5455

5657

585960616263

6465

6667

6869

7071727374757677

7879

8081

82838485868788

8990

9192

9394 95 96

97 98 99 100101

102103

104

105

106

107

108

109

110

111

112

113

114

115116

117118

119120121122123124

125126

127

128

129

130

131

132

133

134

135

136

137

138

139140

141142

143 144145 146 147148

149150

151

152

153

154

155

156

157

158

159

160

161

162

163164

165166

167168169170171172

173174

175

176

177

178

179

180

181

182

183

184

185

186

187188

189190

191 192

193 194 195196

197198

199

200

201

202

203

204

205

206

207

208

209

210

211212

213214

215216217218219220

221222

223

224

225

226

227

228

229

230

231

232

233

234

235236

237238

239 240

Page 77: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Outline

IntroductionWhat is qgraph?Graphs

Creating graphsInput modesLayout modes

Visualizing statisticsCorrelation matricesFactor loadingsConfirmatory Factor Analysis

Concluding commentsReferences

Page 78: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Concluding comments

I qgraph is still work in progress

I Plans for the future:

I More wrapper functions for different statistics (e.g. IRT)I More layout modesI Estimating and fitting causal models

I Some things I couldn’t describe...

Page 79: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Concluding comments

I qgraph is still work in progressI Plans for the future:

I More wrapper functions for different statistics (e.g. IRT)I More layout modesI Estimating and fitting causal models

I Some things I couldn’t describe...

Page 80: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Concluding comments

I qgraph is still work in progressI Plans for the future:

I More wrapper functions for different statistics (e.g. IRT)

I More layout modesI Estimating and fitting causal models

I Some things I couldn’t describe...

Page 81: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Concluding comments

I qgraph is still work in progressI Plans for the future:

I More wrapper functions for different statistics (e.g. IRT)I More layout modes

I Estimating and fitting causal models

I Some things I couldn’t describe...

Page 82: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Concluding comments

I qgraph is still work in progressI Plans for the future:

I More wrapper functions for different statistics (e.g. IRT)I More layout modesI Estimating and fitting causal models

I Some things I couldn’t describe...

Page 83: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Concluding comments

I qgraph is still work in progressI Plans for the future:

I More wrapper functions for different statistics (e.g. IRT)I More layout modesI Estimating and fitting causal models

I Some things I couldn’t describe...

Page 84: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Layout constraints

Page 85: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Grayscale colors

> Q <- qgraph(cor(big5), minimum = 0.25, cut = 0.4,

+ vsize = 2, groups = big5groups, legend = T,

+ borders = F, vTrans = 200, gray = TRUE)

1

2

34

5

6

7

89

10

11

12

1314

15

16

17

1819

20

21

22

2324

25

26

27

2829

30

31

32

3334

35

36

37

3839

40

41

42

4344

45

46

47

4849

50

51

52

5354

55

56

57

5859

60

61

62

6364

65

66

67

6869

70

71

72

7374

75

76

77

7879

80

81

82

8384

85

86

87

8889

90

91

92

9394

95

96

97

9899

100

101

102

103104

105

106

107

108109

110

111

112

113114

115

116

117

118119

120

121

122

123124

125

126

127

128129

130

131

132

133134

135

136

137

138139

140

141

142

143144

145

146

147

148149

150

151

152

153154

155

156

157

158159

160

161

162

163164

165

166

167

168169

170

171

172

173174

175

176

177

178179

180

181

182

183184

185

186

187

188189

190

191

192

193194

195

196

197

198199

200

201

202

203204

205

206

207

208209

210

211

212

213214

215

216

217

218219

220

221

222

223224

225

226

227

228229

230

231

232

233234

235

236

237

238239

240

NEOAC

NEOAC

Page 86: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Tooltips

Link

Page 87: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Modelling

ξ

η1 η2 η3

y1 y2 y3 y4 y5 y6 y7

x1 x2 x3

Page 88: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph
Page 89: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

Concluding comments

Thank you for your attention!

Page 90: The qgraph package for network visualizations of ... · qgraph I A R package (CRAN link) I Can be used to plot various types of graphs I Di erent from other R packages (e.g. igraph

ReferencesCosta, P. T., & McCrae, R. R. (1992). Neo personality inventory

revised (neo pi-r). Psychological Assessment Resources.Csardi, G., & Nepusz, T. (2006). The extttigraph software package

for complex network research. InterJournal, ComplexSystems, 1695. Available from http://igraph.sf.net

Dolan, C., Oort, F., Stoel, R., & Wicherts, J. (2009). TestingMeasurement Invariance in the Target Rotated MultigroupExploratory Factor Model. Structural Equation Modeling: AMultidisciplinary Journal, 16(2), 20.

Fox, J. (2006). Structural Equation Modeling With the extttsemPackage in R. Structural Equation Modeling, 13(3),465–486.

Hoekstra, H., Fruyt, F. de, & Ormel, J. (2003).Neo-Persoonlijkheidsvragenlijsten: NEO-PI-R, NEO-FFI [Neopersonality questionnaires: NEO-PI-R, NEO-FFI]. Lisse:Swets Test Services.

Revelle, W. (2010). extttpsych: Procedures for psychological,psychometric, and personality research [Computer softwaremanual]. Evanston, Illinois. Available from http://

personality-project.org/r/psych.manual.pdf (Rpackage version 1.0-93)

Rosseel, Y. (2011). extttlavaan: Latent variable analysis[Computer software manual]. Available fromhttp://CRAN.R-project.org/package=lavaan (Rpackage version 0.4-7)