if (FALSE) {
# single factor model with five indicators each loading by .5
gen <- semPower.genSigma(nIndicator = 5, loadM = .5)
gen$Sigma # implied covariance matrix
gen$modelTrue # analysis model string
gen$modelPop # population model string
# orthogonal two factor model with four and five indicators each loading by .5
gen <- semPower.genSigma(nIndicator = c(4, 5), loadM = .5)
# correlated (r = .25) two factor model with
# four indicators loading by .7 on the first factor
# and five indicators loading by .6 on the second factor
gen <- semPower.genSigma(Phi = .25, nIndicator = c(4, 5), loadM = c(.7, .6))
# correlated three factor model with variying indicators and loadings,
# factor correlations according to Phi
Phi <- matrix(c(
c(1.0, 0.2, 0.5),
c(0.2, 1.0, 0.3),
c(0.5, 0.3, 1.0)
), byrow = TRUE, ncol = 3)
gen <- semPower.genSigma(Phi = Phi, nIndicator = c(3, 4, 5),
loadM = c(.7, .6, .5))
# same as above, but using a factor loadings matrix
Lambda <- matrix(c(
c(0.8, 0.0, 0.0),
c(0.7, 0.0, 0.0),
c(0.6, 0.0, 0.0),
c(0.0, 0.7, 0.0),
c(0.0, 0.8, 0.0),
c(0.0, 0.5, 0.0),
c(0.0, 0.4, 0.0),
c(0.0, 0.0, 0.5),
c(0.0, 0.0, 0.4),
c(0.0, 0.0, 0.6),
c(0.0, 0.0, 0.4),
c(0.0, 0.0, 0.5)
), byrow = TRUE, ncol = 3)
gen <- semPower.genSigma(Phi = Phi, Lambda = Lambda)
# same as above, but using a reduced loading matrix, i. e.
# only define the primary loadings for each factor
loadings <- list(
c(0.8, 0.7, 0.6),
c(0.7, 0.8, 0.5, 0.4),
c(0.5, 0.4, 0.6, 0.4, 0.5)
)
gen <- semPower.genSigma(Phi = Phi, loadings = loadings)
# Provide Beta for a three factor model
# with 3, 4, and 5 indicators
# loading by .6, 5, and .4, respectively.
Beta <- matrix(c(
c(0.0, 0.0, 0.0),
c(0.3, 0.0, 0.0), # f2 = .3*f1
c(0.2, 0.4, 0.0) # f3 = .2*f1 + .4*f2
), byrow = TRUE, ncol = 3)
gen <- semPower.genSigma(Beta = Beta, nIndicator = c(3, 4, 5),
loadM = c(.6, .5, .4))
# two group example:
# correlated two factor model (r = .25 and .35 in the first and second group,
# respectively)
# the first factor is indicated by four indicators loading by .7 in the first
# and .5 in the second group,
# the second factor is indicated by five indicators loading by .6 in the first
# and .8 in the second group,
# all item intercepts are zero in both groups,
# the latent means are zero in the first group
# and .25 and .10 in the second group.
gen <- semPower.genSigma(Phi = list(.25, .35),
nIndicator = list(c(4, 5), c(4, 5)),
loadM = list(c(.7, .6), c(.5, .8)),
tau = list(rep(0, 9), rep(0, 9)),
Alpha = list(c(0, 0), c(.25, .10))
)
gen[[1]]$Sigma # implied covariance matrix group 1
gen[[2]]$Sigma # implied covariance matrix group 2
gen[[1]]$mu # implied means group 1
gen[[2]]$mu # implied means group 2
}
Run the code above in your browser using DataLab