tmatta / lsasim

Simulate large scale assessment data
6 stars 5 forks source link

c_mean, sigma #13

Closed wleoncio closed 3 years ago

wleoncio commented 3 years ago

0. Setup

I've tested most values below. Not all testings are shown in this report. I only included the testings that are showing errors/warnings or inconsistent results.

set.seed(12334)
n1 <- c(3, 6)
n2 <- c(groups = 4, people = 2)
n3 <- c(school = 3, class = 2, student = 5)
n4 <- c(20, 50)
n5 <- list(school = 3, class = c(2, 1, 3), student = c(20, 20, 10, 30, 30, 30))
n5a <- list(school = 3, class = c(2, 3, 3), student = c(20, 20, 10, 30, 30, 30))
n6 <- list(school = 3, class = c(2, 1, 3), student = ranges(10, 50))
n6a <- list(school = 3, class = c(2, 3, 3), student = ranges(10, 50))
n7 <- list(school = 10, student = ranges(10, 50))
n8 <- list(school = 3, student = c(20, 20, 10))
n8a <- list(school = 3, class = c(2, 2, 2),student = c(20, 20, 10))
n8b <- list(school = 3, class = c(2, 3, 3),student = c(20, 20, 10, 5))
n8c <- list(school = 3, class = c(2, 1, 3),student = c(20, 20, 10))
n9 <- list(school = 10, class = c(2,1,3,1,1,1,2,1,2,1), student = ranges(10, 50))
n10 <- list(country = 2, school = 10, class = c(2,1,3,1,1,1,2,1,2,1), student = ranges(10, 50))
n11 <- list(culture = 2, country = 2, school = 10, class = c(2,1,3,1,1,1,2,1,2,1), student = ranges(10, 50))
n12 <- list(culture = 2, country = 2, district = 3, school = 10, class = c(2,1,3,1,1,1,2,1,2,1), student = ranges(10, 50))
N1 <- c(100, 20)
cluster_gen_2 <- function(...) {
  cluster_gen(..., verbose = FALSE, calc_weights = FALSE)
}

3. c_mean, sigma

Overall suggestions

Error and warning messages

This warning message is due to the lack of sample size. It showed error but could still run.

initial correlation inadmissible, -1.00337997759108, set to -0.9999could not compute polyserial correlation between variables 2 and 1 Message: Error in optim(rho, f, control = control, hessian = TRUE, method = "BFGS") : initial value in 'vmmin' is not finite

data1 <- cluster_gen_2(n3, n_X = c(1, 2), c_mean = list(10, c(-100, 1e3)))
#Why
data2 <- cluster_gen_2(n3, n_X = c(1, 2), sigma = list(.1, c(1, 2)))
summarize_clusters(data1)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1         q2      q3      q4      q5      q6      q7      q8
##  Min.   : 9.530   1:2     2:1     1:4     1:4     1:1     1:2     3:3
##  Mean   :10.071   2:3     3:3     2:2     2:1     2:4     4:2     1:3
##  Max.   :11.021   3:1     1:2             4:1     4:1     2:1
##                                   Prop.                   5:1     Prop.
##  Stddev.: 0.67    Prop.   Prop.   1:0.667 Prop.   Prop.           3:0.5
##                   1:0.333 2:0.167 2:0.333 1:0.667 1:0.167 Prop.   1:0.5
##                   2:0.5   3:0.5           2:0.167 2:0.667 1:0.333
##                   3:0.167 1:0.333         4:0.167 4:0.167 4:0.333
##                                                           2:0.167
##                                                           5:0.167
##
##
##
##  Heterogeneous correlation matrix
## Warning in polyserial(y, x, ML = ML, std.err = std.err, bins = bins): initial correlation inadmissible,
## -1.00337997759108, set to -0.9999
## Warning in hetcor.data.frame(df): could not compute polyserial correlation between variables 2 and 1
##     Message: Error in optim(rho, f, control = control, hessian = TRUE, method = "BFGS") :
##   initial value in 'vmmin' is not finite
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 5 and 2
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 6 and 2
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 6 and 5
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 7 and 4
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in polychor(x, y, ML = ML, std.err = std.err): inadmissible correlation set to 0.9999
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 8 and 7
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
##              q1         q2         q3         q4            q5         q6            q7           q8
## q1  1.000000000         NA -0.2628742  0.3984393 -8.519260e-01 -0.8117027  2.613426e-01 -0.003625505
## q2           NA  1.0000000  0.5015574 -0.5147022            NA         NA -1.399734e-01  0.337972985
## q3 -0.262874216  0.5015574  1.0000000 -0.2756888  1.031634e-01  0.5724863 -3.305985e-01  0.337972985
## q4  0.398439265 -0.5147022 -0.2756888  1.0000000 -9.834653e-01  0.0000000            NA  0.999900000
## q5 -0.851925990         NA  0.1031634 -0.9834653  1.000000e+00         NA -2.205898e-08  0.264213509
## q6 -0.811702739         NA  0.5724863  0.0000000            NA  1.0000000  4.353897e-01  0.985006603
## q7  0.261342585 -0.1399734 -0.3305985         NA -2.205898e-08  0.4353897  1.000000e+00           NA
## q8 -0.003625505  0.3379730  0.3379730  0.9999000  2.642135e-01  0.9850066            NA  1.000000000
## Summary statistics for all classes
##        q1                q2         q3      q4      q5
##  Min.   :-101.66   Min.   : 997.3   1: 9    1:14    2: 4
##  Mean   : -99.97   Mean   : 999.7   3:14    3: 9    4: 8
##  Max.   : -98.28   Max.   :1001.4   2: 7    2: 7    1:14
##                                                     3: 4
##  Stddev.: 0.79     Stddev.: 0.92    Prop.   Prop.
##                                     1:0.3   1:0.467 Prop.
##                                     3:0.467 3:0.3   2:0.133
##                                     2:0.233 2:0.233 4:0.267
##                                                     1:0.467
##                                                     3:0.133
##
##
##
##  Heterogeneous correlation matrix
##             q1          q2          q3          q4          q5
## q1  1.00000000  0.09876057 -0.53034760 -0.53453627 -0.07309759
## q2  0.09876057  1.00000000 -0.15388369 -0.05670148  0.15212506
## q3 -0.53034760 -0.15388369  1.00000000  0.32701734  0.01120183
## q4 -0.53453627 -0.05670148  0.32701734  1.00000000  0.03126020
## q5 -0.07309759  0.15212506  0.01120183  0.03126020  1.00000000
summarize_clusters(data2)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1           q2      q3      q4
##  Min.   :-0.24353   1:1     1:2     4:5
##  Mean   :-0.02103   4:4     2:4     2:1
##  Max.   : 0.16006   3:1
##                             Prop.   Prop.
##  Stddev.: 0.14      Prop.   1:0.333 4:0.833
##                     1:0.167 2:0.667 2:0.167
##                     4:0.667
##                     3:0.167
##
##
##
##  Heterogeneous correlation matrix
## Warning in hetcor.data.frame(df): the correlation matrix has been adjusted to make it positive-definite
##            q1        q2        q3         q4
## q1  1.0000000 0.6708654 0.3753219 -0.2351705
## q2  0.6708654 1.0000000 0.7777819  0.1467740
## q3  0.3753219 0.7777819 1.0000000  0.7286670
## q4 -0.2351705 0.1467740 0.7286670  1.0000000
## Summary statistics for all classes
##        q1                 q2          q3      q4
##  Min.   :-1.74747   Min.   :-5.2782   2:10    1:11
##  Mean   : 0.11236   Mean   : 0.6333   3:11    2: 9
##  Max.   : 2.21901   Max.   : 5.7099   1: 9    3:10
##
##  Stddev.: 1.15      Stddev.: 2.26     Prop.   Prop.
##                                       2:0.333 1:0.367
##                                       3:0.367 2:0.3
##                                       1:0.3   3:0.333
##
##
##
##  Heterogeneous correlation matrix
##            q1         q2         q3         q4
## q1  1.0000000  0.1142556  0.1093630 -0.1506773
## q2  0.1142556  1.0000000 -0.2929213  0.1017046
## q3  0.1093630 -0.2929213  1.0000000 -0.2442169
## q4 -0.1506773  0.1017046 -0.2442169  1.0000000
#Additional Testing-c_mean
dat4 <- cluster_gen_2(n4, n_X = 3, c_mean = c(0.0005, 0.0006, 0.0008))
summarize_clusters(dat4)  # q1-q3: 0.004718   , -0.010147   , -0.02808
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1                  q2                  q3           q4      q5      q6      q7
##  Min.   :-3.088879   Min.   :-3.016072   Min.   :-3.18898   1:370   1:327   1:274   1:306
##  Mean   :-0.035664   Mean   : 0.006485   Mean   :-0.03584   2:307   2:278   2:158   2:244
##  Max.   : 3.223561   Max.   : 3.444820   Max.   : 3.11225   3:323   3:395   3:197   3:193
##                                                                             4:125   4:257
##  Stddev.: 1.03       Stddev.: 0.96       Stddev.: 0.97      Prop.   Prop.   5:246
##                                                             1:0.37  1:0.327         Prop.
##                                                             2:0.307 2:0.278 Prop.   1:0.306
##                                                             3:0.323 3:0.395 1:0.274 2:0.244
##                                                                             2:0.158 3:0.193
##                                                                             3:0.197 4:0.257
##                                                                             4:0.125
##                                                                             5:0.246
##
##
##
##  Heterogeneous correlation matrix
##             q1           q2          q3          q4            q5            q6           q7
## q1  1.00000000 -0.022617711  0.09671681 -0.12319046  0.0580275594  0.0469878951 -0.072220975
## q2 -0.02261771  1.000000000 -0.02297775  0.15701189  0.0359657131 -0.0372707017  0.006030682
## q3  0.09671681 -0.022977747  1.00000000  0.04637104 -0.1339411872 -0.1581182308  0.119893299
## q4 -0.12319046  0.157011886  0.04637104  1.00000000 -0.0433383210  0.1550195274  0.129191576
## q5  0.05802756  0.035965713 -0.13394119 -0.04333832  1.0000000000  0.0009867756 -0.079563757
## q6  0.04698790 -0.037270702 -0.15811823  0.15501953  0.0009867756  1.0000000000 -0.016437117
## q7 -0.07222097  0.006030682  0.11989330  0.12919158 -0.0795637567 -0.0164371168  1.000000000
dat5 <- cluster_gen_2(n5, n_X = c(1, 3), c_mean = list(34.55, c(0.1, 0.2, 0.3)))
summarize_clusters(dat5)  # level2 q1-q3: -0.01947   , 0.2104,   0.3625
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1        q2      q3      q4      q5      q6      q7      q8      q9
##  Min.   :32.55   1:2     2:4     2:1     1:2     1:4     2:4     1:3     1:2
##  Mean   :33.93   3:3     1:2     3:4     3:1     2:1     5:1     4:1     3:3
##  Max.   :35.19   4:1             4:1     4:1     3:1     1:1     2:2     2:1
##                          Prop.           2:1
##  Stddev.: 0.95   Prop.   2:0.667 Prop.   5:1     Prop.   Prop.   Prop.   Prop.
##                  1:0.333 1:0.333 2:0.167         1:0.667 2:0.667 1:0.5   1:0.333
##                  3:0.5           3:0.667 Prop.   2:0.167 5:0.167 4:0.167 3:0.5
##                  4:0.167         4:0.167 1:0.333 3:0.167 1:0.167 2:0.333 2:0.167
##                                          3:0.167
##                                          4:0.167
##                                          2:0.167
##                                          5:0.167
##
##
##
##  Heterogeneous correlation matrix
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 3 and 2
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 5 and 3
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 6 and 4
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 9 and 2
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 9 and 3
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
##            q1          q2         q3         q4         q5         q6         q7          q8          q9
## q1  1.0000000  0.67112742  0.8290112  0.3975417  0.1299234  0.4962084  0.5394335 -0.54108828  0.67112742
## q2  0.6711274  1.00000000         NA  0.5724863  0.6187646  0.2751142  0.4740732 -0.06785133          NA
## q3  0.8290112          NA  1.0000000  0.9944722         NA  0.6139675  0.6139675 -0.99610886          NA
## q4  0.3975417  0.57248627  0.9944722  1.0000000  0.6522037         NA -0.6039091 -0.43437664  0.57248627
## q5  0.1299234  0.61876461         NA  0.6522037  1.0000000  0.4552238  0.3637532 -0.55442933  0.61876461
## q6  0.4962084  0.27511423  0.6139675         NA  0.4552238  1.0000000 -0.9861176 -0.10202122  0.27511423
## q7  0.5394335  0.47407325  0.6139675 -0.6039091  0.3637532 -0.9861176  1.0000000 -0.56249012  0.47407325
## q8 -0.5410883 -0.06785133 -0.9961089 -0.4343766 -0.5544293 -0.1020212 -0.5624901  1.00000000 -0.06785133
## q9  0.6711274          NA         NA  0.5724863  0.6187646  0.2751142  0.4740732 -0.06785133  1.00000000
## Summary statistics for all classes
##        q1                 q2                 q3          q4      q5      q6      q7      q8      q9      q10
##  Min.   :-2.08385   Min.   :-2.39003   Min.   :-2.7189   1:75    1:49    1:31    1:42    1:57    1:67    1:55
##  Mean   : 0.04155   Mean   : 0.04721   Mean   : 0.3168   2:65    2:17    2:33    2:39    2:83    2:18    3:33
##  Max.   : 2.28442   Max.   : 2.65569   Max.   : 2.4929           3:21    3:31    3:59            3:55    4:34
##                                                          Prop.   4:53    4:45            Prop.           2:18
##  Stddev.: 1         Stddev.: 1.03      Stddev.: 0.96     1:0.536                 Prop.   1:0.407 Prop.
##                                                          2:0.464 Prop.   Prop.   1:0.3   2:0.593 1:0.479 Prop.
##                                                                  1:0.35  1:0.221 2:0.279         2:0.129 1:0.393
##                                                                  2:0.121 2:0.236 3:0.421         3:0.393 3:0.236
##                                                                  3:0.15  3:0.221                         4:0.243
##                                                                  4:0.379 4:0.321                         2:0.129
##
##
##  q11
##  1:48
##  2:43
##  3:49
##
##  Prop.
##  1:0.343
##  2:0.307
##  3:0.35
##
##
##
##
##
##  Heterogeneous correlation matrix
##              q1          q2          q3          q4           q5          q6          q7           q8          q9
## q1   1.00000000 -0.24848311 -0.28198628 -0.18348652  0.265699538 -0.04720267  0.29865162 -0.262215999  0.05562326
## q2  -0.24848311  1.00000000  0.23405780  0.26633400  0.074945667  0.18246746 -0.25272445  0.122268095  0.37207570
## q3  -0.28198628  0.23405780  1.00000000  0.03772484 -0.289685338  0.37861282 -0.23256465  0.315492984  0.12889310
## q4  -0.18348652  0.26633400  0.03772484  1.00000000 -0.318036609 -0.07600542 -0.07004181  0.296203456  0.05864929
## q5   0.26569954  0.07494567 -0.28968534 -0.31803661  1.000000000 -0.16494207 -0.04443229  0.003930484  0.07899999
## q6  -0.04720267  0.18246746  0.37861282 -0.07600542 -0.164942074  1.00000000 -0.04020077  0.068280550 -0.05920893
## q7   0.29865162 -0.25272445 -0.23256465 -0.07004181 -0.044432286 -0.04020077  1.00000000  0.018141459 -0.24564572
## q8  -0.26221600  0.12226809  0.31549298  0.29620346  0.003930484  0.06828055  0.01814146  1.000000000  0.30510849
## q9   0.05562326  0.37207570  0.12889310  0.05864929  0.078999988 -0.05920893 -0.24564572  0.305108488  1.00000000
## q10 -0.05495989  0.07779110  0.11185742 -0.10314273 -0.214532852  0.16001682 -0.16465869 -0.125896707  0.05344901
## q11  0.32399240 -0.17607829  0.05501269 -0.41445300 -0.064925416  0.33229803  0.09911876 -0.188583814  0.28663132
##             q10         q11
## q1  -0.05495989  0.32399240
## q2   0.07779110 -0.17607829
## q3   0.11185742  0.05501269
## q4  -0.10314273 -0.41445300
## q5  -0.21453285 -0.06492542
## q6   0.16001682  0.33229803
## q7  -0.16465869  0.09911876
## q8  -0.12589671 -0.18858381
## q9   0.05344901  0.28663132
## q10  1.00000000  0.04766892
## q11  0.04766892  1.00000000
dat5a <- cluster_gen_2(n5a, n_X = c(3, 3), c_mean = list(c(1, 2, 2), c(0.15, 0.25, 0.35)))
summarize_clusters(dat5a)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1                q2              q3        q4      q5      q6      q7      q8      q9
##  Min.   :-1.1766   Min.   :1.105   Min.   :1.023   1:2     3:2     1:1     2:5     1:3     2:1
##  Mean   : 0.8863   Mean   :1.632   Mean   :2.593   4:2     5:2     2:3     3:1     2:4     3:4
##  Max.   : 2.0607   Max.   :2.741   Max.   :4.196   5:3     1:3     4:4     4:2     3:1     4:2
##                                                    2:1     4:1                             1:1
##  Stddev.: 1.06     Stddev.: 0.6    Stddev.: 1.06                   Prop.   Prop.   Prop.
##                                                    Prop.   Prop.   1:0.125 2:0.625 1:0.375 Prop.
##                                                    1:0.25  3:0.25  2:0.375 3:0.125 2:0.5   2:0.125
##                                                    4:0.25  5:0.25  4:0.5   4:0.25  3:0.125 3:0.5
##                                                    5:0.375 1:0.375                         4:0.25
##                                                    2:0.125 4:0.125                         1:0.125
##
##
##
##  Heterogeneous correlation matrix
## Warning in hetcor.data.frame(df): the correlation matrix has been adjusted to make it positive-definite
##             q1          q2          q3          q4          q5          q6          q7          q8         q9
## q1  1.00000000 -0.04632226 -0.08306371  0.29132002  0.06036799 -0.11049405  0.55308315  0.21509735  0.2333463
## q2 -0.04632226  1.00000000 -0.45245813  0.25492525  0.66346978  0.66580800  0.19455775  0.09800025 -0.3783082
## q3 -0.08306371 -0.45245813  1.00000000 -0.29735490  0.19029567  0.21709490 -0.48706986  0.52285777  0.1896451
## q4  0.29132002  0.25492525 -0.29735490  1.00000000 -0.02770801  0.44844773  0.46481334 -0.52709176  0.6753520
## q5  0.06036799  0.66346978  0.19029567 -0.02770801  1.00000000  0.75692364  0.24586023  0.73602496 -0.1679157
## q6 -0.11049405  0.66580800  0.21709490  0.44844773  0.75692364  1.00000000  0.04423697  0.23351658  0.1695942
## q7  0.55308315  0.19455775 -0.48706986  0.46481334  0.24586023  0.04423697  1.00000000  0.05602572  0.4238667
## q8  0.21509735  0.09800025  0.52285777 -0.52709176  0.73602496  0.23351658  0.05602572  1.00000000 -0.2845033
## q9  0.23334631 -0.37830817  0.18964514  0.67535198 -0.16791569  0.16959421  0.42386669 -0.28450325  1.0000000
## Summary statistics for all classes
##        q1                q2                q3          q4      q5      q6      q7      q8
##  Min.   :-3.1839   Min.   :-3.1807   Min.   :-2.0370   1:61    1:61    1:63    1:104   1:46
##  Mean   : 0.1441   Mean   : 0.2910   Mean   : 0.3252   2:35    2:47    2:53    2: 76   2:33
##  Max.   : 2.5329   Max.   : 3.0155   Max.   : 2.9465   3:30    3:72    3:64            3:41
##                                                        4:54                    Prop.   4:60
##  Stddev.: 0.98     Stddev.: 1.02     Stddev.: 0.92             Prop.   Prop.   1:0.578
##                                                        Prop.   1:0.339 1:0.35  2:0.422 Prop.
##                                                        1:0.339 2:0.261 2:0.294         1:0.256
##                                                        2:0.194 3:0.4   3:0.356         2:0.183
##                                                        3:0.167                         3:0.228
##                                                        4:0.3                           4:0.333
##
##
##
##  Heterogeneous correlation matrix
##             q1          q2           q3           q4          q5          q6          q7          q8
## q1  1.00000000 -0.11124435  0.098155521  0.054091783 -0.16909732  0.01833939  0.22156236 -0.00900241
## q2 -0.11124435  1.00000000  0.039055237  0.247998725  0.00268769  0.20466949  0.23697637 -0.06036102
## q3  0.09815552  0.03905524  1.000000000 -0.007797933 -0.09979711  0.13796654 -0.11265761  0.13369011
## q4  0.05409178  0.24799873 -0.007797933  1.000000000 -0.11052900  0.19685272  0.10585524  0.05563859
## q5 -0.16909732  0.00268769 -0.099797113 -0.110528996  1.00000000  0.12140572 -0.01377413  0.04653548
## q6  0.01833939  0.20466949  0.137966537  0.196852720  0.12140572  1.00000000 -0.14159503 -0.06435907
## q7  0.22156236  0.23697637 -0.112657614  0.105855239 -0.01377413 -0.14159503  1.00000000 -0.21757255
## q8 -0.00900241 -0.06036102  0.133690110  0.055638594  0.04653548 -0.06435907 -0.21757255  1.00000000
#level1 q1-q3: 0.9293   1.7213   2.1149
#level2 q1-q3: 0.1340   0.2065   0.3443

dat6 <- cluster_gen_2(n6, n_X = c(2, 2), c_mean = list(c(10, 20), c(200, 3)))
summarize_clusters(dat6)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1               q2        q3      q4      q5      q6      q7      q8      q9      q10
##  Min.   : 8.366   Min.   :18.86   1:3     4:2     2:2     3:2     1:2     4:2     1:1     2:3
##  Mean   :10.295   Mean   :20.09   3:1     3:2     3:4     2:2     5:2     5:2     3:3     3:3
##  Max.   :13.413   Max.   :22.37   2:2     1:1             4:2     2:2     1:2     2:2
##                                           2:1     Prop.                                   Prop.
##  Stddev.: 1.93    Stddev.: 1.38   Prop.           2:0.333 Prop.   Prop.   Prop.   Prop.   2:0.5
##                                   1:0.5   Prop.   3:0.667 3:0.333 1:0.333 4:0.333 1:0.167 3:0.5
##                                   3:0.167 4:0.333         2:0.333 5:0.333 5:0.333 3:0.5
##                                   2:0.333 3:0.333         4:0.333 2:0.333 1:0.333 2:0.333
##                                           1:0.167
##                                           2:0.167
##
##
##
##  Heterogeneous correlation matrix
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 6 and 4
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 7 and 5
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
##             q1          q2            q3          q4          q5         q6          q7            q8         q9
## q1   1.0000000 -0.61964532  7.346419e-01  0.52048240  0.62667547  0.5971171  0.36810295  4.711096e-01  0.2066978
## q2  -0.6196453  1.00000000  1.056203e-01 -0.77007095  0.06636962 -0.7571709 -0.18530497 -5.315393e-01 -0.9509405
## q3   0.7346419  0.10562028  1.000000e+00  0.04779302  0.99610886  0.2605171  0.62328133 -8.881784e-13 -0.5910334
## q4   0.5204824 -0.77007095  4.779302e-02  1.00000000 -0.20922483         NA  0.07490096  9.437915e-02  0.8044238
## q5   0.6266755  0.06636962  9.961089e-01 -0.20922483  1.00000000  0.0000000          NA  6.180443e-01 -0.5147022
## q6   0.5971171 -0.75717086  2.605171e-01          NA  0.00000000  1.0000000  0.32479806  0.000000e+00  0.7350145
## q7   0.3681029 -0.18530497  6.232813e-01  0.07490096          NA  0.3247981  1.00000000  3.247981e-01  0.0000000
## q8   0.4711096 -0.53153932 -8.881784e-13  0.09437915  0.61804429  0.0000000  0.32479806  1.000000e+00  0.3318078
## q9   0.2066978 -0.95094048 -5.910334e-01  0.80442378 -0.51470223  0.7350145  0.00000000  3.318078e-01  1.0000000
## q10 -0.2299783  0.46520778  2.875389e-01  0.54747382  0.00000000  0.5492371  0.00000000 -5.492371e-01 -0.3379730
##            q10
## q1  -0.2299783
## q2   0.4652078
## q3   0.2875389
## q4   0.5474738
## q5   0.0000000
## q6   0.5492371
## q7   0.0000000
## q8  -0.5492371
## q9  -0.3379730
## q10  1.0000000
## Summary statistics for all classes
##        q1              q2         q3      q4      q5      q6      q7      q8      q9     q10     q11
##  Min.   :198.0   Min.   :0.2625   1:52    1:49    1:44    1:52    1: 72   1:36    1:74   1:53    1:51
##  Mean   :200.0   Mean   :3.0437   2:41    2:32    2:46    2:27    2:100   2:35    2:98   2:17    2:40
##  Max.   :202.2   Max.   :5.1723   3:17    3:25    3:82    3:35            3:30           3:44    3:35
##                                   4:18    4:66            4:58    Prop.   4:71    Prop.  4:58    4:46
##  Stddev.: 0.96   Stddev.: 0.91    5:44            Prop.           1:0.419         1:0.43
##                                           Prop.   1:0.256 Prop.   2:0.581 Prop.   2:0.57 Prop.   Prop.
##                                   Prop.   1:0.285 2:0.267 1:0.302         1:0.209        1:0.308 1:0.297
##                                   1:0.302 2:0.186 3:0.477 2:0.157         2:0.203        2:0.099 2:0.233
##                                   2:0.238 3:0.145         3:0.203         3:0.174        3:0.256 3:0.203
##                                   3:0.099 4:0.384         4:0.337         4:0.413        4:0.337 4:0.267
##                                   4:0.105
##                                   5:0.256
##
##
##
##  Heterogeneous correlation matrix
##              q1            q2          q3          q4          q5          q6          q7          q8          q9
## q1   1.00000000  0.1467890640  0.17991803  0.10180527 -0.01443640  0.12885417 -0.18971728 -0.14427203 -0.12206281
## q2   0.14678906  1.0000000000  0.14594880 -0.04817306 -0.01784400 -0.06804589 -0.03749792  0.18317907  0.26413408
## q3   0.17991803  0.1459488016  1.00000000 -0.07218643 -0.36413531 -0.09542858  0.04865217 -0.14947665 -0.01405996
## q4   0.10180527 -0.0481730596 -0.07218643  1.00000000  0.16599554 -0.07612683  0.20315488  0.04644373  0.01381552
## q5  -0.01443640 -0.0178439983 -0.36413531  0.16599554  1.00000000 -0.04923507  0.30232489  0.31871547  0.11337589
## q6   0.12885417 -0.0680458884 -0.09542858 -0.07612683 -0.04923507  1.00000000  0.16140510 -0.16736104  0.01183413
## q7  -0.18971728 -0.0374979238  0.04865217  0.20315488  0.30232489  0.16140510  1.00000000 -0.05739296  0.11408142
## q8  -0.14427203  0.1831790680 -0.14947665  0.04644373  0.31871547 -0.16736104 -0.05739296  1.00000000  0.22781379
## q9  -0.12206281  0.2641340824 -0.01405996  0.01381552  0.11337589  0.01183413  0.11408142  0.22781379  1.00000000
## q10 -0.08276690 -0.0004573588 -0.21652972 -0.05984941  0.04375981  0.15959672 -0.03497482  0.11754507 -0.11463074
## q11 -0.04177473 -0.0372280245  0.16225378 -0.10000302 -0.18772620  0.17847968 -0.04012710 -0.03981816 -0.03691299
##               q10         q11
## q1  -0.0827668975 -0.04177473
## q2  -0.0004573588 -0.03722802
## q3  -0.2165297221  0.16225378
## q4  -0.0598494103 -0.10000302
## q5   0.0437598137 -0.18772620
## q6   0.1595967227  0.17847968
## q7  -0.0349748195 -0.04012710
## q8   0.1175450700 -0.03981816
## q9  -0.1146307396 -0.03691299
## q10  1.0000000000 -0.07109039
## q11 -0.0710903891  1.00000000
dat10 <- cluster_gen_2(n10, n_X = c(2, 3, 3), c_mean = list(c(0.1, 0.225), c(0.87, 0.005, 30), c(70, 700, 7000)))
summarize_clusters(dat10)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all countries
##        q1                 q2          q3     q4     q5     q6
##  Min.   :-2.28677   Min.   :-1.3693   2:16   1:8    1:6    1:6
##  Mean   : 0.09384   Mean   : 0.6583   1: 4   2:5    2:5    2:8
##  Max.   : 1.55528   Max.   : 2.3699          4:4    3:4    3:6
##                                       Prop.  3:3    4:5
##  Stddev.: 0.97      Stddev.: 0.92     2:0.8                Prop.
##                                       1:0.2  Prop.  Prop.  1:0.3
##                                              1:0.4  1:0.3  2:0.4
##                                              2:0.25 2:0.25 3:0.3
##                                              4:0.2  3:0.2
##                                              3:0.15 4:0.25
##
##
##
##  Heterogeneous correlation matrix
## Warning in hetcor.data.frame(df): the correlation matrix has been adjusted to make it positive-definite
##             q1          q2          q3          q4          q5         q6
## q1  1.00000000 -0.50749913  0.01541585 -0.58709434 -0.38470671  0.6439012
## q2 -0.50749913  1.00000000 -0.81363686  0.06205237  0.19304103 -0.3696294
## q3  0.01541585 -0.81363686  1.00000000  0.26225198  0.16855078  0.2268875
## q4 -0.58709434  0.06205237  0.26225198  1.00000000 -0.04199333 -0.5028279
## q5 -0.38470671  0.19304103  0.16855078 -0.04199333  1.00000000 -0.3135810
## q6  0.64390117 -0.36962942  0.22688751 -0.50282792 -0.31358097  1.0000000
## Summary statistics for all schools
##        q1                 q2                 q3        q4
##  Min.   :-0.98913   Min.   :-1.63138   Min.   :28.33   4: 9
##  Mean   : 0.81442   Mean   : 0.04774   Mean   :29.96   1:13
##  Max.   : 2.82579   Max.   : 1.74188   Max.   :31.40   3: 4
##                                                        2: 4
##  Stddev.: 1.1       Stddev.: 0.83      Stddev.: 0.89
##                                                        Prop.
##                                                        4:0.3
##                                                        1:0.433
##                                                        3:0.133
##                                                        2:0.133
##
##
##
##  Heterogeneous correlation matrix
##            q1         q2         q3         q4
## q1 1.00000000 0.25520421 0.16320823 0.08672255
## q2 0.25520421 1.00000000 0.09327425 0.42648035
## q3 0.16320823 0.09327425 1.00000000 0.12757262
## q4 0.08672255 0.42648035 0.12757262 1.00000000
## Summary statistics for all classes
##        q1              q2              q3       q4      q5      q6      q7      q8
##  Min.   :66.89   Min.   :697.1   Min.   :6997   1:241   1:226   1:194   1:214   1:196
##  Mean   :69.95   Mean   :700.0   Mean   :7000   2:190   2:198   2:134   2:110   2:151
##  Max.   :73.22   Max.   :702.6   Max.   :7003   3:237   3:244   3:110   3:159   3:136
##                                                                 4:230   4:185   4:185
##  Stddev.: 1.02   Stddev.: 1.04   Stddev.: 1.03  Prop.   Prop.
##                                                 1:0.361 1:0.338 Prop.   Prop.   Prop.
##                                                 2:0.284 2:0.296 1:0.29  1:0.32  1:0.293
##                                                 3:0.355 3:0.365 2:0.201 2:0.165 2:0.226
##                                                                 3:0.165 3:0.238 3:0.204
##                                                                 4:0.344 4:0.277 4:0.277
##
##
##
##  Heterogeneous correlation matrix
##              q1           q2          q3           q4           q5          q6           q7          q8
## q1  1.000000000  0.051050842 -0.06118294 -0.005641717 -0.002155054  0.04366447 -0.015910098 -0.06705308
## q2  0.051050842  1.000000000 -0.24335305  0.003191525 -0.097476072 -0.08950584 -0.113585579  0.08147955
## q3 -0.061182937 -0.243353054  1.00000000 -0.025864784 -0.062716901  0.08384192  0.107612612  0.03867568
## q4 -0.005641717  0.003191525 -0.02586478  1.000000000 -0.038005615  0.03918056  0.115991509  0.15572535
## q5 -0.002155054 -0.097476072 -0.06271690 -0.038005615  1.000000000 -0.10838767  0.007591735 -0.08505556
## q6  0.043664466 -0.089505843  0.08384192  0.039180559 -0.108387672  1.00000000  0.075592807  0.16205362
## q7 -0.015910098 -0.113585579  0.10761261  0.115991509  0.007591735  0.07559281  1.000000000  0.18416773
## q8 -0.067053078  0.081479547  0.03867568  0.155725349 -0.085055565  0.16205362  0.184167734  1.00000000
# level1 q1-q2: 0.5901 0.1461
# level2 q1-q3: 0.7468 -0.1062 30.01
# level3 q1-q3: good overall 70.05 700.0 7000

dat11 <- cluster_gen_2(n11, n_X = c(1, 2, 2, 2), c_mean = list(0.001, c(0.15, 0.25), c(0.35, 0.45), c(0.55, 0.65)))
summarize_clusters(dat11)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all cultures
##        q1          q2     q3     q4     q5    q6
##  Min.   :-0.4931   5:3    1:3    2:3    1:2   1:2
##  Mean   : 0.9642   4:1    2:1    3:1    2:2   2:2
##  Max.   : 2.0930
##                    Prop.  Prop.  Prop.  Prop. Prop.
##  Stddev.: 1.15     5:0.75 1:0.75 2:0.75 1:0.5 1:0.5
##                    4:0.25 2:0.25 3:0.25 2:0.5 2:0.5
##
##
##
##  Heterogeneous correlation matrix
## Warning in polyserial(y, x, ML = ML, std.err = std.err, bins = bins): initial correlation inadmissible,
## -1.15558971113954, set to -0.9999
## Warning in polyserial(y, x, ML = ML, std.err = std.err, bins = bins): inadmissible correlation set to 0.9999
## Warning in polyserial(y, x, ML = ML, std.err = std.err, bins = bins): initial correlation inadmissible,
## -1.12788723192174, set to -0.9999
## Warning in hetcor.data.frame(df): the correlation matrix has been adjusted to make it positive-definite
##            q1         q2         q3         q4         q5         q6
## q1  1.0000000 -0.8239123  0.9950152 -0.2704803 -0.9129538 -0.5685974
## q2 -0.8239123  1.0000000 -0.7632909 -0.3227410  0.5209377  0.9346650
## q3  0.9950152 -0.7632909  1.0000000 -0.3651375 -0.9490961 -0.4837298
## q4 -0.2704803 -0.3227410 -0.3651375  1.0000000  0.6397885 -0.6381588
## q5 -0.9129538  0.5209377 -0.9490961  0.6397885  1.0000000  0.1834243
## q6 -0.5685974  0.9346650 -0.4837298 -0.6381588  0.1834243  1.0000000
## Summary statistics for all countries
##        q1                q2          q3      q4      q5      q6      q7
##  Min.   :-2.6829   Min.   :-1.7648   1:12    2: 5    1:16    1:10    2:16
##  Mean   :-0.1981   Mean   : 0.2693   2: 9    3: 7    2: 8    2: 2    3:12
##  Max.   : 2.3021   Max.   : 2.5097   3:19    4: 8    3: 5    3: 2    1:12
##                                              5:11    4:11    4: 7
##  Stddev.: 1.02     Stddev.: 0.93     Prop.   1: 9            5:19    Prop.
##                                      1:0.3           Prop.           2:0.4
##                                      2:0.225 Prop.   1:0.4   Prop.   3:0.3
##                                      3:0.475 2:0.125 2:0.2   1:0.25  1:0.3
##                                              3:0.175 3:0.125 2:0.05
##                                              4:0.2   4:0.275 3:0.05
##                                              5:0.275         4:0.175
##                                              1:0.225         5:0.475
##
##
##
##  Heterogeneous correlation matrix
## Warning in log(P): NaNs produced
## Warning in log(P): NaNs produced

## Warning in log(P): NaNs produced

## Warning in log(P): NaNs produced

## Warning in log(P): NaNs produced
##            q1          q2          q3         q4          q5          q6          q7
## q1  1.0000000 -0.19454501  0.13536454 -0.2958169 -0.52161083 -0.38032046 -0.06023710
## q2 -0.1945450  1.00000000  0.05550631  0.2785378 -0.30875477  0.14461616  0.09389601
## q3  0.1353645  0.05550631  1.00000000  0.2847508 -0.40355078 -0.31684656 -0.06310602
## q4 -0.2958169  0.27853780  0.28475082  1.0000000 -0.36216738  0.20908156  0.37307628
## q5 -0.5216108 -0.30875477 -0.40355078 -0.3621674  1.00000000 -0.07214972 -0.32917590
## q6 -0.3803205  0.14461616 -0.31684656  0.2090816 -0.07214972  1.00000000 -0.04008806
## q7 -0.0602371  0.09389601 -0.06310602  0.3730763 -0.32917590 -0.04008806  1.00000000
## Summary statistics for all schools
##        q1                q2          q3     q4
##  Min.   :-2.3879   Min.   :-2.0939   1:18   4:16
##  Mean   : 0.1439   Mean   : 0.7124   2:42   2:10
##  Max.   : 2.5549   Max.   : 3.2776          3:13
##                                      Prop.  1:21
##  Stddev.: 1.06     Stddev.: 0.97     1:0.3
##                                      2:0.7  Prop.
##                                             4:0.267
##                                             2:0.167
##                                             3:0.217
##                                             1:0.35
##
##
##
##  Heterogeneous correlation matrix
##             q1          q2           q3          q4
## q1 1.000000000  0.14327112  0.008302347  0.01571761
## q2 0.143271116  1.00000000  0.186164539 -0.07337453
## q3 0.008302347  0.18616454  1.000000000 -0.08403181
## q4 0.015717608 -0.07337453 -0.084031806  1.00000000
## Summary statistics for all classes
##        q1                 q2            q3      q4      q5      q6      q7      q8      q9
##  Min.   :-2.31343   Min.   :-3.339817   1:422   1:412   1:467   1:366   1:540   1:503   1:364
##  Mean   : 0.59210   Mean   : 0.666849   2:275   2:292   2:376   2:294   2:364   2:376   2:273
##  Max.   : 3.53703   Max.   : 3.694616   3:256   3:231   3:519   3:298   3:458   3:483   3:290
##                                         4:409   4:427           4:404                   4:435
##  Stddev.: 0.99      Stddev.: 1                          Prop.           Prop.   Prop.
##                                         Prop.   Prop.   1:0.343 Prop.   1:0.396 1:0.369 Prop.
##                                         1:0.31  1:0.302 2:0.276 1:0.269 2:0.267 2:0.276 1:0.267
##                                         2:0.202 2:0.214 3:0.381 2:0.216 3:0.336 3:0.355 2:0.2
##                                         3:0.188 3:0.17          3:0.219                 3:0.213
##                                         4:0.3   4:0.314         4:0.297                 4:0.319
##
##
##
##  Heterogeneous correlation matrix
##              q1          q2           q3           q4          q5          q6          q7           q8
## q1  1.000000000 -0.02826557  0.012490625 -0.006854838  0.05096430  0.03937432 -0.04859720  0.061367524
## q2 -0.028265570  1.00000000 -0.042970797 -0.013451966  0.08924333  0.11358772 -0.04573050  0.017805272
## q3  0.012490625 -0.04297080  1.000000000  0.023054991  0.08560908  0.06591288 -0.04046132 -0.007665465
## q4 -0.006854838 -0.01345197  0.023054991  1.000000000 -0.04354223  0.01630831  0.06996595 -0.025541882
## q5  0.050964302  0.08924333  0.085609084 -0.043542231  1.00000000  0.06387787  0.05060769  0.023021284
## q6  0.039374318  0.11358772  0.065912878  0.016308309  0.06387787  1.00000000  0.11630195  0.010917919
## q7 -0.048597195 -0.04573050 -0.040461321  0.069965953  0.05060769  0.11630195  1.00000000 -0.088673860
## q8  0.061367524  0.01780527 -0.007665465 -0.025541882  0.02302128  0.01091792 -0.08867386  1.000000000
## q9  0.001581393  0.01422933  0.021271852  0.007038909  0.04074840 -0.05694679  0.08773718  0.161520982
##              q9
## q1  0.001581393
## q2  0.014229327
## q3  0.021271852
## q4  0.007038909
## q5  0.040748397
## q6 -0.056946788
## q7  0.087737175
## q8  0.161520982
## q9  1.000000000
# level1: 0.3349
# level2: 0.1956, 0.11559
# level3: 0.2553 0.4484
# level4: 0.5378 0.6555

dat12 <- cluster_gen_2(n12, n_X = c(1, 1, 2, 2, 3), c_mean = list(0.07, 0.75, c(10.55, 25), c(44, 66), c(78, 88, 98)))
summarize_clusters(dat12)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all cultures
##        q1           q2    q3    q4     q5     q6
##  Min.   :-1.95109   4:2   4:2   1:1    1:3    1:2
##  Mean   :-0.42214   1:2   2:2   3:3    2:1    2:1
##  Max.   : 0.35908                             3:1
##                     Prop. Prop. Prop.  Prop.
##  Stddev.: 1.07      4:0.5 4:0.5 1:0.25 1:0.75 Prop.
##                     1:0.5 2:0.5 3:0.75 2:0.25 1:0.5
##                                               2:0.25
##                                               3:0.25
##
##
##
##  Heterogeneous correlation matrix
## Warning in polychor(x, y, ML = ML, std.err = std.err): inadmissible correlation set to 0.9999
## Warning in polyserial(y, x, ML = ML, std.err = std.err, bins = bins): inadmissible correlation set to 0.9999
## Warning in hetcor.data.frame(df): the correlation matrix has been adjusted to make it positive-definite
##            q1         q2         q3         q4         q5         q6
## q1  1.0000000 -0.6440401 -0.6440401 -0.1107827  0.7222827 -0.4919462
## q2 -0.6440401  1.0000000  1.0000000  0.5785218 -0.5908306  0.4379943
## q3 -0.6440401  1.0000000  1.0000000  0.5785218 -0.5908306  0.4379943
## q4 -0.1107827  0.5785218  0.5785218  1.0000000  0.3084933  0.7933550
## q5  0.7222827 -0.5908306 -0.5908306  0.3084933  1.0000000  0.1937965
## q6 -0.4919462  0.4379943  0.4379943  0.7933550  0.1937965  1.0000000
## Summary statistics for all countries
##        q1          q2      q3      q4      q5      q6    q7     q8      q9      q10
##  Min.   :-0.7895   2:4     4:2     1:4     2:4     2:6   1:3    1:7     1:7     2:2
##  Mean   : 1.1399   4:4     5:3     2:3     3:6     3:6   3:9    2:5     3:5     3:3
##  Max.   : 2.7237   1:2     2:3     4:5     1:2                                  4:1
##                    3:2     3:1                     Prop. Prop.  Prop.   Prop.   5:4
##  Stddev.: 0.91             1:3     Prop.   Prop.   2:0.5 1:0.25 1:0.583 1:0.583 1:2
##                    Prop.           1:0.333 2:0.333 3:0.5 3:0.75 2:0.417 3:0.417
##                    2:0.333 Prop.   2:0.25  3:0.5                                Prop.
##                    4:0.333 4:0.167 4:0.417 1:0.167                              2:0.167
##                    1:0.167 5:0.25                                               3:0.25
##                    3:0.167 2:0.25                                               4:0.083
##                            3:0.083                                              5:0.333
##                            1:0.25                                               1:0.167
##
##
##
##  Heterogeneous correlation matrix
## Warning in hetcor.data.frame(df): the correlation matrix has been adjusted to make it positive-definite
##              q1          q2          q3          q4          q5          q6          q7          q8          q9
## q1   1.00000000 -0.03975963 -0.77159122 -0.11649360 -0.76369245  0.34394872  0.15812924 -0.34580158  0.20716944
## q2  -0.03975963  1.00000000 -0.01449597 -0.27009714  0.03242123 -0.44260765  0.63536181  0.81631359  0.06075739
## q3  -0.77159122 -0.01449597  1.00000000  0.46245262  0.46353781  0.05358068 -0.22132248  0.12002169 -0.28584880
## q4  -0.11649360 -0.27009714  0.46245262  1.00000000 -0.15636938  0.60454992  0.08532465 -0.08293662  0.38987134
## q5  -0.76369245  0.03242123  0.46353781 -0.15636938  1.00000000 -0.26933614  0.09774005  0.35673674 -0.37825639
## q6   0.34394872 -0.44260765  0.05358068  0.60454992 -0.26933614  1.00000000  0.19391517 -0.23627579 -0.18066627
## q7   0.15812924  0.63536181 -0.22132248  0.08532465  0.09774005  0.19391517  1.00000000  0.79575905  0.09972816
## q8  -0.34580158  0.81631359  0.12002169 -0.08293662  0.35673674 -0.23627579  0.79575905  1.00000000 -0.03479278
## q9   0.20716944  0.06075739 -0.28584880  0.38987134 -0.37825639 -0.18066627  0.09972816 -0.03479278  1.00000000
## q10 -0.19775588  0.14946044  0.49349601  0.54768061 -0.07769552 -0.08101118 -0.09650395 -0.03910203  0.51876240
##             q10
## q1  -0.19775588
## q2   0.14946044
## q3   0.49349601
## q4   0.54768061
## q5  -0.07769552
## q6  -0.08101118
## q7  -0.09650395
## q8  -0.03910203
## q9   0.51876240
## q10  1.00000000
## Summary statistics for all districts
##        q1               q2        q3      q4      q5      q6      q7
##  Min.   : 7.595   Min.   :22.64   1:34    1:30    1:34    1:59    1:34
##  Mean   :10.551   Mean   :25.12   3:20    2:31    2:29    2:61    2:19
##  Max.   :12.696   Max.   :28.06   4:45    3:59    3:29            4:25
##                                   2:21            4:28    Prop.   5:27
##  Stddev.: 0.97    Stddev.: 1.07           Prop.           1:0.492 3:15
##                                   Prop.   1:0.25  Prop.   2:0.508
##                                   1:0.283 2:0.258 1:0.283         Prop.
##                                   3:0.167 3:0.492 2:0.242         1:0.283
##                                   4:0.375         3:0.242         2:0.158
##                                   2:0.175         4:0.233         4:0.208
##                                                                   5:0.225
##                                                                   3:0.125
##
##
##
##  Heterogeneous correlation matrix
##             q1          q2          q3          q4          q5          q6          q7
## q1  1.00000000 -0.20003467  0.41368472 -0.01195502  0.16468409 -0.06655919 -0.06547140
## q2 -0.20003467  1.00000000 -0.09138959  0.00807471 -0.17203826  0.03723826 -0.12932314
## q3  0.41368472 -0.09138959  1.00000000  0.17711706  0.04677578 -0.22612297 -0.04757975
## q4 -0.01195502  0.00807471  0.17711706  1.00000000 -0.10936754 -0.25748721 -0.19205397
## q5  0.16468409 -0.17203826  0.04677578 -0.10936754  1.00000000  0.24408102  0.04632611
## q6 -0.06655919  0.03723826 -0.22612297 -0.25748721  0.24408102  1.00000000  0.24334544
## q7 -0.06547140 -0.12932314 -0.04757975 -0.19205397  0.04632611  0.24334544  1.00000000
## Summary statistics for all schools
##        q1              q2        q3      q4      q5      q6      q7
##  Min.   :41.31   Min.   :63.93   1:44    1:69    1: 78   2:31    2:33
##  Mean   :44.15   Mean   :65.98   4:33    3:75    2:102   3:41    4:50
##  Max.   :46.58   Max.   :68.41   3:31    2:36            1:51    1:64
##                                  5:52            Prop.   4:57    3:33
##  Stddev.: 1.04   Stddev.: 0.94   2:20    Prop.   1:0.433
##                                          1:0.383 2:0.567 Prop.   Prop.
##                                  Prop.   3:0.417         2:0.172 2:0.183
##                                  1:0.244 2:0.2           3:0.228 4:0.278
##                                  4:0.183                 1:0.283 1:0.356
##                                  3:0.172                 4:0.317 3:0.183
##                                  5:0.289
##                                  2:0.111
##
##
##
##  Heterogeneous correlation matrix
##             q1           q2           q3           q4           q5          q6           q7
## q1  1.00000000 -0.147285297 -0.095664788 -0.024672951  0.088596328 -0.01076034 -0.021898324
## q2 -0.14728530  1.000000000  0.055207808  0.109079501 -0.006315061  0.01203279  0.107266595
## q3 -0.09566479  0.055207808  1.000000000 -0.017405041  0.186525183  0.05388384  0.006532345
## q4 -0.02467295  0.109079501 -0.017405041  1.000000000  0.013009758 -0.01381924  0.005647526
## q5  0.08859633 -0.006315061  0.186525183  0.013009758  1.000000000  0.22438915 -0.026171411
## q6 -0.01076034  0.012032788  0.053883843 -0.013819241  0.224389150  1.00000000 -0.071625615
## q7 -0.02189832  0.107266595  0.006532345  0.005647526 -0.026171411 -0.07162561  1.000000000
## Summary statistics for all classes
##        q1              q2              q3         q4       q5       q6       q7       q8
##  Min.   :74.23   Min.   :84.34   Min.   : 93.91   1:1140   1:1422   1:1507   1:1466   1:1340
##  Mean   :78.00   Mean   :87.99   Mean   : 98.00   2: 859   2:1055   2:1029   2:1036   2:1099
##  Max.   :81.18   Max.   :91.82   Max.   :101.58   3: 830   3:1489   3:1430   3:1464   3:1527
##                                                   4:1137
##  Stddev.: 0.99   Stddev.: 1.01   Stddev.: 1                Prop.    Prop.    Prop.    Prop.
##                                                   Prop.    1:0.359  1:0.38   1:0.37   1:0.338
##                                                   1:0.287  2:0.266  2:0.259  2:0.261  2:0.277
##                                                   2:0.217  3:0.375  3:0.361  3:0.369  3:0.385
##                                                   3:0.209
##                                                   4:0.287
##
##
##
##  Heterogeneous correlation matrix
##             q1           q2           q3           q4           q5          q6           q7           q8
## q1  1.00000000  0.017617058 -0.026172081  0.055583853 -0.033720704 -0.02583886 -0.015164402  0.065527930
## q2  0.01761706  1.000000000  0.033907414  0.057907703 -0.023449695 -0.01507869  0.003281505  0.020583774
## q3 -0.02617208  0.033907414  1.000000000 -0.008071975 -0.028464739 -0.00113580  0.018336431  0.003788641
## q4  0.05558385  0.057907703 -0.008071975  1.000000000 -0.006072469 -0.03246792  0.011023350 -0.017660165
## q5 -0.03372070 -0.023449695 -0.028464739 -0.006072469  1.000000000 -0.04122890 -0.034447933 -0.004538705
## q6 -0.02583886 -0.015078692 -0.001135800 -0.032467924 -0.041228899  1.00000000 -0.041912908  0.031859376
## q7 -0.01516440  0.003281505  0.018336431  0.011023350 -0.034447933 -0.04191291  1.000000000  0.038172458
## q8  0.06552793  0.020583774  0.003788641 -0.017660165 -0.004538705  0.03185938  0.038172458  1.000000000
# level1: -0.8199 bad
# level2: 0.83156 bad
# level3: 10.545 24.90 good
# level4: 44.03 66.04 good
# level5: 78.02 88.00 98.00 good
set.seed(12334)
s4 <- cluster_gen_2(n4, n_X = 4, sigma = c(0.7, 0.8, 0.9, 0.11))
summarize_clusters(s4) #good
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1                 q2                  q3                 q4            q5      q6      q7      q8
##  Min.   :-2.20578   Min.   :-2.834780   Min.   :-3.04700   Min.   :-0.347064   1:318   1:296   1:324   1:545
##  Mean   : 0.01443   Mean   :-0.006389   Mean   :-0.06294   Mean   : 0.001359   2:242   2:182   2:174   2:455
##  Max.   : 2.36533   Max.   : 2.382128   Max.   : 2.94172   Max.   : 0.393029   3:187   3:207   3:180
##                                                                                4:253   4:315   4:322   Prop.
##  Stddev.: 0.71      Stddev.: 0.8        Stddev.: 0.94      Stddev.: 0.11                               1:0.545
##                                                                                Prop.   Prop.   Prop.   2:0.455
##                                                                                1:0.318 1:0.296 1:0.324
##                                                                                2:0.242 2:0.182 2:0.174
##                                                                                3:0.187 3:0.207 3:0.18
##                                                                                4:0.253 4:0.315 4:0.322
##
##
##  q9
##  1:325
##  2:179
##  3:193
##  4:303
##
##  Prop.
##  1:0.325
##  2:0.179
##  3:0.193
##  4:0.303
##
##
##
##  Heterogeneous correlation matrix
##              q1          q2            q3            q4           q5          q6           q7          q8
## q1  1.000000000 -0.10631852 -2.963437e-03 -9.276218e-02 -0.031140972 -0.06139268 -0.032428975  0.01084294
## q2 -0.106318515  1.00000000  6.319368e-02 -7.704840e-02  0.038575572 -0.02837014  0.111947983  0.01756420
## q3 -0.002963437  0.06319368  1.000000e+00 -8.224589e-06  0.041445854 -0.02261278  0.048634970  0.08075486
## q4 -0.092762176 -0.07704840 -8.224589e-06  1.000000e+00 -0.074015625 -0.01191724  0.081633743  0.03780720
## q5 -0.031140972  0.03857557  4.144585e-02 -7.401562e-02  1.000000000 -0.03006357  0.008736174  0.09851361
## q6 -0.061392677 -0.02837014 -2.261278e-02 -1.191724e-02 -0.030063574  1.00000000  0.075542138 -0.09459179
## q7 -0.032428975  0.11194798  4.863497e-02  8.163374e-02  0.008736174  0.07554214  1.000000000  0.14167406
## q8  0.010842940  0.01756420  8.075486e-02  3.780720e-02  0.098513607 -0.09459179  0.141674060  1.00000000
## q9  0.020700754 -0.03900587  8.599681e-02  5.425760e-02 -0.143681379  0.08419700 -0.098483995 -0.01473160
##             q9
## q1  0.02070075
## q2 -0.03900587
## q3  0.08599681
## q4  0.05425760
## q5 -0.14368138
## q6  0.08419700
## q7 -0.09848399
## q8 -0.01473160
## q9  1.00000000
set.seed(12334)
s5 <- cluster_gen_2(n5, n_X = c(1, 2), sigma = list(.07, c(14.5, 20.5)))
summarize_clusters(s5)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1            q2      q3      q4    q5      q6      q7      q8
##  Min.   :-0.144145   1:2     2:2     1:3   1:3     1:2     1:1     3:4
##  Mean   : 0.002352   2:2     3:2     2:3   2:1     2:2     4:1     2:1
##  Max.   : 0.121329   4:2     1:1           4:2     3:2     3:1     1:1
##                              4:1     Prop.                 2:1
##  Stddev.: 0.09       Prop.           1:0.5 Prop.   Prop.   5:2     Prop.
##                      1:0.333 Prop.   2:0.5 1:0.5   1:0.333         3:0.667
##                      2:0.333 2:0.333       2:0.167 2:0.333 Prop.   2:0.167
##                      4:0.333 3:0.333       4:0.333 3:0.333 1:0.167 1:0.167
##                              1:0.167                       4:0.167
##                              4:0.167                       3:0.167
##                                                            2:0.167
##                                                            5:0.333
##
##
##
##  Heterogeneous correlation matrix
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 4 and 3
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 7 and 4
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
## Warning in hetcor.data.frame(df): could not compute polychoric correlation between variables 8 and 5
##     Message: Error in optim(0, f, control = control, hessian = TRUE, method = "BFGS") :
##   non-finite finite-difference value [1]
##             q1         q2          q3          q4         q5          q6         q7          q8
## q1  1.00000000 -0.6937852 -0.21061166 -0.03412718 -0.2331527  0.04399225 -0.2561762  0.04722044
## q2 -0.69378517  1.0000000  0.11136582  0.00000000  0.6232813  0.85876751  0.5337223 -0.27064154
## q3 -0.21061166  0.1113658  1.00000000          NA  0.7500341 -0.09437915  0.7367474 -0.39933192
## q4 -0.03412718  0.0000000          NA  1.00000000  0.7325971  0.00000000         NA  0.26421351
## q5 -0.23315272  0.6232813  0.75003413  0.73259710  1.0000000  0.62328133  0.7940227          NA
## q6  0.04399225  0.8587675 -0.09437915  0.00000000  0.6232813  1.00000000  0.5337223 -0.27064154
## q7 -0.25617616  0.5337223  0.73674740          NA  0.7940227  0.53372233  1.0000000  0.05886000
## q8  0.04722044 -0.2706415 -0.39933192  0.26421351         NA -0.27064154  0.0588600  1.00000000
## Summary statistics for all classes
##        q1                 q2            q3      q4      q5
##  Min.   :-41.3028   Min.   :-58.94457   1:53    1:53    1:39
##  Mean   : -1.0216   Mean   : -0.21865   2:52    2:34    2:23
##  Max.   : 36.6274   Max.   : 51.23872   3:35    3:53    3:39
##                                                         4:39
##  Stddev.: 15.08     Stddev.: 20.34      Prop.   Prop.
##                                         1:0.379 1:0.379 Prop.
##                                         2:0.371 2:0.243 1:0.279
##                                         3:0.25  3:0.379 2:0.164
##                                                         3:0.279
##                                                         4:0.279
##
##
##
##  Heterogeneous correlation matrix
##            q1         q2          q3          q4          q5
## q1  1.0000000 0.10196773 -0.25654670 -0.14658335  0.14403773
## q2  0.1019677 1.00000000  0.14161184  0.15318952  0.09076548
## q3 -0.2565467 0.14161184  1.00000000 -0.07192123  0.32104092
## q4 -0.1465834 0.15318952 -0.07192123  1.00000000 -0.04622655
## q5  0.1440377 0.09076548  0.32104092 -0.04622655  1.00000000
#level 1 q1: 0.09
#level 2 q1 q2: 15.08 20.34

set.seed(12334)
s6a <- cluster_gen_2(n6a, n_X = c(3, 3), sigma = list(c(21, 37, 48), c(51, 58, 67)))
summarize_clusters(s6a)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1                 q2                q3          q4      q5      q6     q7      q8
##  Min.   :-23.3185   Min.   :-100.21   Min.   :-70.088   3:5     2:4     1:2    1:3     1:5
##  Mean   : -0.1131   Mean   : -14.64   Mean   :  1.252   1:2     3:3     3:4    4:3     3:1
##  Max.   : 25.2208   Max.   :  33.99   Max.   : 63.578   2:1     1:1     2:2    3:2     2:2
##
##  Stddev.: 16.1      Stddev.: 43.17    Stddev.: 42.58    Prop.   Prop.   Prop.  Prop.   Prop.
##                                                         3:0.625 2:0.5   1:0.25 1:0.375 1:0.625
##                                                         1:0.25  3:0.375 3:0.5  4:0.375 3:0.125
##                                                         2:0.125 1:0.125 2:0.25 3:0.25  2:0.25
##
##
##
##  Heterogeneous correlation matrix
## Warning in polyserial(y, x, ML = ML, std.err = std.err, bins = bins): initial correlation inadmissible,
## -1.09340672345356, set to -0.9999
## Warning in hetcor.data.frame(df): the correlation matrix has been adjusted to make it positive-definite
##             q1          q2          q3          q4          q5          q6          q7         q8
## q1  1.00000000 -0.30091379  0.15283195  0.42340173  0.05244181 -0.28464966 -0.34764532 -0.4173583
## q2 -0.30091379  1.00000000 -0.06169991 -0.91676562 -0.41392929 -0.26037490 -0.19315113 -0.4964688
## q3  0.15283195 -0.06169991  1.00000000  0.01802766  0.13647523  0.09801081  0.03347088  0.4633082
## q4  0.42340173 -0.91676562  0.01802766  1.00000000  0.68005852 -0.02911533 -0.14944110  0.2959815
## q5  0.05244181 -0.41392929  0.13647523  0.68005852  1.00000000 -0.32909725 -0.41348142  0.2154796
## q6 -0.28464966 -0.26037490  0.09801081 -0.02911533 -0.32909725  1.00000000  0.78918731  0.2514738
## q7 -0.34764532 -0.19315113  0.03347088 -0.14944110 -0.41348142  0.78918731  1.00000000  0.3427685
## q8 -0.41735828 -0.49646885  0.46330819  0.29598149  0.21547964  0.25147385  0.34276845  1.0000000
## Summary statistics for all classes
##        q1                  q2                 q3           q4      q5      q6      q7      q8      q9      q10
##  Min.   :-134.7058   Min.   :-188.889   Min.   :-166.210   1:59    1:57    1:68    1:76    1:64    1:53    1:98
##  Mean   :  -2.8085   Mean   :  -3.649   Mean   :  -5.383   2:66    2:37    2:72    2:35    2:26    2:54    2:42
##  Max.   : 136.5127   Max.   : 171.728   Max.   : 163.387   3:54    3:43    3:85    3:40    3:40    3:62    3:85
##                                                            4:46    4:28            4:74    4:30    4:56
##  Stddev.: 50.37      Stddev.: 56.71     Stddev.: 64.71             5:60    Prop.           5:65            Prop.
##                                                            Prop.           1:0.302 Prop.           Prop.   1:0.436
##                                                            1:0.262 Prop.   2:0.32  1:0.338 Prop.   1:0.236 2:0.187
##                                                            2:0.293 1:0.253 3:0.378 2:0.156 1:0.284 2:0.24  3:0.378
##                                                            3:0.24  2:0.164         3:0.178 2:0.116 3:0.276
##                                                            4:0.204 3:0.191         4:0.329 3:0.178 4:0.249
##                                                                    4:0.124                 4:0.133
##                                                                    5:0.267                 5:0.289
##
##
##  q11     q12
##  1:59    1:93
##  2:46    2:64
##  3:41    3:68
##  4:79
##          Prop.
##  Prop.   1:0.413
##  1:0.262 2:0.284
##  2:0.204 3:0.302
##  3:0.182
##  4:0.351
##
##
##
##
##
##  Heterogeneous correlation matrix
##              q1           q2           q3          q4           q5          q6          q7          q8
## q1   1.00000000  0.139897080  0.165904714 -0.15456204 -0.050172286  0.11629036  0.17135140  0.11164240
## q2   0.13989708  1.000000000 -0.212824602  0.08831703 -0.006343550  0.08074457 -0.07989094  0.08729985
## q3   0.16590471 -0.212824602  1.000000000 -0.13010852 -0.058537163  0.02418756 -0.12200697 -0.19549630
## q4  -0.15456204  0.088317031 -0.130108516  1.00000000 -0.093383179 -0.13333185  0.11934043  0.11872629
## q5  -0.05017229 -0.006343550 -0.058537163 -0.09338318  1.000000000 -0.04900694 -0.01048429 -0.24701119
## q6   0.11629036  0.080744571  0.024187561 -0.13333185 -0.049006937  1.00000000  0.05043280 -0.00700592
## q7   0.17135140 -0.079890940 -0.122006975  0.11934043 -0.010484293  0.05043280  1.00000000  0.21961965
## q8   0.11164240  0.087299853 -0.195496300  0.11872629 -0.247011189 -0.00700592  0.21961965  1.00000000
## q9   0.16577957 -0.025355176 -0.003077427 -0.11112714 -0.015242330  0.27038299  0.18405791  0.06058972
## q10 -0.04456890 -0.137286683 -0.099585679  0.09155293  0.038183981  0.12086467  0.02710331 -0.08893014
## q11 -0.19189764  0.020397653 -0.141440394  0.01994495  0.006199945  0.13773856 -0.16557574 -0.02761268
## q12 -0.20438939  0.008767232 -0.037516111 -0.04101418 -0.131842768  0.02619684 -0.27259341  0.17970571
##               q9         q10          q11          q12
## q1   0.165779567 -0.04456890 -0.191897637 -0.204389393
## q2  -0.025355176 -0.13728668  0.020397653  0.008767232
## q3  -0.003077427 -0.09958568 -0.141440394 -0.037516111
## q4  -0.111127143  0.09155293  0.019944949 -0.041014181
## q5  -0.015242330  0.03818398  0.006199945 -0.131842768
## q6   0.270382986  0.12086467  0.137738555  0.026196839
## q7   0.184057906  0.02710331 -0.165575737 -0.272593413
## q8   0.060589720 -0.08893014 -0.027612683  0.179705715
## q9   1.000000000 -0.09455313 -0.055626748 -0.238172434
## q10 -0.094553126  1.00000000  0.186873893 -0.146566136
## q11 -0.055626748  0.18687389  1.000000000 -0.219868990
## q12 -0.238172434 -0.14656614 -0.219868990  1.000000000
# level1: 16.1 , 43.17, 42.58;
# level2: 50.37  56.71 64.71

set.seed(12334)
s7 <- cluster_gen_2(n7, n_X = 2, sigma = c(72, 81))
summarize_clusters(s7)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1                 q2           q3      q4      q5
##  Min.   :-212.053   Min.   :-269.928   1:70    1:90    1:78
##  Mean   :  -1.220   Mean   :  -5.785   2:34    2:76    2:49
##  Max.   : 176.259   Max.   : 182.245   3:56    3:49    3:35
##                                        4:31    4:66    4:38
##  Stddev.: 73.75     Stddev.: 78.09     5:90            5:81
##                                                Prop.
##                                        Prop.   1:0.32  Prop.
##                                        1:0.249 2:0.27  1:0.278
##                                        2:0.121 3:0.174 2:0.174
##                                        3:0.199 4:0.235 3:0.125
##                                        4:0.11          4:0.135
##                                        5:0.32          5:0.288
##
##
##
##  Heterogeneous correlation matrix
##             q1          q2          q3          q4          q5
## q1  1.00000000 -0.20246944 -0.29301052  0.05455271  0.09849905
## q2 -0.20246944  1.00000000  0.04922986 -0.25182299  0.13040190
## q3 -0.29301052  0.04922986  1.00000000  0.02845545 -0.05882252
## q4  0.05455271 -0.25182299  0.02845545  1.00000000 -0.16459058
## q5  0.09849905  0.13040190 -0.05882252 -0.16459058  1.00000000
# 73.75 78.09

set.seed(12334)
s8 <- cluster_gen_2(n8, n_X = 4, sigma = c(0.111, 0.113, 0.115, 0.117))
summarize_clusters(s8)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1                   q2                 q3                 q4            q5     q6     q7     q8     q9
##  Min.   :-0.3539187   Min.   :-0.24500   Min.   :-0.23996   Min.   :-0.283512   1:29   1:18   1:18   1:14   1: 8
##  Mean   : 0.0041898   Mean   : 0.01133   Mean   :-0.01478   Mean   :-0.019697   2: 7   2: 9   2:11   2:36   2:20
##  Max.   : 0.2715584   Max.   : 0.28323   Max.   : 0.28145   Max.   : 0.253220   3: 6   3: 8   3: 9          3: 7
##                                                                                 4: 8   4:15   4:12   Prop.  4:15
##  Stddev.: 0.12        Stddev.: 0.12      Stddev.: 0.12      Stddev.: 0.13                            1:0.28
##                                                                                 Prop.  Prop.  Prop.  2:0.72 Prop.
##                                                                                 1:0.58 1:0.36 1:0.36        1:0.16
##                                                                                 2:0.14 2:0.18 2:0.22        2:0.4
##                                                                                 3:0.12 3:0.16 3:0.18        3:0.14
##                                                                                 4:0.16 4:0.3  4:0.24        4:0.3
##
##
##
##  Heterogeneous correlation matrix
##             q1          q2          q3           q4          q5          q6          q7          q8           q9
## q1  1.00000000 -0.08783291  0.08244792  0.012852186  0.08717891 -0.02944067  0.02437698 -0.20448130  0.257402575
## q2 -0.08783291  1.00000000 -0.02310892  0.153294974  0.27415375  0.36013296 -0.69174342  0.01619314  0.480120227
## q3  0.08244792 -0.02310892  1.00000000  0.219608452  0.54625224  0.10061711 -0.02471118 -0.48474030 -0.212740316
## q4  0.01285219  0.15329497  0.21960845  1.000000000  0.47203674  0.07532671  0.04186812  0.15902384 -0.005776325
## q5  0.08717891  0.27415375  0.54625224  0.472036741  1.00000000 -0.01042340 -0.11692122 -0.49093050 -0.102266790
## q6 -0.02944067  0.36013296  0.10061711  0.075326714 -0.01042340  1.00000000 -0.52734667 -0.26287715  0.158885783
## q7  0.02437698 -0.69174342 -0.02471118  0.041868117 -0.11692122 -0.52734667  1.00000000 -0.00892086 -0.356948683
## q8 -0.20448130  0.01619314 -0.48474030  0.159023841 -0.49093050 -0.26287715 -0.00892086  1.00000000  0.329022713
## q9  0.25740258  0.48012023 -0.21274032 -0.005776325 -0.10226679  0.15888578 -0.35694868  0.32902271  1.000000000
#0.12  0.12   0.12   0.13

set.seed(12334)
s9 <- cluster_gen_2(n9, n_X = c(2, 2), sigma = list(c(99, 101), c(0.006, 0.008)))
summarize_clusters(s9)
## ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Summary statistics for all schools
##        q1                 q2          q3      q4      q5      q6
##  Min.   :-166.991   Min.   :-137.27   2:5     1:9     2:1     1:7
##  Mean   :  -3.193   Mean   : -30.60   3:6     3:4     3:5     3:1
##  Max.   : 118.898   Max.   : 119.94   1:4     2:2     1:9     2:2
##                                                               4:5
##  Stddev.: 101.31    Stddev.: 73.13    Prop.   Prop.   Prop.
##                                       2:0.333 1:0.6   2:0.067 Prop.
##                                       3:0.4   3:0.267 3:0.333 1:0.467
##                                       1:0.267 2:0.133 1:0.6   3:0.067
##                                                               2:0.133
##                                                               4:0.333
##
##
##
##  Heterogeneous correlation matrix
##             q1          q2          q3          q4           q5           q6
## q1  1.00000000 -0.05967253 -0.31023537 -0.32175840  0.227453575 -0.302362626
## q2 -0.05967253  1.00000000 -0.18413192  0.30480570  0.628244927 -0.292289902
## q3 -0.31023537 -0.18413192  1.00000000  0.53219717 -0.083599206 -0.201319647
## q4 -0.32175840  0.30480570  0.53219717  1.00000000  0.167838599  0.010327930
## q5  0.22745357  0.62824493 -0.08359921  0.16783860  1.000000000 -0.005615806
## q6 -0.30236263 -0.29228990 -0.20131965  0.01032793 -0.005615806  1.000000000
## Summary statistics for all classes
##        q1                   q2             q3      q4      q5      q6      q7      q8      q9
##  Min.   :-0.0215642   Min.   :-0.0267151   1:142   1:94    1:118   1:118   1:91    1:113   1:136
##  Mean   :-0.0004303   Mean   :-0.0001576   2: 95   2:62    2: 91   2: 51   2:56    2: 68   2: 98
##  Max.   : 0.0161664   Max.   : 0.0217059   3:132   3:57    3: 75   3: 76   3:47    3: 88   3:135
##                                                    4:62    4: 85   4:124   4:95    4:100
##  Stddev.: 0.01        Stddev.: 0.01        Prop.   5:94                    5:80            Prop.
##                                            1:0.385         Prop.   Prop.           Prop.   1:0.369
##                                            2:0.257 Prop.   1:0.32  1:0.32  Prop.   1:0.306 2:0.266
##                                            3:0.358 1:0.255 2:0.247 2:0.138 1:0.247 2:0.184 3:0.366
##                                                    2:0.168 3:0.203 3:0.206 2:0.152 3:0.238
##                                                    3:0.154 4:0.23  4:0.336 3:0.127 4:0.271
##                                                    4:0.168                 4:0.257
##                                                    5:0.255                 5:0.217
##
##
##
##  Heterogeneous correlation matrix
##              q1           q2           q3          q4           q5           q6           q7          q8
## q1  1.000000000  0.179599530  0.140440456 -0.03570842 -0.013322871  0.050037004 -0.003680346  0.06165805
## q2  0.179599530  1.000000000  0.045437003  0.19723764  0.124466368  0.008947092  0.100651604 -0.01154585
## q3  0.140440456  0.045437003  1.000000000 -0.08691404  0.036915410 -0.081203049  0.001391041  0.18415554
## q4 -0.035708419  0.197237643 -0.086914044  1.00000000  0.026340275 -0.107509760 -0.109089670 -0.06267040
## q5 -0.013322871  0.124466368  0.036915410  0.02634028  1.000000000 -0.031603116 -0.020662639 -0.10814937
## q6  0.050037004  0.008947092 -0.081203049 -0.10750976 -0.031603116  1.000000000  0.096342606  0.04612547
## q7 -0.003680346  0.100651604  0.001391041 -0.10908967 -0.020662639  0.096342606  1.000000000  0.03022382
## q8  0.061658051 -0.011545850  0.184155535 -0.06267040 -0.108149375  0.046125468  0.030223824  1.00000000
## q9 -0.090753286 -0.085088753 -0.114871065 -0.21116405  0.005213178  0.128403436  0.012497062 -0.06827498
##              q9
## q1 -0.090753286
## q2 -0.085088753
## q3 -0.114871065
## q4 -0.211164053
## q5  0.005213178
## q6  0.128403436
## q7  0.012497062
## q8 -0.068274976
## q9  1.000000000
# level1: 101.31, 73.13, level2: 0.01, 0.01
wleoncio commented 3 years ago
  1. Although it can be inferred that univariate/multivariate normal distributions are used with “c_mean”, “sigma”, and “cor_matrix”, it's better to include those information.

Addressed on 7b4ecff68e0ae42747faed3b196241b7d7b37871.

  1. When “c_mean” is not specified, the generation of mean is not given on whether they're freely generated or 0 by default.
  2. When “sigma” is not specified, the generation of sigma is not given clearly on whether it's randomly generated or 1 by default.

Addressed on 6c69a7b660dc8fdb36f5304e151bb9f738c9a8c5.

  1. Could not extract results from “summarize_cluster” function, e.g., extract certain statistics from certain level. It would be better if those could be extracted.
  2. Output from “summarize_cluster” function can't be saved as an object. It would make more sense if it can be saved.
  3. If (4) and (5) can be resolved, checking errors from simulation could be achieved via vast simulation instead of eye balling.

Addressed on 6f4c10c8690e068ffd268692abf71ffb17ec5847.

  1. When the means/sigmas are very small (e.g., 0.005) and with multiple levels, the estimation will be not accurate (e.g., school level estimates will be not as accurate as the student levels)
  2. Higher hierachical order => Worse estimation.

Addressed on 01536c162846181c2105c9abf53518846deae251.

wleoncio commented 3 years ago
  1. The output for “sigma” only includes two digits, so it’s impossible to compare the results if the input values are less than 0.01

@Hugo-v587, here's a counter-example:

cluster_gen(c(1, 10), n_X = 1, n_W=0, full_output=TRUE, sigma=pi)

Notice how all standard deviations are 3.141593 as specified, so the output uses as many significant digits as R is configured to print by default. Can you confirm this works on your end?

wleoncio commented 3 years ago
  1. Changing the seed will generate very different estimation results.

@Hugo-v587, I wonder if this could be a result of a small sample size. Please report if increasing the sample size doesn't fix this (with accompanying code).

wleoncio commented 3 years ago

Errors and warnings

All reported errors were addressed on f44d28dd589a6f1129040192a775b6db26d87702.