man <- make_manifest(covmat = ability.cov)
## Here is also an example of how to set up a CFA model the hard way
beta <- matrix(NA_real_, nrow = nrow(cormat(man)), ncol = 2)
rownames(beta) <- rownames(cormat(man))
beta[2:3,1] <- beta[5:6,2] <- 0
free <- is.na(beta)
beta <- new("parameter.coef", x = beta, free = free, num_free = sum(free))
Phi <- diag(2)
free <- lower.tri(Phi)
Phi <- new("parameter.cormat", x = Phi, free = free, num_free = sum(free))
res <- make_restrictions(manifest = man, beta = beta, Phi = Phi,
discrepancy = "MLE")
show(res)
RAM <- restrictions2RAM(res)
if(require(sem)) {
RAM[,3] <- c(0.5, 0, 0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0, 0,
1, 0, 1, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5)
cfa <- sem(RAM, model.matrix(man, standardize = FALSE), man@n.obs)
summary(cfa)
}
Run the code above in your browser using DataLab