Do profiles have incremental validity in predicting grades ?.
Open data
        setwd("~/Dropbox/R Stat")
        load("cluster_rio_som.RData")
        library(ggplot2)
        library(sjPlot)
        library(kohonen) 
## Loading required package: class
## Loading required package: MASS
        library(forcats)
Cluster solutions (ward and self organizing maps som)
table(grp9)
## grp9
##    1    2    3    4    5    6    7    8    9 
## 4187 1503 4168 2144  813 4343 3384 1259 2786
table(cluster_som$unit.classif)
## 
##    1    2    3    4    5    6    7    8    9 
## 2781 3624 1454 2622 2365 2619 2000 4343 2779
table(cluster_som$unit.classif, grp9)
##    grp9
##        1    2    3    4    5    6    7    8    9
##   1    3  712  693    2   14   48  924   89  296
##   2   90    1  429  254   35 2345  161    0  309
##   3    0  361    0    0   29    0   50  881  133
##   4    2  143  231    0   17  153 1553  138  385
##   5  342    1   77 1460   62  354    0    0   69
##   6  204  249  350   89  556  653  410   57   51
##   7    0   16   92   11  100  103   53   94 1531
##   8 1248   20 2172   37    0  621  233    0   12
##   9 2298    0  124  291    0   66    0    0    0
library(gmodels)
CrossTable(cluster_som$unit.classif, grp9, 
           expected = FALSE, prop.r = TRUE, prop.c = FALSE, prop.t = FALSE)
## 
##  
##    Cell Contents
## |-------------------------|
## |                       N |
## | Chi-square contribution |
## |           N / Row Total |
## |-------------------------|
## 
##  
## Total Observations in Table:  24587 
## 
##  
##                          | grp9 
## cluster_som$unit.classif |         1 |         2 |         3 |         4 |         5 |         6 |         7 |         8 |         9 | Row Total | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##                        1 |         3 |       712 |       693 |         2 |        14 |        48 |       924 |        89 |       296 |      2781 | 
##                          |   467.605 |  1727.988 |   104.129 |   238.521 |    66.089 |   399.921 |   765.341 |    20.027 |     1.160 |           | 
##                          |     0.001 |     0.256 |     0.249 |     0.001 |     0.005 |     0.017 |     0.332 |     0.032 |     0.106 |     0.113 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##                        2 |        90 |         1 |       429 |       254 |        35 |      2345 |       161 |         0 |       309 |      3624 | 
##                          |   450.268 |   219.539 |    55.916 |    12.170 |    60.055 |  4540.533 |   228.753 |   185.570 |    25.159 |           | 
##                          |     0.025 |     0.000 |     0.118 |     0.070 |     0.010 |     0.647 |     0.044 |     0.000 |     0.085 |     0.147 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##                        3 |         0 |       361 |         0 |         0 |        29 |         0 |        50 |       881 |       133 |      1454 | 
##                          |   247.606 |   833.094 |   246.483 |   126.790 |     7.571 |   256.832 |   112.612 |  8737.241 |     6.121 |           | 
##                          |     0.000 |     0.248 |     0.000 |     0.000 |     0.020 |     0.000 |     0.034 |     0.606 |     0.091 |     0.059 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##                        4 |         2 |       143 |       231 |         0 |        17 |       153 |      1553 |       138 |       385 |      2622 | 
##                          |   442.518 |     1.863 |   102.535 |   228.640 |    56.033 |   207.689 |  3938.090 |     0.104 |    26.003 |           | 
##                          |     0.001 |     0.055 |     0.088 |     0.000 |     0.006 |     0.058 |     0.592 |     0.053 |     0.147 |     0.107 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##                        5 |       342 |         1 |        77 |      1460 |        62 |       354 |         0 |         0 |        69 |      2365 | 
##                          |     9.162 |   142.579 |   261.705 |  7622.297 |     3.357 |     9.728 |   325.504 |   121.102 |   147.749 |           | 
##                          |     0.145 |     0.000 |     0.033 |     0.617 |     0.026 |     0.150 |     0.000 |     0.000 |     0.029 |     0.096 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##                        6 |       204 |       249 |       350 |        89 |       556 |       653 |       410 |        57 |        51 |      2619 | 
##                          |   131.308 |    49.365 |    19.891 |    85.062 |  2544.279 |    78.351 |     6.808 |    44.335 |   203.528 |           | 
##                          |     0.078 |     0.095 |     0.134 |     0.034 |     0.212 |     0.249 |     0.157 |     0.022 |     0.019 |     0.107 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##                        7 |         0 |        16 |        92 |        11 |       100 |       103 |        53 |        94 |      1531 |      2000 | 
##                          |   340.586 |    92.354 |   180.005 |   153.095 |    17.344 |   177.306 |   179.472 |     0.691 |  7507.583 |           | 
##                          |     0.000 |     0.008 |     0.046 |     0.005 |     0.050 |     0.051 |     0.026 |     0.047 |     0.765 |     0.081 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##                        8 |      1248 |        20 |      2172 |        37 |         0 |       621 |       233 |         0 |        12 |      4343 | 
##                          |   349.504 |   226.994 |  2800.008 |   308.327 |   143.607 |    27.839 |   222.566 |   222.387 |   468.406 |           | 
##                          |     0.287 |     0.005 |     0.500 |     0.009 |     0.000 |     0.143 |     0.054 |     0.000 |     0.003 |     0.177 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##                        9 |      2298 |         0 |       124 |       291 |         0 |        66 |         0 |         0 |         0 |      2779 | 
##                          |  7035.957 |   169.880 |   255.736 |     9.775 |    91.891 |   367.751 |   382.484 |   142.301 |   314.894 |           | 
##                          |     0.827 |     0.000 |     0.045 |     0.105 |     0.000 |     0.024 |     0.000 |     0.000 |     0.000 |     0.113 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
##             Column Total |      4187 |      1503 |      4168 |      2144 |       813 |      4343 |      3384 |      1259 |      2786 |     24587 | 
## -------------------------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|-----------|
## 
## 
subs <- round(cluster$height - c(0, cluster$height[-length(cluster$height)]), 3)
plot(cluster$height)

plot(cluster, hang = -1)
rect.hclust(cluster, k=9, border="red")

source("cluster_fig_senna1.R")  
What profiles characterizes each cluster? Results from ward method
cluster_fig(bd = sv1_rio[ , 178:183], grp = grp9, min=-3, max=3, interv = .5, interc = 0)