data(holzinger)
data(holzinger.outlier)
#Exploratory
nfact <- 3
(ORresult <- obs.resid(holzinger, nfact))
(ORresult.outlier <- obs.resid(holzinger.outlier, nfact))
plot(ORresult)
plot(ORresult.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
(ORresult <- obs.resid(holzinger, model))
(ORresult.outlier <- obs.resid(holzinger.outlier, model))
plot(ORresult)
plot(ORresult.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))
)
(ORresult <- obs.resid(holzinger, model))
(ORresult.outlier <- obs.resid(holzinger.outlier, model))
plot(ORresult)
plot(ORresult.outlier)
Run the code above in your browser using DataLab