# perfect input correlation matrix for two-factor model
# Population Factor Pattern of the 3 items for each respective
# Factor: 0.8, 0.6, 0.4
# Population Factor-Factor correlation: 0.3
mycor <- matrix(nrow=6, ncol=6, byrow=TRUE,
c(1.000,0.480,0.320,0.192,0.144,0.096,
0.480,1.000,0.240,0.144,0.108,0.072,
0.320,0.240,1.000,0.096,0.072,0.048,
0.192,0.144,0.096,1.000,0.480,0.320,
0.144,0.108,0.072,0.480,1.000,0.240,
0.096,0.072,0.048,0.320,0.240,1.000))
colnames(mycor) <- c("V1", "V2", "V3", "V4", "V5", "V6")
rownames(mycor) <- colnames(mycor)
# the confirmatory factor analysis
# first three variables with first factor, last three with second
# default correlation matrix is mycor
# two ways to specify the items, with a colon and with commas
corCFA(F1=V1:V3, F2=c(V6,V5,V4))
# abbreviated form
cfa(F1=V1:V3, F2=V4:V6)
# produce a gray scale heat map of the item correlations
# with communalities in the diagonal
# all subsequent graphics are in gray scale until changed
set(colors="gray")
corCFA(F1=V1:V3, F2=V4:V6)
# access the lessR data set called datMach4
data(datMach4)
# select the subset of the data that just contains Mach items
mach <- subset(datMach4, select=c(m01:m20))
# calculate the correlations and store in mycor
cr(mach)
# confirmatory factor analysis of 4-factor solution of Mach IV scale
# Hunter, Gerbing and Boster, 1982
corCFA(F1=c(m06,m07,m09,m10), F2=c(m15,m02),
F3=c(m04,m11,m16), F4=c(m01,m05,m12,m13))
# bad model to illustrate indicator diagnostics
mycor <- corReflect(vars=c(m20))
corCFA(F1=c(m06,m09,m19), F2=c(m07),
F3=c(m04,m11,m16), F4=c(m20,m18,m12,m15))
Run the code above in your browser using DataLab