# NOT RUN {
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)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab