| VSS.simulate {psych} | R Documentation |
Simulation is one of most useful techniques in statistics and psychometrics. Here we simulate a correlation matrix with a simple structure composed of a specified number of factors. Each item is assumed to have complexity one.
VSS.simulate(ncases, nvariables, nfactors, meanloading)
ncases |
number of simulated subjects |
nvariables |
Number of variables |
nfactors |
Number of factors to generate |
meanloading |
with a mean loading |
a ncases x nvariables matrix
William Revelle
## Not run:
simulated <- VSS.simulate(1000,20,4,.6)
vss <- VSS(simulated,rotate="varimax")
VSS.plot(vss)
## End(Not run)
## The function is currently defined as
function(ncases,nvariables,nfactors,meanloading)
#generates a simple structure factor matrix
#with nfactors
{
weight=sqrt(1-meanloading*meanloading) #loadings are path coefficients
theta=matrix(rnorm(ncases*nfactors),nrow=ncases,ncol=nvariables)
#generates nfactor independent columns, repeated nvariable/nfactor times)
error=matrix(rnorm(ncases*nvariables),nrow=ncases,ncol=nvariables)
#errors for all variables
items=meanloading*theta+weight*error
#observed score = factor score + error score
return(items)
}