data(holzinger)
data(holzinger.outlier)
#Exploratory
nfact <- 3
(gCDresult <- gCD(holzinger, nfact))
(gCDresult.outlier <- gCD(holzinger.outlier, nfact))
plot(gCDresult)
plot(gCDresult.outlier)
#Confirmatory with sem
model <- specifyModel()
F1 -> V1, lam11
F1 -> V2, lam21
F1 -> V3, lam31
F2 -> V4, lam41
F2 -> V5, lam52
F2 -> V6, lam62
F3 -> V7, lam73
F3 -> V8, lam83
F3 -> V9, lam93
F1 <-> F1, NA, 1
F2 <-> F2, NA, 1
F3 <-> F3, NA, 1
(gCDresult2 <- gCD(holzinger, model))
(gCDresult2.outlier <- gCD(holzinger.outlier, model))
plot(gCDresult2)
plot(gCDresult2.outlier)
#Confirmatory using OpenMx (requires github version, see ?faoutlier)
manifests <- colnames(holzinger)
latents <- c("F1","F2","F3")
#specify model, mxData not necessary but useful to check if mxRun works
model <- mxModel("Three Factor",
type="RAM",
manifestVars = manifests,
latentVars = latents,
mxPath(from="F1", to=manifests[1:3]),
mxPath(from="F2", to=manifests[4:6]),
mxPath(from="F3", to=manifests[7:9]),
mxPath(from=manifests, arrows=2),
mxPath(from=latents, arrows=2,
free=FALSE, values=1.0),
mxData(cov(holzinger), type="cov", numObs=nrow(holzinger))
)
(gCDresult2 <- gCD(holzinger, model))
(gCDresult2.outlier <- gCD(holzinger.outlier, model))
plot(gCDresult2)
plot(gCDresult2.outlier)
Run the code above in your browser using DataLab