sim.hierarchical(gload=NULL, fload=NULL, n = 0, raw = FALSE,mu = NULL)
make.hierarchical(gload=NULL, fload=NULL, n = 0, raw = FALSE) #deprecated
Given a matrix of item factor loadings (fload) and of loadings of these factors on a general factor (gload), we create a population correlation matrix by using the general factor law (R = F' theta F where theta = g'g).
To create sample values, we use the mvrnorm
function from MASS.
The default is to return population correlation matrices. Sample correlation matrices are generated if n >0. Raw data are returned if raw = TRUE.
The default values for gload and fload create a data matrix discussed by Jensen and Weng, 1994.
Although written to create hierarchical structures, if the gload matrix is all 0, then a non-hierarchical structure will be generated.
omega
, schmid
, ICLUST
, VSS
for ways of analyzing these data. Also see sim.structure
to simulate a variety of structural models (e.g., multiple correlated factor models). The simulation uses the mvrnorm
function from the MASS package.gload <- gload<-matrix(c(.9,.8,.7),nrow=3) # a higher order factor matrix
fload <-matrix(c( #a lower order (oblique) factor matrix
.8,0,0,
.7,0,.0,
.6,0,.0,
0,.7,.0,
0,.6,.0,
0,.5,0,
0,0,.6,
0,0,.5,
0,0,.4), ncol=3,byrow=TRUE)
jensen <- sim.hierarchical(gload,fload) #the test set used by omega
round(jensen,2)
#simulate a non-hierarchical structure
fload <- matrix(c(c(c(.9,.8,.7,.6),rep(0,20)),c(c(.9,.8,.7,.6),rep(0,20)),
c(c(.9,.8,.7,.6),rep(0,20)),c(c(c(.9,.8,.7,.6),rep(0,20)),c(.9,.8,.7,.6))),ncol=5)
gload <- matrix(rep(0,5))
five.factor <- sim.hierarchical(gload,fload,500,TRUE) #create sample data set
#do it again with a hierachical structure
gload <- matrix(rep(.7,5) )
five.factor.g <- sim.hierarchical(gload,fload,500,TRUE) #create sample data set
#compare these two with omega
#not run
#om.5 <- omega(five.factor$observed,5)
#om.5g <- omega(five.factor.g$observed,5)
Run the code above in your browser using DataLab