if (FALSE) {
#############################################################################
# EXAMPLE 1: Reliability estimation of Reading dataset data.read
#############################################################################
miceadds::library_install("psych")
set.seed(789)
data( data.read )
dat <- data.read
# calculate matrix of tetrachoric correlations
dat.tetra <- psych::tetrachoric(dat) # using tetrachoric from psych package
dat.tetra2 <- sirt::tetrachoric2(dat) # using tetrachoric2 from sirt package
# perform parallel factor analysis
fap <- psych::fa.parallel.poly(dat, n.iter=1 )
## Parallel analysis suggests that the number of factors=3
## and the number of components=2
# parallel factor analysis based on tetrachoric correlation matrix
## (tetrachoric2)
fap2 <- psych::fa.parallel(dat.tetra2$rho, n.obs=nrow(dat), n.iter=1 )
## Parallel analysis suggests that the number of factors=6
## and the number of components=2
## Note that in this analysis, uncertainty with respect to thresholds is ignored.
# calculate reliability using a model with 4 factors
greenyang.reliability( object.tetra=dat.tetra, nfactors=4 )
## coefficient dimensions estimate
## Omega Total (1D) omega_1 1 0.771
## Omega Total (4D) omega_t 4 0.844
## Omega Hierarchical (4D) omega_h 4 0.360
## Omega Hierarchical Asymptotic (4D) omega_ha 4 0.427
## Explained Common Variance (4D) ECV 4 0.489
## Explained Variance (First Eigenvalue) ExplVar NA 35.145
## Eigenvalue Ratio (1st to 2nd Eigenvalue) EigenvalRatio NA 2.121
# calculation of Green-Yang-Reliability based on tetrachoric correlations
# obtained by tetrachoric2
greenyang.reliability( object.tetra=dat.tetra2, nfactors=4 )
# The same result will be obtained by using fap as the input
greenyang.reliability( object.tetra=fap, nfactors=4 ) }
Run the code above in your browser using DataLab