Init
options(digits = 4)
library(pacman)
p_load(kirkegaard, lavaan, lavaanPlot)
Data
#read data
load("data/BAFACALO_DATASET-2.RData")
load("data/codebook_BAFACALO.RData")
#fix incorrect names
names(bafacalo)[156:167] #notice 0 vs. O!
## [1] "MVi01" "MViO2" "MViO3" "MVi02" "MViO4" "MViO5" "MVi03" "MViO6"
## [9] "MViO7" "MVi04" "MViO8" "MViO9"
names(bafacalo)[156:167] = "MVi" + str_pad(1:12, width = 2, side = "left", pad = "0")
#subset items
items = bafacalo %>% select(VZi01:Ii15)
#recode
bafacalo$sex %<>% plyr::mapvalues(0:1, c("Female", "Male"))
Descriptive
#how many cases?
nrow(bafacalo)
## [1] 292
#how many items?
ncol(items)
## [1] 219
#how much missing item data?
miss_amount(items)
## cases with missing data vars with missing data cells with missing data
## 1.0000 1.0000 0.2353
Item stats
#calculate items stats
item_stats = tibble(
name = names(items),
number = 1:ncol(items),
test = str_match(names(items), "(.+?)(\\d+)$")[, 2],
number_in_test = str_match(names(items), "(.+?)(\\d+)$")[, 3] %>% as.numeric(),
#pass rate
na = map_dbl(items, ~mean(is.na(.))),
pass_rate_pre = items %>% colMeans(na.rm = T)
)
#fill in 0's
items[is.na(items)] = 0
#new pass rate
item_stats$pass_rate = colMeans(items)
IRT
#IRT
irt_fit = irt.fa(items)
## Warning in cor.smooth(mat): Matrix was not positive definite, smoothing was
## done
## The determinant of the smoothed correlation was zero.
## This means the objective function is not defined.
## Chi square is based upon observed residuals.
## The determinant of the smoothed correlation was zero.
## This means the objective function is not defined for the null model either.
## The Chi square is thus based upon observed correlations.
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.

irt_fit
## Item Response Analysis using Factor Analysis
##
## Call: irt.fa(x = items)
## Item Response Analysis using Factor Analysis
##
## Summary information by factor and item
## Factor = 1
## -3 -2 -1 0 1 2 3
## VZi01 0.27 0.49 0.36 0.13 0.04 0.01 0.00
## VZi02 0.35 0.91 0.48 0.09 0.01 0.00 0.00
## VZi03 0.13 0.44 0.64 0.29 0.07 0.01 0.00
## VZi04 0.24 0.53 0.45 0.16 0.04 0.01 0.00
## VZi05 0.19 0.69 0.69 0.19 0.03 0.01 0.00
## VZi06 0.19 0.37 0.35 0.17 0.06 0.02 0.01
## VZi07 0.04 0.12 0.27 0.37 0.25 0.10 0.03
## VZi08 0.14 0.46 0.61 0.26 0.06 0.01 0.00
## VZi09 0.14 0.34 0.43 0.25 0.09 0.02 0.01
## VZi10 0.23 0.41 0.34 0.15 0.05 0.01 0.00
## VZi11 0.10 0.45 0.81 0.35 0.07 0.01 0.00
## VZi12 0.18 0.66 0.71 0.20 0.04 0.01 0.00
## VZi13 0.03 0.09 0.19 0.28 0.24 0.13 0.05
## VZi14 0.03 0.09 0.22 0.35 0.28 0.13 0.05
## VZi15 0.10 0.35 0.60 0.34 0.10 0.02 0.00
## VZi16 0.09 0.87 1.41 0.20 0.02 0.00 0.00
## VZi17 0.02 0.15 0.83 0.92 0.19 0.02 0.00
## VZi18 0.07 1.06 1.58 0.14 0.01 0.00 0.00
## VZi19 0.11 1.04 1.28 0.15 0.01 0.00 0.00
## VZi20 0.05 0.14 0.34 0.41 0.23 0.08 0.02
## VZi21 0.04 0.18 0.50 0.55 0.21 0.05 0.01
## VZi22 0.09 0.75 1.34 0.24 0.02 0.00 0.00
## VZi23 0.03 0.16 0.52 0.62 0.24 0.05 0.01
## VZi24 0.07 0.33 0.79 0.46 0.10 0.02 0.00
## VZi25 0.13 1.17 1.17 0.13 0.01 0.00 0.00
## VZi26 0.02 0.17 0.86 0.86 0.17 0.02 0.00
## VZi27 0.02 0.13 0.65 0.91 0.25 0.04 0.01
## VZi28 0.05 0.37 1.25 0.51 0.07 0.01 0.00
## VZi29 0.03 0.18 0.70 0.73 0.19 0.03 0.01
## VZi30 0.03 0.23 1.13 0.75 0.11 0.01 0.00
## CFi01 0.16 0.33 0.36 0.20 0.07 0.02 0.01
## CFi02 0.17 0.33 0.33 0.18 0.07 0.02 0.01
## CFi03 0.14 0.28 0.31 0.19 0.08 0.03 0.01
## CFi04 0.12 0.40 0.59 0.30 0.08 0.02 0.00
## CFi05 0.04 0.16 0.50 0.60 0.24 0.06 0.01
## CFi06 0.07 0.15 0.26 0.27 0.17 0.07 0.03
## CFi07 0.04 0.15 0.39 0.49 0.25 0.07 0.02
## CFi08 0.03 0.16 0.61 0.72 0.23 0.04 0.01
## CFi09 0.19 0.33 0.31 0.16 0.06 0.02 0.01
## CFi10 0.09 0.15 0.17 0.14 0.09 0.05 0.02
## CFi11 0.16 0.24 0.23 0.14 0.06 0.03 0.01
## CFi12 0.04 0.13 0.28 0.36 0.24 0.10 0.03
## CFi13 0.06 0.17 0.35 0.37 0.19 0.07 0.02
## CFi14 0.14 0.26 0.28 0.18 0.08 0.03 0.01
## CFi15 0.06 0.14 0.26 0.29 0.19 0.08 0.03
## CFi16 0.05 0.24 0.70 0.57 0.15 0.03 0.01
## CFi17 0.06 0.20 0.42 0.39 0.18 0.05 0.01
## CFi18 0.10 0.13 0.12 0.09 0.06 0.03 0.02
## CFi19 0.06 0.41 1.07 0.44 0.07 0.01 0.00
## CFi20 0.03 0.13 0.39 0.54 0.27 0.08 0.02
## CFi21 0.07 0.21 0.38 0.34 0.16 0.05 0.02
## CFi22 0.03 0.21 0.88 0.74 0.15 0.02 0.00
## CFi23 0.04 0.17 0.50 0.57 0.22 0.05 0.01
## CFi24 0.05 0.10 0.18 0.21 0.17 0.10 0.05
## CFi25 0.14 0.29 0.35 0.22 0.09 0.03 0.01
## CFi26 0.15 0.37 0.43 0.22 0.07 0.02 0.01
## CFi27 0.07 0.19 0.33 0.31 0.16 0.06 0.02
## CFi28 0.05 0.14 0.28 0.32 0.20 0.08 0.03
## CFi29 0.04 0.13 0.33 0.43 0.25 0.09 0.03
## CFi30 0.05 0.18 0.43 0.45 0.20 0.06 0.01
## CFi31 0.04 0.16 0.43 0.50 0.23 0.06 0.02
## CFi32 0.04 0.13 0.33 0.44 0.26 0.09 0.03
## V1i01 0.08 0.13 0.17 0.15 0.10 0.06 0.03
## V1i05 0.17 0.23 0.21 0.12 0.06 0.02 0.01
## V1i10 0.05 0.10 0.16 0.18 0.15 0.09 0.04
## V1i14 0.15 0.21 0.20 0.13 0.07 0.03 0.01
## V1i15 0.24 0.39 0.30 0.13 0.04 0.01 0.00
## V1i18 0.04 0.05 0.07 0.07 0.07 0.05 0.04
## V2i03 0.05 0.08 0.12 0.14 0.13 0.09 0.05
## V3i01 0.08 0.13 0.17 0.16 0.11 0.06 0.03
## V3i04 0.06 0.08 0.09 0.08 0.07 0.05 0.03
## V3i11 0.05 0.09 0.14 0.17 0.15 0.10 0.05
## V3i12 0.05 0.07 0.09 0.09 0.07 0.05 0.04
## V3i17 0.07 0.20 0.36 0.33 0.16 0.06 0.02
## MA1i02 0.04 0.06 0.08 0.09 0.09 0.07 0.05
## MA1i03 0.04 0.06 0.07 0.08 0.08 0.06 0.05
## MA1i04 0.05 0.07 0.10 0.11 0.10 0.07 0.05
## MA1i05 0.04 0.05 0.07 0.07 0.07 0.06 0.05
## MA1i07 0.04 0.06 0.09 0.10 0.10 0.07 0.05
## MA1i09 0.06 0.10 0.15 0.16 0.13 0.08 0.04
## MA1i11 0.04 0.06 0.08 0.09 0.09 0.07 0.05
## MA1i13 0.06 0.08 0.10 0.10 0.08 0.06 0.04
## MA2i02 0.07 0.11 0.14 0.14 0.11 0.07 0.04
## MA2i03 0.04 0.06 0.09 0.11 0.11 0.08 0.06
## MA2i04 0.05 0.08 0.11 0.12 0.11 0.07 0.05
## MA2i05 0.04 0.07 0.11 0.13 0.12 0.09 0.05
## MA2i06 0.04 0.09 0.15 0.18 0.16 0.10 0.05
## MA2i07 0.05 0.09 0.14 0.16 0.13 0.09 0.05
## MA2i08 0.06 0.09 0.11 0.11 0.09 0.06 0.04
## MA2i09 0.04 0.07 0.11 0.13 0.12 0.08 0.05
## MA2i10 0.05 0.09 0.14 0.17 0.15 0.09 0.05
## MVi01 0.09 0.13 0.14 0.12 0.08 0.04 0.02
## MVi02 0.11 0.26 0.36 0.26 0.11 0.04 0.01
## MVi03 0.09 0.11 0.12 0.10 0.07 0.04 0.02
## MVi04 0.12 0.25 0.33 0.23 0.10 0.04 0.01
## MVi05 0.10 0.22 0.32 0.25 0.12 0.04 0.02
## MVi07 0.09 0.23 0.37 0.30 0.14 0.05 0.01
## MVi10 0.06 0.08 0.09 0.08 0.06 0.04 0.03
## MVi11 0.10 0.21 0.29 0.23 0.12 0.05 0.02
## MVi12 0.07 0.09 0.10 0.09 0.07 0.05 0.03
## RGi01 0.09 0.15 0.20 0.18 0.11 0.06 0.02
## RGi02 0.10 0.21 0.29 0.23 0.12 0.05 0.02
## RGi03 0.11 0.33 0.52 0.31 0.10 0.03 0.01
## RGi04 0.05 0.08 0.11 0.11 0.10 0.07 0.04
## RGi05 0.05 0.09 0.12 0.14 0.12 0.08 0.05
## RGi06 0.04 0.14 0.42 0.54 0.25 0.07 0.02
## RGi07 0.03 0.09 0.22 0.34 0.27 0.13 0.05
## RGi08 0.05 0.16 0.34 0.39 0.21 0.07 0.02
## RGi09 0.04 0.16 0.50 0.59 0.24 0.06 0.01
## RGi10 0.03 0.07 0.14 0.24 0.24 0.16 0.07
## RGi11 0.02 0.08 0.20 0.36 0.32 0.15 0.05
## RGi12 0.02 0.06 0.13 0.22 0.25 0.17 0.08
## RGi13 0.02 0.03 0.04 0.06 0.07 0.07 0.06
## RGi14 0.03 0.07 0.12 0.17 0.17 0.13 0.07
## RGi15 0.03 0.05 0.08 0.10 0.11 0.10 0.07
## RLi01 0.14 0.24 0.25 0.16 0.08 0.03 0.01
## RLi02 0.17 0.36 0.37 0.19 0.07 0.02 0.01
## RLi03 0.13 0.23 0.26 0.18 0.09 0.03 0.01
## RLi05 0.04 0.05 0.06 0.07 0.07 0.05 0.04
## RLi06 0.13 0.22 0.25 0.17 0.08 0.03 0.01
## RLi07 0.05 0.06 0.07 0.07 0.06 0.05 0.03
## RLi09 0.10 0.18 0.22 0.18 0.10 0.05 0.02
## RLi11 0.06 0.10 0.13 0.14 0.11 0.07 0.04
## RLi15 0.06 0.12 0.18 0.19 0.14 0.08 0.04
## RLi16 0.18 0.26 0.23 0.13 0.05 0.02 0.01
## RLi18 0.11 0.18 0.20 0.15 0.09 0.04 0.02
## RLi19 0.04 0.06 0.07 0.07 0.06 0.05 0.04
## RLi23 0.10 0.17 0.21 0.17 0.10 0.05 0.02
## RLi27 0.10 0.15 0.17 0.14 0.08 0.04 0.02
## RLi28 0.06 0.10 0.13 0.13 0.10 0.07 0.04
## RLi29 0.07 0.18 0.31 0.29 0.16 0.06 0.02
## RLi30 0.06 0.13 0.22 0.25 0.17 0.09 0.04
## Ii01 0.25 0.34 0.25 0.11 0.04 0.01 0.00
## Ii02 0.05 0.06 0.07 0.07 0.06 0.04 0.03
## Ii03 0.08 0.16 0.24 0.23 0.14 0.06 0.02
## Ii04 0.11 0.28 0.40 0.27 0.11 0.03 0.01
## Ii05 0.08 0.17 0.28 0.26 0.15 0.06 0.02
## Ii06 0.08 0.34 0.70 0.40 0.10 0.02 0.00
## Ii07 0.09 0.13 0.14 0.12 0.08 0.04 0.02
## Ii08 0.06 0.14 0.24 0.26 0.16 0.08 0.03
## Ii09 0.07 0.22 0.47 0.41 0.16 0.05 0.01
## Ii10 0.03 0.10 0.25 0.38 0.28 0.12 0.04
## Ii11 0.05 0.08 0.11 0.13 0.12 0.08 0.05
## Ii14 0.03 0.06 0.10 0.13 0.13 0.11 0.07
## Ii15 0.03 0.04 0.06 0.07 0.08 0.07 0.05
## Test Info 11.81 31.44 50.44 37.51 17.96 7.81 3.48
## SEM 0.29 0.18 0.14 0.16 0.24 0.36 0.54
## Reliability 0.92 0.97 0.98 0.97 0.94 0.87 0.71
##
## Factor analysis with Call: fa(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate,
## fm = fm)
##
## Test of the hypothesis that 1 factor is sufficient.
## The degrees of freedom for the model is 23652 and the objective function was 553.9
## The number of observations was 292 with Chi Square = 119920 with prob < 0
##
## The root mean square of the residuals (RMSA) is 0.09
## The df corrected root mean square of the residuals is 0.09
##
## Tucker Lewis Index of factoring reliability = 0.837
## RMSEA index = 0.141 and the 10 % confidence intervals are 0.118 NA
## BIC = -14346
irt_fit$fa
## Factor Analysis using method = minres
## Call: fa(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate,
## fm = fm)
## Standardized loadings (pattern matrix) based upon correlation matrix
## MR1 h2 u2 com
## VZi01 0.64 4.1e-01 0.59 1
## VZi02 0.75 5.6e-01 0.44 1
## VZi03 0.69 4.8e-01 0.52 1
## VZi04 0.66 4.4e-01 0.56 1
## VZi05 0.73 5.4e-01 0.46 1
## VZi06 0.60 3.6e-01 0.64 1
## VZi07 0.58 3.4e-01 0.66 1
## VZi08 0.68 4.7e-01 0.53 1
## VZi09 0.61 3.8e-01 0.62 1
## VZi10 0.61 3.7e-01 0.63 1
## VZi11 0.73 5.3e-01 0.47 1
## VZi12 0.73 5.4e-01 0.46 1
## VZi13 0.53 2.8e-01 0.72 1
## VZi14 0.57 3.3e-01 0.67 1
## VZi15 0.67 4.5e-01 0.55 1
## VZi16 0.84 7.0e-01 0.30 1
## VZi17 0.78 6.1e-01 0.39 1
## VZi18 0.87 7.5e-01 0.25 1
## VZi19 0.84 7.1e-01 0.29 1
## VZi20 0.61 3.7e-01 0.63 1
## VZi21 0.68 4.6e-01 0.54 1
## VZi22 0.82 6.8e-01 0.32 1
## VZi23 0.70 4.9e-01 0.51 1
## VZi24 0.72 5.2e-01 0.48 1
## VZi25 0.84 7.1e-01 0.29 1
## VZi26 0.78 6.1e-01 0.39 1
## VZi27 0.76 5.8e-01 0.42 1
## VZi28 0.80 6.4e-01 0.36 1
## VZi29 0.74 5.5e-01 0.45 1
## VZi30 0.80 6.4e-01 0.36 1
## CFi01 0.59 3.5e-01 0.65 1
## CFi02 0.58 3.3e-01 0.67 1
## CFi03 0.55 3.1e-01 0.69 1
## CFi04 0.67 4.5e-01 0.55 1
## CFi05 0.69 4.7e-01 0.53 1
## CFi06 0.53 2.8e-01 0.72 1
## CFi07 0.64 4.1e-01 0.59 1
## CFi08 0.73 5.3e-01 0.47 1
## CFi09 0.57 3.3e-01 0.67 1
## CFi10 0.44 1.9e-01 0.81 1
## CFi11 0.51 2.6e-01 0.74 1
## CFi12 0.58 3.4e-01 0.66 1
## CFi13 0.60 3.5e-01 0.65 1
## CFi14 0.54 2.9e-01 0.71 1
## CFi15 0.54 3.0e-01 0.70 1
## CFi16 0.72 5.2e-01 0.48 1
## CFi17 0.62 3.9e-01 0.61 1
## CFi18 0.39 1.5e-01 0.85 1
## CFi19 0.77 6.0e-01 0.40 1
## CFi20 0.66 4.3e-01 0.57 1
## CFi21 0.60 3.6e-01 0.64 1
## CFi22 0.77 5.9e-01 0.41 1
## CFi23 0.68 4.6e-01 0.54 1
## CFi24 0.48 2.3e-01 0.77 1
## CFi25 0.57 3.3e-01 0.67 1
## CFi26 0.62 3.9e-01 0.61 1
## CFi27 0.57 3.3e-01 0.67 1
## CFi28 0.56 3.1e-01 0.69 1
## CFi29 0.61 3.8e-01 0.62 1
## CFi30 0.64 4.1e-01 0.59 1
## CFi31 0.65 4.2e-01 0.58 1
## CFi32 0.62 3.8e-01 0.62 1
## V1i01 0.43 1.9e-01 0.81 1
## V1i02 0.12 1.4e-02 0.99 1
## V1i03 0.19 3.7e-02 0.96 1
## V1i04 0.02 3.5e-04 1.00 1
## V1i05 0.50 2.5e-01 0.75 1
## V1i06 0.04 1.9e-03 1.00 1
## V1i07 0.22 5.0e-02 0.95 1
## V1i08 0.25 6.1e-02 0.94 1
## V1i09 0.00 2.4e-06 1.00 1
## V1i10 0.45 2.0e-01 0.80 1
## V1i11 -0.05 3.0e-03 1.00 1
## V1i12 -0.07 5.5e-03 0.99 1
## V1i13 0.00 6.7e-06 1.00 1
## V1i14 0.48 2.3e-01 0.77 1
## V1i15 0.60 3.5e-01 0.65 1
## V1i16 -0.19 3.7e-02 0.96 1
## V1i17 0.28 7.9e-02 0.92 1
## V1i18 0.30 8.8e-02 0.91 1
## V1i19 0.19 3.5e-02 0.97 1
## V1i20 0.18 3.2e-02 0.97 1
## V1i21 0.07 4.8e-03 1.00 1
## V1i22 0.11 1.3e-02 0.99 1
## V1i23 0.21 4.4e-02 0.96 1
## V1i24 0.00 1.6e-06 1.00 1
## V2i01 -0.06 3.4e-03 1.00 1
## V2i02 0.13 1.7e-02 0.98 1
## V2i03 0.41 1.7e-01 0.83 1
## V2i04 -0.15 2.2e-02 0.98 1
## V2i05 0.07 4.4e-03 1.00 1
## V2i06 0.22 4.7e-02 0.95 1
## V2i07 0.15 2.4e-02 0.98 1
## V2i08 0.10 9.1e-03 0.99 1
## V2i09 0.25 6.2e-02 0.94 1
## V2i10 -0.14 2.0e-02 0.98 1
## V2i11 0.22 4.6e-02 0.95 1
## V2i12 0.20 4.2e-02 0.96 1
## V2i13 -0.07 4.7e-03 1.00 1
## V2i14 0.20 3.9e-02 0.96 1
## V2i15 0.04 1.5e-03 1.00 1
## V2i16 0.00 2.5e-05 1.00 1
## V2i17 -0.10 1.1e-02 0.99 1
## V2i18 0.22 4.9e-02 0.95 1
## V3i01 0.44 2.0e-01 0.80 1
## V3i02 0.21 4.5e-02 0.96 1
## V3i03 0.18 3.4e-02 0.97 1
## V3i04 0.33 1.1e-01 0.89 1
## V3i05 0.16 2.4e-02 0.98 1
## V3i06 0.09 7.5e-03 0.99 1
## V3i07 0.12 1.5e-02 0.99 1
## V3i08 0.02 6.1e-04 1.00 1
## V3i09 -0.14 1.9e-02 0.98 1
## V3i10 0.18 3.2e-02 0.97 1
## V3i11 0.44 1.9e-01 0.81 1
## V3i12 0.33 1.1e-01 0.89 1
## V3i13 -0.16 2.4e-02 0.98 1
## V3i14 -0.04 1.6e-03 1.00 1
## V3i15 0.11 1.3e-02 0.99 1
## V3i16 0.23 5.3e-02 0.95 1
## V3i17 0.59 3.5e-01 0.65 1
## V3i18 0.15 2.2e-02 0.98 1
## MA1i01 0.20 4.0e-02 0.96 1
## MA1i02 0.34 1.1e-01 0.89 1
## MA1i03 0.32 1.0e-01 0.90 1
## MA1i04 0.36 1.3e-01 0.87 1
## MA1i05 0.31 9.4e-02 0.91 1
## MA1i06 0.27 7.4e-02 0.93 1
## MA1i07 0.35 1.2e-01 0.88 1
## MA1i08 0.19 3.7e-02 0.96 1
## MA1i09 0.43 1.9e-01 0.81 1
## MA1i10 0.28 7.6e-02 0.92 1
## MA1i11 0.34 1.2e-01 0.88 1
## MA1i12 0.23 5.4e-02 0.95 1
## MA1i13 0.36 1.3e-01 0.87 1
## MA1i14 0.23 5.2e-02 0.95 1
## MA1i15 0.20 4.1e-02 0.96 1
## MA2i01 0.18 3.3e-02 0.97 1
## MA2i02 0.41 1.7e-01 0.83 1
## MA2i03 0.37 1.4e-01 0.86 1
## MA2i04 0.38 1.4e-01 0.86 1
## MA2i05 0.39 1.5e-01 0.85 1
## MA2i06 0.45 2.0e-01 0.80 1
## MA2i07 0.42 1.8e-01 0.82 1
## MA2i08 0.36 1.3e-01 0.87 1
## MA2i09 0.39 1.5e-01 0.85 1
## MA2i10 0.44 1.9e-01 0.81 1
## MVi01 0.40 1.6e-01 0.84 1
## MVi02 0.58 3.3e-01 0.67 1
## MVi03 0.38 1.5e-01 0.85 1
## MVi04 0.56 3.1e-01 0.69 1
## MVi05 0.55 3.1e-01 0.69 1
## MVi06 0.28 8.0e-02 0.92 1
## MVi07 0.59 3.4e-01 0.66 1
## MVi08 0.10 1.1e-02 0.99 1
## MVi09 0.27 7.5e-02 0.92 1
## MVi10 0.33 1.1e-01 0.89 1
## MVi11 0.53 2.8e-01 0.72 1
## MVi12 0.35 1.2e-01 0.88 1
## RGi01 0.47 2.2e-01 0.78 1
## RGi02 0.54 2.9e-01 0.71 1
## RGi03 0.65 4.2e-01 0.58 1
## RGi04 0.37 1.4e-01 0.86 1
## RGi05 0.40 1.6e-01 0.84 1
## RGi06 0.66 4.3e-01 0.57 1
## RGi07 0.57 3.2e-01 0.68 1
## RGi08 0.60 3.6e-01 0.64 1
## RGi09 0.69 4.7e-01 0.53 1
## RGi10 0.51 2.6e-01 0.74 1
## RGi11 0.58 3.4e-01 0.66 1
## RGi12 0.51 2.6e-01 0.74 1
## RGi13 0.29 8.5e-02 0.91 1
## RGi14 0.45 2.0e-01 0.80 1
## RGi15 0.37 1.3e-01 0.87 1
## RLi01 0.51 2.6e-01 0.74 1
## RLi02 0.60 3.6e-01 0.64 1
## RLi03 0.52 2.7e-01 0.73 1
## RLi04 0.23 5.5e-02 0.95 1
## RLi05 0.30 8.8e-02 0.91 1
## RLi06 0.51 2.6e-01 0.74 1
## RLi07 0.29 8.7e-02 0.91 1
## RLi08 0.13 1.7e-02 0.98 1
## RLi09 0.48 2.3e-01 0.77 1
## RLi10 0.11 1.2e-02 0.99 1
## RLi11 0.40 1.6e-01 0.84 1
## RLi12 0.21 4.5e-02 0.96 1
## RLi13 0.05 2.1e-03 1.00 1
## RLi14 0.01 1.8e-04 1.00 1
## RLi15 0.46 2.2e-01 0.78 1
## RLi16 0.52 2.7e-01 0.73 1
## RLi17 -0.01 8.0e-05 1.00 1
## RLi18 0.47 2.2e-01 0.78 1
## RLi19 0.30 9.1e-02 0.91 1
## RLi20 -0.16 2.6e-02 0.97 1
## RLi21 0.28 7.9e-02 0.92 1
## RLi22 0.19 3.6e-02 0.96 1
## RLi23 0.47 2.3e-01 0.77 1
## RLi24 0.09 7.6e-03 0.99 1
## RLi25 -0.10 9.6e-03 0.99 1
## RLi26 0.04 1.6e-03 1.00 1
## RLi27 0.43 1.9e-01 0.81 1
## RLi28 0.39 1.6e-01 0.84 1
## RLi29 0.56 3.1e-01 0.69 1
## RLi30 0.51 2.6e-01 0.74 1
## Ii01 0.57 3.2e-01 0.68 1
## Ii02 0.29 8.6e-02 0.91 1
## Ii03 0.51 2.6e-01 0.74 1
## Ii04 0.60 3.6e-01 0.64 1
## Ii05 0.54 2.9e-01 0.71 1
## Ii06 0.70 4.9e-01 0.51 1
## Ii07 0.41 1.6e-01 0.84 1
## Ii08 0.52 2.7e-01 0.73 1
## Ii09 0.64 4.1e-01 0.59 1
## Ii10 0.59 3.5e-01 0.65 1
## Ii11 0.39 1.5e-01 0.85 1
## Ii12 0.25 6.1e-02 0.94 1
## Ii13 0.26 7.0e-02 0.93 1
## Ii14 0.40 1.6e-01 0.84 1
## Ii15 0.31 9.5e-02 0.91 1
##
## MR1
## SS loadings 47.52
## Proportion Var 0.22
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 23871 and the objective function was 2871 with Chi Square of 623407
## The degrees of freedom for the model are 23652 and the objective function was 553.9
##
## The root mean square of the residuals (RMSR) is 0.09
## The df corrected root mean square of the residuals is 0.09
##
## The harmonic number of observations is 292 with the empirical chi square 120272 with prob < 0
## The total number of observations was 292 with Likelihood Chi Square = 119920 with prob < 0
##
## Tucker Lewis Index of factoring reliability = 0.837
## RMSEA index = 0.141 and the 90 % confidence intervals are 0.118 NA
## BIC = -14346
## Fit based upon off diagonal values = 0.84
#negative loadings?
sum(irt_fit$fa$loadings[, 1] < 0)
## [1] 14
#remove bad items (negative loadings)
items2 = items[irt_fit$fa$loadings[, 1] > 0]
#IRT
irt_fit = irt.fa(items2)
## Warning in cor.smooth(mat): Matrix was not positive definite, smoothing was
## done
## The determinant of the smoothed correlation was zero.
## This means the objective function is not defined.
## Chi square is based upon observed residuals.
## The determinant of the smoothed correlation was zero.
## This means the objective function is not defined for the null model either.
## The Chi square is thus based upon observed correlations.
## Warning in fa.stats(r = r, f = f, phi = phi, n.obs = n.obs, np.obs
## = np.obs, : The estimated weights for the factor scores are probably
## incorrect. Try a different factor extraction method.

irt_fit
## Item Response Analysis using Factor Analysis
##
## Call: irt.fa(x = items2)
## Item Response Analysis using Factor Analysis
##
## Summary information by factor and item
## Factor = 1
## -3 -2 -1 0 1 2 3
## VZi01 0.28 0.51 0.36 0.13 0.03 0.01 0.00
## VZi02 0.38 1.03 0.46 0.08 0.01 0.00 0.00
## VZi03 0.13 0.45 0.65 0.29 0.07 0.01 0.00
## VZi04 0.24 0.56 0.45 0.15 0.04 0.01 0.00
## VZi05 0.19 0.72 0.70 0.18 0.03 0.00 0.00
## VZi06 0.19 0.38 0.36 0.17 0.06 0.02 0.00
## VZi07 0.04 0.12 0.27 0.37 0.25 0.10 0.03
## VZi08 0.14 0.47 0.62 0.26 0.06 0.01 0.00
## VZi09 0.14 0.35 0.44 0.25 0.08 0.02 0.01
## VZi10 0.23 0.42 0.35 0.15 0.04 0.01 0.00
## VZi11 0.10 0.46 0.84 0.34 0.07 0.01 0.00
## VZi12 0.18 0.68 0.72 0.20 0.04 0.01 0.00
## VZi13 0.03 0.09 0.19 0.28 0.24 0.13 0.05
## VZi14 0.03 0.09 0.22 0.35 0.28 0.13 0.05
## VZi15 0.10 0.35 0.59 0.34 0.10 0.02 0.00
## VZi16 0.09 0.87 1.41 0.20 0.02 0.00 0.00
## VZi17 0.02 0.15 0.84 0.94 0.19 0.02 0.00
## VZi18 0.07 1.05 1.58 0.14 0.01 0.00 0.00
## VZi19 0.11 1.05 1.28 0.15 0.01 0.00 0.00
## VZi20 0.05 0.14 0.34 0.41 0.23 0.08 0.02
## VZi21 0.04 0.18 0.51 0.55 0.21 0.05 0.01
## VZi22 0.09 0.75 1.34 0.24 0.02 0.00 0.00
## VZi23 0.03 0.16 0.53 0.63 0.23 0.05 0.01
## VZi24 0.07 0.33 0.79 0.46 0.11 0.02 0.00
## VZi25 0.13 1.18 1.16 0.13 0.01 0.00 0.00
## VZi26 0.02 0.17 0.87 0.86 0.17 0.02 0.00
## VZi27 0.02 0.13 0.67 0.94 0.24 0.04 0.00
## VZi28 0.04 0.37 1.28 0.51 0.06 0.01 0.00
## VZi29 0.03 0.18 0.71 0.73 0.19 0.03 0.00
## VZi30 0.03 0.23 1.14 0.75 0.11 0.01 0.00
## CFi01 0.16 0.34 0.38 0.20 0.07 0.02 0.01
## CFi02 0.17 0.33 0.34 0.18 0.07 0.02 0.01
## CFi03 0.15 0.29 0.32 0.20 0.08 0.03 0.01
## CFi04 0.12 0.40 0.59 0.30 0.08 0.02 0.00
## CFi05 0.03 0.16 0.50 0.61 0.24 0.06 0.01
## CFi06 0.07 0.15 0.26 0.27 0.17 0.07 0.03
## CFi07 0.04 0.15 0.40 0.50 0.25 0.07 0.02
## CFi08 0.03 0.16 0.62 0.73 0.22 0.04 0.01
## CFi09 0.19 0.35 0.32 0.16 0.06 0.02 0.01
## CFi10 0.10 0.15 0.17 0.14 0.09 0.05 0.02
## CFi11 0.16 0.25 0.23 0.14 0.06 0.02 0.01
## CFi12 0.04 0.13 0.29 0.38 0.24 0.09 0.03
## CFi13 0.06 0.17 0.35 0.37 0.19 0.07 0.02
## CFi14 0.15 0.26 0.29 0.18 0.08 0.03 0.01
## CFi15 0.06 0.14 0.27 0.30 0.19 0.08 0.03
## CFi16 0.05 0.24 0.71 0.57 0.15 0.03 0.00
## CFi17 0.06 0.20 0.43 0.40 0.18 0.05 0.01
## CFi18 0.10 0.13 0.12 0.09 0.06 0.03 0.02
## CFi19 0.06 0.42 1.10 0.44 0.07 0.01 0.00
## CFi20 0.03 0.13 0.40 0.55 0.28 0.08 0.02
## CFi21 0.07 0.21 0.39 0.35 0.16 0.05 0.02
## CFi22 0.03 0.21 0.89 0.74 0.15 0.02 0.00
## CFi23 0.04 0.17 0.51 0.58 0.22 0.05 0.01
## CFi24 0.05 0.10 0.18 0.22 0.17 0.10 0.05
## CFi25 0.14 0.30 0.36 0.22 0.09 0.03 0.01
## CFi26 0.16 0.38 0.44 0.23 0.07 0.02 0.01
## CFi27 0.07 0.19 0.34 0.31 0.16 0.06 0.02
## CFi28 0.05 0.14 0.28 0.33 0.20 0.08 0.03
## CFi29 0.04 0.13 0.33 0.44 0.25 0.09 0.02
## CFi30 0.05 0.18 0.45 0.47 0.20 0.06 0.01
## CFi31 0.04 0.16 0.43 0.50 0.23 0.06 0.02
## CFi32 0.04 0.13 0.33 0.44 0.26 0.09 0.03
## V1i01 0.08 0.13 0.17 0.15 0.10 0.06 0.03
## V1i05 0.17 0.24 0.21 0.12 0.06 0.02 0.01
## V1i10 0.05 0.10 0.16 0.19 0.15 0.09 0.04
## V1i14 0.15 0.22 0.21 0.13 0.07 0.03 0.01
## V1i15 0.25 0.41 0.31 0.13 0.04 0.01 0.00
## V1i18 0.04 0.05 0.07 0.07 0.07 0.06 0.04
## V2i03 0.05 0.08 0.13 0.15 0.13 0.09 0.05
## V3i01 0.08 0.13 0.18 0.17 0.11 0.06 0.03
## V3i04 0.06 0.08 0.09 0.09 0.07 0.05 0.03
## V3i11 0.05 0.09 0.15 0.18 0.15 0.10 0.05
## V3i12 0.05 0.07 0.09 0.09 0.08 0.06 0.04
## V3i17 0.07 0.20 0.38 0.34 0.16 0.05 0.02
## MA1i02 0.04 0.06 0.08 0.09 0.09 0.07 0.05
## MA1i03 0.04 0.06 0.08 0.09 0.08 0.07 0.05
## MA1i04 0.05 0.07 0.10 0.11 0.10 0.07 0.05
## MA1i05 0.04 0.05 0.07 0.08 0.08 0.06 0.05
## MA1i07 0.04 0.07 0.09 0.10 0.10 0.08 0.05
## MA1i09 0.06 0.10 0.15 0.17 0.13 0.08 0.04
## MA1i11 0.04 0.06 0.08 0.10 0.09 0.08 0.05
## MA1i13 0.06 0.09 0.10 0.10 0.08 0.06 0.04
## MA2i02 0.07 0.11 0.14 0.14 0.11 0.07 0.03
## MA2i03 0.04 0.06 0.09 0.11 0.11 0.08 0.06
## MA2i04 0.05 0.08 0.11 0.12 0.11 0.07 0.05
## MA2i05 0.04 0.07 0.11 0.13 0.12 0.09 0.05
## MA2i06 0.04 0.09 0.15 0.19 0.16 0.10 0.05
## MA2i07 0.05 0.09 0.14 0.16 0.13 0.09 0.05
## MA2i08 0.06 0.09 0.11 0.11 0.09 0.06 0.04
## MA2i09 0.04 0.08 0.11 0.13 0.12 0.09 0.05
## MA2i10 0.05 0.09 0.15 0.18 0.15 0.09 0.05
## MVi01 0.09 0.13 0.15 0.12 0.08 0.04 0.02
## MVi02 0.11 0.26 0.37 0.26 0.11 0.04 0.01
## MVi03 0.09 0.12 0.12 0.10 0.07 0.04 0.02
## MVi04 0.12 0.25 0.33 0.23 0.10 0.04 0.01
## MVi05 0.10 0.23 0.33 0.25 0.12 0.04 0.01
## MVi06 0.06 0.07 0.07 0.06 0.05 0.03 0.02
## MVi07 0.09 0.23 0.38 0.30 0.14 0.05 0.01
## MVi10 0.06 0.08 0.09 0.08 0.06 0.04 0.03
## MVi11 0.10 0.21 0.29 0.23 0.12 0.05 0.02
## MVi12 0.07 0.09 0.10 0.09 0.07 0.05 0.03
## RGi01 0.09 0.16 0.20 0.18 0.11 0.06 0.02
## RGi02 0.10 0.22 0.30 0.23 0.12 0.05 0.02
## RGi03 0.11 0.34 0.53 0.31 0.10 0.02 0.01
## RGi04 0.05 0.08 0.11 0.12 0.10 0.07 0.04
## RGi05 0.05 0.09 0.12 0.14 0.12 0.08 0.05
## RGi06 0.04 0.14 0.42 0.54 0.26 0.07 0.02
## RGi07 0.03 0.09 0.22 0.34 0.27 0.13 0.05
## RGi08 0.05 0.16 0.35 0.39 0.21 0.07 0.02
## RGi09 0.04 0.16 0.51 0.60 0.24 0.06 0.01
## RGi10 0.03 0.07 0.15 0.24 0.25 0.16 0.07
## RGi11 0.02 0.08 0.20 0.36 0.32 0.15 0.05
## RGi12 0.02 0.06 0.13 0.22 0.25 0.17 0.08
## RGi13 0.02 0.03 0.04 0.06 0.07 0.07 0.06
## RGi14 0.03 0.07 0.12 0.17 0.18 0.13 0.07
## RGi15 0.03 0.05 0.08 0.10 0.11 0.10 0.07
## RLi01 0.14 0.24 0.25 0.16 0.08 0.03 0.01
## RLi02 0.17 0.36 0.38 0.19 0.07 0.02 0.01
## RLi03 0.13 0.23 0.26 0.18 0.09 0.03 0.01
## RLi05 0.04 0.05 0.06 0.07 0.07 0.06 0.04
## RLi06 0.13 0.22 0.25 0.17 0.08 0.03 0.01
## RLi07 0.05 0.06 0.07 0.07 0.06 0.05 0.03
## RLi09 0.11 0.19 0.23 0.18 0.10 0.04 0.02
## RLi11 0.06 0.10 0.13 0.14 0.11 0.07 0.04
## RLi15 0.06 0.12 0.19 0.20 0.14 0.08 0.04
## RLi16 0.19 0.28 0.24 0.13 0.05 0.02 0.01
## RLi18 0.11 0.18 0.21 0.16 0.09 0.04 0.02
## RLi19 0.04 0.06 0.07 0.07 0.07 0.05 0.04
## RLi23 0.10 0.17 0.22 0.18 0.10 0.05 0.02
## RLi27 0.10 0.15 0.17 0.14 0.09 0.04 0.02
## RLi28 0.06 0.10 0.13 0.13 0.10 0.07 0.04
## RLi29 0.07 0.18 0.32 0.30 0.16 0.06 0.02
## RLi30 0.06 0.13 0.22 0.25 0.17 0.09 0.04
## Ii01 0.25 0.35 0.25 0.11 0.04 0.01 0.00
## Ii02 0.05 0.06 0.07 0.07 0.06 0.04 0.03
## Ii03 0.08 0.16 0.24 0.23 0.14 0.06 0.03
## Ii04 0.11 0.28 0.40 0.27 0.11 0.03 0.01
## Ii05 0.08 0.17 0.28 0.26 0.15 0.06 0.02
## Ii06 0.08 0.34 0.70 0.40 0.10 0.02 0.00
## Ii07 0.10 0.14 0.15 0.12 0.08 0.04 0.02
## Ii08 0.06 0.15 0.25 0.26 0.17 0.08 0.03
## Ii09 0.07 0.23 0.47 0.41 0.16 0.04 0.01
## Ii10 0.03 0.10 0.25 0.39 0.28 0.12 0.04
## Ii11 0.05 0.08 0.11 0.13 0.12 0.08 0.05
## Ii14 0.03 0.06 0.10 0.13 0.13 0.11 0.07
## Ii15 0.03 0.04 0.06 0.07 0.08 0.07 0.06
## Test Info 12.00 32.06 51.20 37.97 18.07 7.83 3.48
## SEM 0.29 0.18 0.14 0.16 0.24 0.36 0.54
## Reliability 0.92 0.97 0.98 0.97 0.94 0.87 0.71
##
## Factor analysis with Call: fa(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate,
## fm = fm)
##
## Test of the hypothesis that 1 factor is sufficient.
## The degrees of freedom for the model is 20705 and the objective function was 484.8
## The number of observations was 292 with Chi Square = 107222 with prob < 0
##
## The root mean square of the residuals (RMSA) is 0.09
## The df corrected root mean square of the residuals is 0.09
##
## Tucker Lewis Index of factoring reliability = 0.856
## RMSEA index = 0.141 and the 10 % confidence intervals are 0.119 NA
## BIC = -10315
irt_fit$fa
## Factor Analysis using method = minres
## Call: fa(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate,
## fm = fm)
## Standardized loadings (pattern matrix) based upon correlation matrix
## MR1 h2 u2 com
## VZi01 0.64 4.2e-01 0.58 1
## VZi02 0.77 5.9e-01 0.41 1
## VZi03 0.69 4.8e-01 0.52 1
## VZi04 0.67 4.5e-01 0.55 1
## VZi05 0.74 5.5e-01 0.45 1
## VZi06 0.60 3.6e-01 0.64 1
## VZi07 0.58 3.4e-01 0.66 1
## VZi08 0.69 4.7e-01 0.53 1
## VZi09 0.62 3.8e-01 0.62 1
## VZi10 0.61 3.8e-01 0.62 1
## VZi11 0.74 5.4e-01 0.46 1
## VZi12 0.74 5.4e-01 0.46 1
## VZi13 0.53 2.8e-01 0.72 1
## VZi14 0.57 3.3e-01 0.67 1
## VZi15 0.67 4.5e-01 0.55 1
## VZi16 0.84 7.0e-01 0.30 1
## VZi17 0.79 6.2e-01 0.38 1
## VZi18 0.87 7.5e-01 0.25 1
## VZi19 0.84 7.1e-01 0.29 1
## VZi20 0.61 3.7e-01 0.63 1
## VZi21 0.68 4.6e-01 0.54 1
## VZi22 0.82 6.8e-01 0.32 1
## VZi23 0.70 4.9e-01 0.51 1
## VZi24 0.72 5.2e-01 0.48 1
## VZi25 0.84 7.1e-01 0.29 1
## VZi26 0.78 6.1e-01 0.39 1
## VZi27 0.77 5.9e-01 0.41 1
## VZi28 0.80 6.4e-01 0.36 1
## VZi29 0.74 5.5e-01 0.45 1
## VZi30 0.80 6.4e-01 0.36 1
## CFi01 0.60 3.5e-01 0.65 1
## CFi02 0.58 3.3e-01 0.67 1
## CFi03 0.56 3.1e-01 0.69 1
## CFi04 0.67 4.5e-01 0.55 1
## CFi05 0.69 4.8e-01 0.52 1
## CFi06 0.53 2.9e-01 0.71 1
## CFi07 0.65 4.2e-01 0.58 1
## CFi08 0.73 5.3e-01 0.47 1
## CFi09 0.58 3.4e-01 0.66 1
## CFi10 0.44 1.9e-01 0.81 1
## CFi11 0.51 2.6e-01 0.74 1
## CFi12 0.59 3.4e-01 0.66 1
## CFi13 0.60 3.6e-01 0.64 1
## CFi14 0.54 2.9e-01 0.71 1
## CFi15 0.54 3.0e-01 0.70 1
## CFi16 0.72 5.2e-01 0.48 1
## CFi17 0.63 3.9e-01 0.61 1
## CFi18 0.39 1.5e-01 0.85 1
## CFi19 0.78 6.0e-01 0.40 1
## CFi20 0.66 4.4e-01 0.56 1
## CFi21 0.60 3.6e-01 0.64 1
## CFi22 0.77 5.9e-01 0.41 1
## CFi23 0.69 4.7e-01 0.53 1
## CFi24 0.48 2.3e-01 0.77 1
## CFi25 0.58 3.3e-01 0.67 1
## CFi26 0.63 3.9e-01 0.61 1
## CFi27 0.58 3.3e-01 0.67 1
## CFi28 0.56 3.2e-01 0.68 1
## CFi29 0.62 3.8e-01 0.62 1
## CFi30 0.65 4.2e-01 0.58 1
## CFi31 0.65 4.3e-01 0.57 1
## CFi32 0.62 3.8e-01 0.62 1
## V1i01 0.44 1.9e-01 0.81 1
## V1i02 0.13 1.6e-02 0.98 1
## V1i03 0.20 3.8e-02 0.96 1
## V1i04 0.03 6.5e-04 1.00 1
## V1i05 0.50 2.5e-01 0.75 1
## V1i06 0.05 2.3e-03 1.00 1
## V1i07 0.23 5.3e-02 0.95 1
## V1i08 0.25 6.2e-02 0.94 1
## V1i09 0.00 1.2e-05 1.00 1
## V1i10 0.45 2.1e-01 0.79 1
## V1i13 0.01 6.0e-05 1.00 1
## V1i14 0.49 2.4e-01 0.76 1
## V1i15 0.60 3.6e-01 0.64 1
## V1i17 0.29 8.2e-02 0.92 1
## V1i18 0.30 9.1e-02 0.91 1
## V1i19 0.19 3.6e-02 0.96 1
## V1i20 0.18 3.4e-02 0.97 1
## V1i21 0.08 5.7e-03 0.99 1
## V1i22 0.11 1.3e-02 0.99 1
## V1i23 0.22 4.7e-02 0.95 1
## V1i24 0.00 2.7e-06 1.00 1
## V2i02 0.14 1.9e-02 0.98 1
## V2i03 0.41 1.7e-01 0.83 1
## V2i05 0.07 5.2e-03 0.99 1
## V2i06 0.22 5.0e-02 0.95 1
## V2i07 0.16 2.5e-02 0.98 1
## V2i08 0.10 1.0e-02 0.99 1
## V2i09 0.25 6.3e-02 0.94 1
## V2i11 0.22 4.8e-02 0.95 1
## V2i12 0.21 4.3e-02 0.96 1
## V2i14 0.20 4.1e-02 0.96 1
## V2i15 0.04 1.9e-03 1.00 1
## V2i16 0.01 1.4e-04 1.00 1
## V2i18 0.23 5.2e-02 0.95 1
## V3i01 0.45 2.0e-01 0.80 1
## V3i02 0.22 4.7e-02 0.95 1
## V3i03 0.19 3.5e-02 0.97 1
## V3i04 0.34 1.2e-01 0.88 1
## V3i05 0.16 2.5e-02 0.97 1
## V3i06 0.09 8.4e-03 0.99 1
## V3i07 0.13 1.6e-02 0.98 1
## V3i08 0.03 9.0e-04 1.00 1
## V3i10 0.18 3.4e-02 0.97 1
## V3i11 0.45 2.0e-01 0.80 1
## V3i12 0.34 1.1e-01 0.89 1
## V3i15 0.12 1.5e-02 0.99 1
## V3i16 0.24 5.6e-02 0.94 1
## V3i17 0.60 3.5e-01 0.65 1
## V3i18 0.16 2.4e-02 0.98 1
## MA1i01 0.20 4.2e-02 0.96 1
## MA1i02 0.34 1.2e-01 0.88 1
## MA1i03 0.33 1.1e-01 0.89 1
## MA1i04 0.36 1.3e-01 0.87 1
## MA1i05 0.31 9.7e-02 0.90 1
## MA1i06 0.27 7.4e-02 0.93 1
## MA1i07 0.36 1.3e-01 0.87 1
## MA1i08 0.19 3.7e-02 0.96 1
## MA1i09 0.44 1.9e-01 0.81 1
## MA1i10 0.28 7.9e-02 0.92 1
## MA1i11 0.34 1.2e-01 0.88 1
## MA1i12 0.23 5.5e-02 0.94 1
## MA1i13 0.36 1.3e-01 0.87 1
## MA1i14 0.23 5.2e-02 0.95 1
## MA1i15 0.20 4.1e-02 0.96 1
## MA2i01 0.18 3.4e-02 0.97 1
## MA2i02 0.41 1.7e-01 0.83 1
## MA2i03 0.37 1.4e-01 0.86 1
## MA2i04 0.38 1.4e-01 0.86 1
## MA2i05 0.39 1.5e-01 0.85 1
## MA2i06 0.45 2.0e-01 0.80 1
## MA2i07 0.42 1.8e-01 0.82 1
## MA2i08 0.36 1.3e-01 0.87 1
## MA2i09 0.39 1.5e-01 0.85 1
## MA2i10 0.44 2.0e-01 0.80 1
## MVi01 0.41 1.7e-01 0.83 1
## MVi02 0.58 3.4e-01 0.66 1
## MVi03 0.38 1.5e-01 0.85 1
## MVi04 0.56 3.2e-01 0.68 1
## MVi05 0.56 3.1e-01 0.69 1
## MVi06 0.29 8.4e-02 0.92 1
## MVi07 0.59 3.5e-01 0.65 1
## MVi08 0.10 1.1e-02 0.99 1
## MVi09 0.28 7.9e-02 0.92 1
## MVi10 0.33 1.1e-01 0.89 1
## MVi11 0.54 2.9e-01 0.71 1
## MVi12 0.35 1.2e-01 0.88 1
## RGi01 0.47 2.2e-01 0.78 1
## RGi02 0.54 2.9e-01 0.71 1
## RGi03 0.65 4.2e-01 0.58 1
## RGi04 0.37 1.4e-01 0.86 1
## RGi05 0.40 1.6e-01 0.84 1
## RGi06 0.66 4.4e-01 0.56 1
## RGi07 0.57 3.2e-01 0.68 1
## RGi08 0.60 3.6e-01 0.64 1
## RGi09 0.69 4.7e-01 0.53 1
## RGi10 0.51 2.6e-01 0.74 1
## RGi11 0.58 3.4e-01 0.66 1
## RGi12 0.51 2.6e-01 0.74 1
## RGi13 0.30 8.7e-02 0.91 1
## RGi14 0.45 2.0e-01 0.80 1
## RGi15 0.37 1.4e-01 0.86 1
## RLi01 0.52 2.7e-01 0.73 1
## RLi02 0.60 3.6e-01 0.64 1
## RLi03 0.52 2.7e-01 0.73 1
## RLi04 0.23 5.5e-02 0.95 1
## RLi05 0.30 8.9e-02 0.91 1
## RLi06 0.51 2.6e-01 0.74 1
## RLi07 0.30 8.7e-02 0.91 1
## RLi08 0.13 1.8e-02 0.98 1
## RLi09 0.49 2.4e-01 0.76 1
## RLi10 0.11 1.2e-02 0.99 1
## RLi11 0.41 1.6e-01 0.84 1
## RLi12 0.22 4.6e-02 0.95 1
## RLi13 0.05 2.2e-03 1.00 1
## RLi14 0.02 2.5e-04 1.00 1
## RLi15 0.47 2.2e-01 0.78 1
## RLi16 0.53 2.8e-01 0.72 1
## RLi18 0.47 2.2e-01 0.78 1
## RLi19 0.30 9.3e-02 0.91 1
## RLi21 0.28 7.9e-02 0.92 1
## RLi22 0.19 3.7e-02 0.96 1
## RLi23 0.48 2.3e-01 0.77 1
## RLi24 0.09 7.8e-03 0.99 1
## RLi26 0.04 1.6e-03 1.00 1
## RLi27 0.44 1.9e-01 0.81 1
## RLi28 0.40 1.6e-01 0.84 1
## RLi29 0.56 3.1e-01 0.69 1
## RLi30 0.51 2.6e-01 0.74 1
## Ii01 0.57 3.3e-01 0.67 1
## Ii02 0.30 8.7e-02 0.91 1
## Ii03 0.51 2.6e-01 0.74 1
## Ii04 0.60 3.6e-01 0.64 1
## Ii05 0.54 2.9e-01 0.71 1
## Ii06 0.70 4.9e-01 0.51 1
## Ii07 0.41 1.7e-01 0.83 1
## Ii08 0.52 2.7e-01 0.73 1
## Ii09 0.64 4.1e-01 0.59 1
## Ii10 0.59 3.5e-01 0.65 1
## Ii11 0.39 1.5e-01 0.85 1
## Ii12 0.25 6.3e-02 0.94 1
## Ii13 0.26 7.0e-02 0.93 1
## Ii14 0.40 1.6e-01 0.84 1
## Ii15 0.31 9.6e-02 0.90 1
##
## MR1
## SS loadings 47.96
## Proportion Var 0.23
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 20910 and the objective function was 2844 with Chi Square of 630856
## The degrees of freedom for the model are 20705 and the objective function was 484.8
##
## The root mean square of the residuals (RMSR) is 0.09
## The df corrected root mean square of the residuals is 0.09
##
## The harmonic number of observations is 292 with the empirical chi square 104330 with prob < 0
## The total number of observations was 292 with Likelihood Chi Square = 107222 with prob < 0
##
## Tucker Lewis Index of factoring reliability = 0.856
## RMSEA index = 0.141 and the 90 % confidence intervals are 0.119 NA
## BIC = -10315
## Fit based upon off diagonal values = 0.86
#negative loadings?
sum(irt_fit$fa$loadings[, 1] < 0) #good!
## [1] 0
#score
irt_fit$scores = scoreIrt(irt_fit, items2)
bafacalo$g_irt = irt_fit$scores$theta1 %>% standardize()
Test level factor analysis
#their tests
tests = bafacalo %>% select(N:FF) %>% map_df(as.numeric)
#all tests
item_stats$test %>% unique()
## [1] "VZi" "CFi" "V1i" "V2i" "V3i" "MA1i" "MA2i" "MVi" "RGi" "RLi"
## [11] "Ii"
tests2 = map(item_stats$test %>% unique(), function(x) {
rowSums(items[str_detect(names(items), str_glue("^{x}\\d+"))])
}) %>% set_names(item_stats$test %>% unique()) %>% as.data.frame()
#factor analyze
#their tests
fa_fit = fa(tests)
fa_fit
## Factor Analysis using method = minres
## Call: fa(r = tests)
## Standardized loadings (pattern matrix) based upon correlation matrix
## MR1 h2 u2 com
## N 0.62 0.380 0.62 1
## P1 0.36 0.132 0.87 1
## P2 0.58 0.332 0.67 1
## P3 0.59 0.344 0.66 1
## FI1 0.50 0.248 0.75 1
## FI2 0.54 0.295 0.70 1
## FF 0.16 0.026 0.97 1
##
## MR1
## SS loadings 1.76
## Proportion Var 0.25
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 21 and the objective function was 1.29 with Chi Square of 371.7
## The degrees of freedom for the model are 14 and the objective function was 0.46
##
## The root mean square of the residuals (RMSR) is 0.13
## The df corrected root mean square of the residuals is 0.15
##
## The harmonic number of observations is 230 with the empirical chi square 152.3 with prob < 2.5e-25
## The total number of observations was 292 with Likelihood Chi Square = 130.9 with prob < 4.4e-21
##
## Tucker Lewis Index of factoring reliability = 0.499
## RMSEA index = 0.171 and the 90 % confidence intervals are 0.144 0.197
## BIC = 51.46
## Fit based upon off diagonal values = 0.79
## Measures of factor score adequacy
## MR1
## Correlation of (regression) scores with factors 0.85
## Multiple R square of scores with factors 0.72
## Minimum correlation of possible factor scores 0.44
#all tests
fa_fit2 = fa(tests2)
fa_fit2
## Factor Analysis using method = minres
## Call: fa(r = tests2)
## Standardized loadings (pattern matrix) based upon correlation matrix
## MR1 h2 u2 com
## VZi 0.76 0.579 0.42 1
## CFi 0.68 0.457 0.54 1
## V1i 0.41 0.170 0.83 1
## V2i 0.28 0.079 0.92 1
## V3i 0.45 0.199 0.80 1
## MA1i 0.52 0.269 0.73 1
## MA2i 0.60 0.363 0.64 1
## MVi 0.62 0.379 0.62 1
## RGi 0.73 0.527 0.47 1
## RLi 0.68 0.466 0.53 1
## Ii 0.69 0.470 0.53 1
##
## MR1
## SS loadings 3.96
## Proportion Var 0.36
##
## Mean item complexity = 1
## Test of the hypothesis that 1 factor is sufficient.
##
## The degrees of freedom for the null model are 55 and the objective function was 4.64 with Chi Square of 1330
## The degrees of freedom for the model are 44 and the objective function was 1.49
##
## The root mean square of the residuals (RMSR) is 0.12
## The df corrected root mean square of the residuals is 0.13
##
## The harmonic number of observations is 292 with the empirical chi square 447 with prob < 3.9e-68
## The total number of observations was 292 with Likelihood Chi Square = 426.2 with prob < 4.9e-64
##
## Tucker Lewis Index of factoring reliability = 0.624
## RMSEA index = 0.175 and the 90 % confidence intervals are 0.158 0.188
## BIC = 176.4
## Fit based upon off diagonal values = 0.9
## Measures of factor score adequacy
## MR1
## Correlation of (regression) scores with factors 0.94
## Multiple R square of scores with factors 0.88
## Minimum correlation of possible factor scores 0.75
#scores
bafacalo$g_tests1 = fa_fit$scores[, 1] %>% standardize()
bafacalo$g_tests2 = fa_fit2$scores[, 1] %>% standardize()
Relations to outcomes: simple
#scores
bafacalo %>% select(g_irt, g_tests1, g_tests2) %>% wtd.cors()
## g_irt g_tests1 g_tests2
## g_irt 1.0000 0.5388 0.9360
## g_tests1 0.5388 1.0000 0.6045
## g_tests2 0.9360 0.6045 1.0000
#plot IRT and FA scores
GG_scatter(bafacalo, "g_irt", "g_tests2")

#correlations with outcomes
bafacalo %>% select(g_irt, g_tests2, scholarity_father, scholarity_mother, portuguese:history) %>% wtd.cors() %>% .[1:2, -c(1:2)]
## scholarity_father scholarity_mother portuguese english math
## g_irt 0.3750 0.4283 0.4146 0.3651 0.4095
## g_tests2 0.3753 0.3931 0.5159 0.4888 0.5110
## biology physics chimestry geography history
## g_irt 0.3493 0.3794 0.3715 0.2181 0.1959
## g_tests2 0.4505 0.4714 0.4766 0.3887 0.3363
Relations to achievement: SEM
#datset for SEM
d2 = cbind(tests2, bafacalo %>% select(portuguese:history)) %>% map_df(as.numeric)
d2$sex = bafacalo$sex %>% factor() %>% as.numeric()
d2 %>% miss_amount()
## cases with missing data vars with missing data cells with missing data
## 1.000 0.450 0.138
d2 %>% miss_by_var(prop = T)
## VZi CFi V1i V2i V3i MA1i
## 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
## MA2i MVi RGi RLi Ii portuguese
## 0.0000 0.0000 0.0000 0.0000 0.0000 0.2192
## english math biology physics chimestry geography
## 0.2226 0.2192 0.2192 0.2260 0.2192 0.5959
## history sex
## 0.6267 0.2123
#latent variables: replication of Deary
model1 = "
achievement =~ portuguese + portuguese + english + math + biology + physics + chimestry + geography + history
g =~ VZi + CFi + V1i + V2i + V3i + MA1i + MA2i + MVi + RGi + RLi + Ii
achievement ~ g"
#fit SEM
sem_fit1 = sem(model1, data = d2, missing = "FIML", std.ov = T)
## Warning in lav_data_full(data = data, group = group, cluster = cluster, :
## lavaan WARNING: due to missing values, some pairwise combinations have less
## than 10% coverage
#params
sem_fit1 %>% parameterestimates(standardized = T)
#plot version
lavaanPlot(model = sem_fit1, coefs = TRUE, covs = T, digits = 3, stand = T)
#single g model
model2 = "
g =~ VZi + CFi + V1i + V2i + V3i + MA1i + MA2i + MVi + RGi + RLi + Ii + portuguese + portuguese + english + math + biology + physics + chimestry + geography + history"
#fit SEM
sem_fit2 = sem(model2, data = d2, missing = "FIML", std.ov = T)
## Warning in lav_data_full(data = data, group = group, cluster = cluster, :
## lavaan WARNING: due to missing values, some pairwise combinations have less
## than 10% coverage
#params
sem_fit2 %>% parameterestimates(standardized = T)
#plot version
lavaanPlot(model = sem_fit2, coefs = TRUE, covs = T, digits = 3, stand = T)
#model fits
fitMeasures(sem_fit1)
## npar fmin chisq
## 58.000 1.114 650.286
## df pvalue cfi
## 151.000 0.000 NA
## tli nnfi rfi
## NA NA NA
## nfi pnfi ifi
## NA NA NA
## rni logl unrestricted.logl
## NA -5711.103 -5385.960
## aic bic ntotal
## 11538.205 11751.457 292.000
## bic2 rmsea rmsea.ci.lower
## 11567.526 0.106 0.098
## rmsea.ci.upper rmsea.pvalue rmr
## 0.115 0.000 0.099
## rmr_nomean srmr srmr_bentler
## 0.103 0.092 0.092
## srmr_bentler_nomean crmr crmr_nomean
## 0.096 0.093 0.097
## srmr_mplus srmr_mplus_nomean cn_05
## 0.089 0.093 82.129
## cn_01 gfi agfi
## 88.266 NA NA
## pgfi mfi ecvi
## NA 0.425 2.624
fitMeasures(sem_fit2)
## npar fmin chisq
## 57.000 1.471 859.175
## df pvalue cfi
## 152.000 0.000 NA
## tli nnfi rfi
## NA NA NA
## nfi pnfi ifi
## NA NA NA
## rni logl unrestricted.logl
## NA -5815.547 -5385.960
## aic bic ntotal
## 11745.094 11954.669 292.000
## bic2 rmsea rmsea.ci.lower
## 11773.909 0.126 0.118
## rmsea.ci.upper rmsea.pvalue rmr
## 0.135 0.000 0.334
## rmr_nomean srmr srmr_bentler
## 0.347 0.282 0.282
## srmr_bentler_nomean crmr crmr_nomean
## 0.292 0.128 0.131
## srmr_mplus srmr_mplus_nomean cn_05
## 0.163 0.168 62.777
## cn_01 gfi agfi
## 67.435 NA NA
## pgfi mfi ecvi
## NA 0.298 3.333
anova(sem_fit1, sem_fit2)
cbind(g = inspect(sem_fit2, 'fit.measures'),
g_ach = inspect(sem_fit1, 'fit.measures')
)
## g g_ach
## npar 5.700e+01 5.800e+01
## fmin 1.471e+00 1.114e+00
## chisq 8.592e+02 6.503e+02
## df 1.520e+02 1.510e+02
## pvalue 0.000e+00 0.000e+00
## cfi NA NA
## tli NA NA
## nnfi NA NA
## rfi NA NA
## nfi NA NA
## pnfi NA NA
## ifi NA NA
## rni NA NA
## logl -5.816e+03 -5.711e+03
## unrestricted.logl -5.386e+03 -5.386e+03
## aic 1.175e+04 1.154e+04
## bic 1.195e+04 1.175e+04
## ntotal 2.920e+02 2.920e+02
## bic2 1.177e+04 1.157e+04
## rmsea 1.262e-01 1.064e-01
## rmsea.ci.lower 1.181e-01 9.808e-02
## rmsea.ci.upper 1.345e-01 1.149e-01
## rmsea.pvalue 4.297e-14 2.087e-14
## rmr 3.344e-01 9.892e-02
## rmr_nomean 3.469e-01 1.033e-01
## srmr 2.823e-01 9.151e-02
## srmr_bentler 2.823e-01 9.151e-02
## srmr_bentler_nomean 2.925e-01 9.561e-02
## crmr 1.279e-01 9.276e-02
## crmr_nomean 1.314e-01 9.748e-02
## srmr_mplus 1.626e-01 8.902e-02
## srmr_mplus_nomean 1.682e-01 9.309e-02
## cn_05 6.278e+01 8.213e+01
## cn_01 6.743e+01 8.827e+01
## gfi NA NA
## agfi NA NA
## pgfi NA NA
## mfi 2.979e-01 4.253e-01
## ecvi 3.333e+00 2.624e+00
Sex difference
#g scores
bafacalo %>% GG_denhist("g_tests2", "sex")
## Warning in GG_denhist(., "g_tests2", "sex"): Grouping variable contained
## missing values. These were removed. If you want an NA group, convert to
## explicit value.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

effsize::cohen.d(bafacalo$g_tests2, bafacalo$sex, na.rm = T)
##
## Cohen's d
##
## d estimate: -0.3227 (small)
## 95 percent confidence interval:
## lower upper
## -0.58488 -0.06055
#SEM
model3 = "
achievement =~ portuguese + portuguese + english + math + biology + physics + chimestry + geography + history
g =~ VZi + CFi + V1i + V2i + V3i + MA1i + MA2i + MVi + RGi + RLi + Ii
achievement ~~ g
g ~ sex
achievement ~ sex"
#fit SEM
sem_fit3 = sem(model3, data = d2, missing = "FIML", std.ov = T)
## Warning in lav_data_full(data = data, group = group, cluster = cluster, : lavaan WARNING: 62 cases were deleted due to missing values in
## exogenous variable(s), while fixed.x = TRUE.
## Warning in lav_data_full(data = data, group = group, cluster = cluster, :
## lavaan WARNING: due to missing values, some pairwise combinations have less
## than 10% coverage
#params
sem_fit3 %>% parameterestimates(standardized = T)
#plot version
lavaanPlot(model = sem_fit3, coefs = TRUE, covs = T, digits = 3, stand = T)
#fits
fitMeasures(sem_fit3)
## npar fmin chisq
## 60.000 1.144 526.195
## df pvalue cfi
## 168.000 0.000 NA
## tli nnfi rfi
## NA NA NA
## nfi pnfi ifi
## NA NA NA
## rni logl unrestricted.logl
## NA -5008.999 -4745.901
## aic bic ntotal
## 10137.997 10344.282 230.000
## bic2 rmsea rmsea.ci.lower
## 10154.118 0.096 0.087
## rmsea.ci.upper rmsea.pvalue rmr
## 0.106 0.000 0.079
## rmr_nomean srmr srmr_bentler
## 0.083 0.079 0.079
## srmr_bentler_nomean crmr crmr_nomean
## 0.083 0.083 0.087
## srmr_mplus srmr_mplus_nomean cn_05
## 0.079 0.083 88.090
## cn_01 gfi agfi
## 94.346 NA NA
## pgfi mfi ecvi
## NA 0.459 2.810