psych (version 1.0-17)

VSS.simulate: create VSS like data

Description

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.

Usage

VSS.simulate(ncases, nvariables, nfactors, meanloading)

Arguments

ncases
number of simulated subjects
nvariables
Number of variables
nfactors
Number of factors to generate
meanloading
with a mean loading

Value

  • a ncases x nvariables matrix

See Also

VSS, ICLUST

Examples

Run this code
simulated <- VSS.simulate(1000,20,4,.6)
vss <- VSS(simulated,rotate="varimax")
VSS.plot(vss)
## 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)
  }

Run the code above in your browser using DataLab