sem
function (from the sem package; Fox, 2010) and outputs a multi-page pdf file containing goodness of fit indices, path diagram, graphs of the parameter estimates and graphs of the implied and observed covariance and correlation matrices.qgraph.sem(res, layout="circle", ..., vsize.man=3, vsize.lat=6, filename="qgraph",
filetype="pdf", residuals=TRUE, panels=2, include=1:12, latres=TRUE,
curve=0, residSize=0.2, onefile=TRUE, width = 7, height = 7)
qgraph
. This is both for the path diagram and for the correlation/covariance plots.Alternatively the 'spring' layout can be used (layout="spring"). This will use the Fruchterman-reingold algorithm (Fruchterman & Reingold, 1991) is used, which has been ported from the 'sna' package (Butts, 2010). This is a force-directed algorithm. It is best to use this in combination with residuals=FALSE. Names for variables and edges used in the model specification are passed to the path diagram. To keep the model readable it is advised to limit these names to 3 characters. If a variable or edge name contains an asterisk, the asterisk is omitted and the name will be printed in the symbol font. This way Greek letters can be used (e.g. the edge name "l*" will make a lambda character). Because the symbol font conveniently uses Arabic numerals, parameter names like beta1 can be created with "*b1" in the model.
Carter T. Butts
John Fox with contributions from Adam Kramer
Fruchterman, T. & Reingold, E. (1991). Graph drawing by force-directed placement. Software - Pract. Exp. 21, 1129?1164.
qgraph
qgraph.cfa
qgraph.semModel
sem
require('sem')
# This example is taken from the examples of the sem function.
# Only names were changed to better suit the path diagram.
# ----------------------- Thurstone data ---------------------------------------
# Second-order confirmatory factor analysis, from the SAS manual for PROC CALIS
R.thur <- readMoments(diag=FALSE, names=c('Sen','Voc',
'SC','FL','4LW','Suf',
'LS','Ped', 'LG'))
.828
.776 .779
.439 .493 .46
.432 .464 .425 .674
.447 .489 .443 .59 .541
.447 .432 .401 .381 .402 .288
.541 .537 .534 .35 .367 .32 .555
.38 .358 .359 .424 .446 .325 .598 .452
model.thur <- specifyModel()
F1 -> Sen, *l11, NA
F1 -> Voc, *l21, NA
F1 -> SC, *l31, NA
F2 -> FL, *l41, NA
F2 -> 4LW, *l52, NA
F2 -> Suf, *l62, NA
F3 -> LS, *l73, NA
F3 -> Ped, *l83, NA
F3 -> LG, *l93, NA
F4 -> F1, *g1, NA
F4 -> F2, *g2, NA
F4 -> F3, *g3, NA
Sen <-> Sen, q*1, NA
Voc<-> Voc, q*2, NA
SC <-> SC, q*3, NA
FL <-> FL, q*4, NA
4LW <-> 4LW, q*5, NA
Suf<-> Suf, q*6, NA
LS <-> LS, q*7, NA
Ped<-> Ped, q*8, NA
LG <-> LG, q*9, NA
F1 <-> F1, NA, 1
F2 <-> F2, NA, 1
F3 <-> F3, NA, 1
F4 <-> F4, NA, 1
sem.thur <- sem(model.thur, R.thur, 213)
# Run qgraph:
qgraph.sem(sem.thur,filename="Thurstone tree",layout="tree",edge.label.cex=0.6,
curve=0.4,width=8,height=5)
# Spring layout:
qgraph.sem(sem.thur,filename="Thurstone spring",layout="spring",residuals=FALSE,
width=5,height=5)
Run the code above in your browser using DataLab