Skip to content

Commit a8f584a

Browse files
committed
tests
1 parent 0c281b1 commit a8f584a

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

tests/testthat/_snaps/factor_analysis.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,87 @@
4242
|MR1 | 1.000 | -0.366 |
4343
|MR2 | -0.366 | 1.000 |
4444

45+
# omega
46+
47+
Code
48+
print(out)
49+
Output
50+
# Rotated loadings from Omega (oblimin-rotation)
51+
52+
Variable | g | F1* | F2* | F3* | h2 | u2 | p2 | Complexity
53+
----------------------------------------------------------------------------------------
54+
mpg- | 0.58 | -0.67 | 0.09 | 0.29 | 0.88 | 0.12 | 0.38 | 2.40
55+
cyl | 0.70 | -0.61 | 0.28 | 0.07 | 0.96 | 0.04 | 0.52 | 2.33
56+
disp | 0.59 | -0.71 | 0.18 | 0.11 | 0.89 | 0.11 | 0.39 | 2.13
57+
hp | 0.77 | -0.31 | 0.23 | 0.36 | 0.87 | 0.13 | 0.68 | 2.00
58+
drat- | 0.27 | -0.79 | 0.06 | -0.07 | 0.71 | 0.29 | 0.10 | 1.26
59+
wt | 0.43 | -0.79 | -0.04 | 0.31 | 0.91 | 0.09 | 0.20 | 1.87
60+
qsec- | 0.81 | 0.19 | 0.50 | 0.06 | 0.95 | 0.05 | 0.70 | 1.81
61+
vs- | 0.74 | -0.27 | 0.38 | 0.05 | 0.77 | 0.23 | 0.71 | 1.81
62+
am- | 8.38e-03 | -0.89 | -0.15 | -9.51e-03 | 0.81 | 0.19 | 8.63e-05 | 1.06
63+
gear | 0.03 | 0.87 | 9.01e-03 | 0.32 | 0.87 | 0.13 | 9.03e-04 | 1.27
64+
carb | 0.68 | 0.06 | 0.10 | 0.63 | 0.87 | 0.13 | 0.53 | 2.06
65+
66+
---
67+
68+
Code
69+
print_md(out)
70+
Output
71+
72+
73+
Table: Rotated loadings from Omega (oblimin-rotation)
74+
75+
|Variable | g| F1* | F2*| F3*| h2 | u2 | p2| Complexity|
76+
|:--------|--------:|:-----|--------:|---------:|:----|:----|--------:|----------:|
77+
|mpg- | 0.58|-0.67 | 0.09| 0.29|0.88 |0.12 | 0.38| 2.40|
78+
|cyl | 0.70|-0.61 | 0.28| 0.07|0.96 |0.04 | 0.52| 2.33|
79+
|disp | 0.59|-0.71 | 0.18| 0.11|0.89 |0.11 | 0.39| 2.13|
80+
|hp | 0.77|-0.31 | 0.23| 0.36|0.87 |0.13 | 0.68| 2.00|
81+
|drat- | 0.27|-0.79 | 0.06| -0.07|0.71 |0.29 | 0.10| 1.26|
82+
|wt | 0.43|-0.79 | -0.04| 0.31|0.91 |0.09 | 0.20| 1.87|
83+
|qsec- | 0.81| 0.19 | 0.50| 0.06|0.95 |0.05 | 0.70| 1.81|
84+
|vs- | 0.74|-0.27 | 0.38| 0.05|0.77 |0.23 | 0.71| 1.81|
85+
|am- | 8.38e-03|-0.89 | -0.15| -9.51e-03|0.81 |0.19 | 8.63e-05| 1.06|
86+
|gear | 0.03| 0.87 | 9.01e-03| 0.32|0.87 |0.13 | 9.03e-04| 1.27|
87+
|carb | 0.68| 0.06 | 0.10| 0.63|0.87 |0.13 | 0.53| 2.06|
88+
89+
---
90+
91+
Code
92+
print(summary(out))
93+
Output
94+
# Omega Statistics
95+
96+
Statistic | Coefficient
97+
----------------------------------
98+
Alpha | 0.88
99+
G.6 | 0.97
100+
Omega (hierachical) | 0.57
101+
Omega (asymptotic H) | 0.58
102+
Omega (total) | 0.97
103+
104+
# Omega Coefficients
105+
106+
Composite | Omega (total) | Omega (hierarchical) | Omega (group)
107+
----------------------------------------------------------------
108+
g | 0.97 | 0.57 | 0.26
109+
F1* | 0.90 | 0.31 | 0.59
110+
F2* | 0.91 | 0.69 | 0.22
111+
F3* | 0.87 | 0.60 | 0.28
112+
113+
# Variances
114+
115+
Composite | Total (%) | General Factor (%) | Group Factor (%)
116+
-------------------------------------------------------------
117+
g | 97.28 | 56.64 | 26.42
118+
F1* | 90.12 | 31.07 | 59.05
119+
F2* | 91.37 | 69.32 | 22.04
120+
F3* | 87.36 | 59.65 | 27.71
121+
122+
---
123+
124+
Code
125+
print_md(summary(out))
126+
Output
127+
Table: Omega Statistics |Statistic | Coefficient| |:--------------------|-----------:| |Alpha | 0.88| |G.6 | 0.97| |Omega (hierachical) | 0.57| |Omega (asymptotic H) | 0.58| |Omega (total) | 0.97| Table: Omega Coefficients |Composite | Omega (total)| Omega (hierarchical)| Omega (group)| |:---------|-------------:|--------------------:|-------------:| |g | 0.97| 0.57| 0.26| |F1* | 0.90| 0.31| 0.59| |F2* | 0.91| 0.69| 0.22| |F3* | 0.87| 0.60| 0.28| Table: Variances |Composite | Total (%)| General Factor (%)| Group Factor (%)| |:---------|---------:|------------------:|----------------:| |g | 97.28| 56.64| 26.42| |F1* | 90.12| 31.07| 59.05| |F2* | 91.37| 69.32| 22.04| |F3* | 87.36| 59.65| 27.71|
128+

tests/testthat/test-factor_analysis.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,18 @@ test_that("factor_analysis", {
5050
fc <- factor_scores(out)
5151
expect_identical(dim(fc), c(32L, 2L))
5252
})
53+
54+
55+
test_that("omega", {
56+
skip_on_cran()
57+
skip_if_not_installed("GPArotation")
58+
skip_if_not_installed("psych")
59+
60+
model <- psych::omega(mtcars, nfactors = 3, plot = FALSE)
61+
out <- model_parameters(model)
62+
expect_snapshot(print(out))
63+
expect_snapshot(print_md(out))
64+
65+
expect_snapshot(print(summary(out)))
66+
expect_snapshot(print_md(summary(out)))
67+
})

0 commit comments

Comments
 (0)