User Tools

Site Tools


neuroimagen:bioface_np_cs

Sacando los Composite Scores de NP para BIOFACE

Limpiando la DB

Vamos a cargar la DB,

setwd("/old_nas/bioface/css")
read_sav("db20211021.sav")-> bioface_data

De aqui no nos interesa todo, sino solo las variables de NP

 bioface_np <- bioface_data[,c(140,149,150,153:155,145:147,160:167,157,158,169,170)]

y lo que nos interesa es montar un dataframe,

bfdf <- data.frame(bioface_np)
for(index in 1:102) { row.names(bfdf)[row.names(bfdf) == index] <- bioface_data[index, 1]}

Voy a mirar un poco las variables.

> describe(bfdf)
                     vars   n  mean    sd median trimmed  mad min max range  skew kurtosis   se
O_Total_NP              1 100 14.83  0.47     15   14.96 0.00  13  15     2 -2.77     6.87 0.05
M_digtspan_direct_NP    2 100  4.86  0.84      5    4.81 1.48   3   7     4  0.36    -0.76 0.08
M_digtspan_invers_NP    3 100  3.48  0.82      4    3.49 1.48   2   5     3 -0.10    -0.58 0.08
LL_Namingtotal_NP       4 100 14.21  1.56     15   14.57 0.00   5  15    10 -3.04    11.99 0.16
LL_comprensio_NP        5 100  5.91  0.29      6    6.00 0.00   5   6     1 -2.82     6.03 0.03
LL_R_total_NP           6 100  4.00  0.00      4    4.00 0.00   4   4     0   NaN      NaN 0.00
M_WMS_total_NP          7 100 24.42  5.85     25   24.49 5.93  11  39    28 -0.07    -0.53 0.59
M_ret_NP                8 100  5.08  2.55      5    5.11 1.48   0  12    12  0.05    -0.07 0.25
M_recon_NP              9 100 20.90  3.48     22   21.51 2.97   4  24    20 -1.95     4.98 0.35
G_Luria_NP             10 100  3.35  1.01      4    3.58 0.00   0   4     4 -1.84     3.05 0.10
P_Ecopraxiatotal_NP    11 100  3.80  0.47      4    3.91 0.00   2   4     2 -2.29     4.57 0.05
P_ideo_total_NP        12 100  3.99  0.10      4    4.00 0.00   3   4     1 -9.70    93.06 0.01
P_constr_total_NP      13  99  3.48  0.88      4    3.68 0.00   0   4     4 -1.88     3.07 0.09
FE_SKTtemps_NP         14 100 33.10 28.16     27   29.21 7.41   0 290   290  7.62    66.38 2.82
FE_SKTerrors_NP        15 100  0.94  1.61      0    0.59 0.00   0   8     8  2.38     6.41 0.16
FE_Pflu_NP             16 100 12.08  3.89     12   12.18 4.45   2  22    20 -0.05    -0.23 0.39
FE_anflu_NP            17 100 15.93  5.05     16   15.85 5.93   5  28    23  0.16    -0.40 0.50
G_pop_total_NP         18 100  9.72  0.91     10    9.90 0.00   2  10     8 -6.33    49.02 0.09
G_15obj_NP             19 100 12.39  2.41     13   12.69 1.48   2  15    13 -1.55     3.49 0.24
FE_R_abstracte_NP      20 100 10.90  2.69     11   11.10 2.97   2  15    13 -0.69     0.13 0.27
FE_T_rellotge_NP       21 100  6.34  1.72      7    6.78 0.00   0   9     9 -2.67     6.94 0.17

y ahora me quedo solo con las filas completas,

> dim(bfdf)
[1] 102  21
> bfdf <- bfdf[complete.cases(bfdf),]
> dim(bfdf)
[1] 99 21

Some minor edits (arreglar esto en la DB!)

> bfdf["B017",14] <- 29
> bfdf[row.names(bfdf) != "B063",] -> bfdf
> dim(bfdf)
[1] 98 21

y quito las filas con sd=0,

bfdf[-c(6)] -> bfdf

y ahora todo va a z-scores,

data.frame(row.names=row.names(bfdf)) -> zdb
for(xname in row.names(describe(bfdf))) {print((bfdf[xname] - describe(bfdf[xname])$mean)/describe(bfdf[xname])$sd) -> zdb[xname]}

Composites Scores agrupando por tipo de pruebas

Las variables a estudiar se agrupan por,

1) Orientation:
O_Total_NP

2) Attention and working memory:
M_digtspan_direct_NP
M_digtspan_invers_NP

3) Processing speed and Executive function:
FE_SKTtemps_NP
FE_SKTerrors_NP

4) Executive function-verbal:
FE_Pflu_NP
FE_anflu_NP
FE_R_abstracte_NP 

5) Language:
LL_Namingtotal_NP
LL_comprensio_NP
LL_R_total_NP (esta ha desaparecido)

6) Verbal Learning and Memory:
M_WMS_total_NP
M_ret_NP
M_recon_NP

7) Praxis:
P_constr_total_NP
P_ideo_total_NP
P_Ecopraxiatotal_NP

8) Visual gnosis:
G_pop_total_NP
G_Luria_NP
G_15obj_NP

9) Global cognition:
FE_T_rellotge_NP

Segun esto habria que hacer 9 composites scores,

data.frame(row.names=row.names(zdb)) -> cs
cs$Orientation = zdb$O_Total_NP
tt <- data.frame(zdb$M_digtspan_direct_NP,zdb$M_digtspan_invers_NP)
mod <- fa(tt, scores="regression")
cs$Attention.and.Working.Memory = mod$scores
remove(tt)
tt <- data.frame(zdb$FE_SKTtemps_NP,zdb$FE_SKTerrors_NP)
mod <- fa(tt, scores="regression")
cs$"Processing.speed.and.Executive.function" <- mod$scores
tt <- data.frame(zdb$FE_Pflu_NP,zdb$FE_anflu_NP,zdb$FE_R_abstracte_NP)
mod <- fa(tt, scores="regression")
cs$"Executive.function.verbal" <- mod$scores
remove(tt)
tt <- data.frame(zdb$LL_Namingtotal_NP, zdb$LL_comprensio_NP)
mod <- fa(tt, scores="regression")
cs$Language = mod$scores
remove(tt)
tt <- data.frame(zdb$M_WMS_total_NP,zdb$M_ret_NP,zdb$M_recon_NP)
mod <- fa(tt, scores="regression")
cs$"Verbal.Learning.and.Memory" = mod$scores
remove(tt)
tt <- data.frame(zdb$P_constr_total_NP, zdb$P_ideo_total_NP, zdb$P_Ecopraxiatotal_NP)
mod <- fa(tt, scores="regression")
cs$Praxis = mod$scores
remove(tt)
tt <- data.frame(zdb$G_pop_total_NP, zdb$G_Luria_NP, zdb$G_15obj_NP)
mod <- fa(tt, scores="regression")
cs$"Visual.gnosis" = mod$scores
cs$"Global.cognition" = zdb$FE_T_rellotge_NP

Para escribir os datos a un archivo SPSS,

write_sav(cs, "bioface_composite_scores.sav")

y evidentemente podemos hacer un PCA de esto incluso y,

A ver

Lo que se puede observar a simple vista es que tenemos una poblacion bastante homogenea en cuanto a los dominios cognitivos donde los sujetos empeoran en algun dominio aleatorio y no en todos al mismo tiempo, ya que no se observa ninguna direccion preferencial en la desviacion de los sujetos hacia la izquierda sino que ocurre mas bien en forma de nube. Luego, hay algunos dominios que estan muy relacionados como Praxis y Global cognition o Language y Verbal learning and Memory, mientras otros, como Orientation son independientes del resto.

PCA

> princomp(zdb) -> pca.zdb
> plot(pca.zdb, type="l")

> pca.var = pca.zdb$sdev^2
> pca.pvar = pca.var/sum(pca.var)
> plot(cumsum(pca.pvar))

Los loadings,

> pca.zdb$loadings

Loadings:
                     Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8 Comp.9 Comp.10 Comp.11
O_Total_NP            0.204         0.366  0.342  0.213  0.170                       0.469   0.209 
M_digtspan_direct_NP  0.129 -0.243 -0.578         0.204  0.109                       0.132         
M_digtspan_invers_NP  0.260 -0.250 -0.373         0.106  0.199 -0.121                       -0.224 
LL_Namingtotal_NP     0.311                0.323 -0.121        -0.372         0.209  0.233  -0.246 
LL_comprensio_NP      0.262  0.218  0.129 -0.109         0.391  0.155 -0.407 -0.100 -0.143  -0.234 
M_WMS_total_NP        0.286  0.243        -0.182  0.227 -0.256  0.296  0.173                       
M_ret_NP              0.274  0.317        -0.137  0.285 -0.282         0.132        -0.127  -0.225 
M_recon_NP            0.277  0.244                0.247 -0.113 -0.252  0.245 -0.255          0.121 
G_Luria_NP            0.125         0.287 -0.391 -0.266  0.260         0.545  0.221 -0.107  -0.204 
P_Ecopraxiatotal_NP   0.202        -0.243  0.109 -0.446         0.484  0.110  0.158  0.192   0.201 
P_ideo_total_NP       0.118 -0.223         0.530        -0.186  0.225         0.365 -0.502  -0.171 
P_constr_total_NP     0.170        -0.188 -0.438        -0.147 -0.195 -0.261  0.597          0.346 
FE_SKTtemps_NP       -0.261  0.225 -0.186        -0.221 -0.160 -0.324         0.125         -0.428 
FE_SKTerrors_NP      -0.201  0.350 -0.177  0.116 -0.236 -0.317  0.123  0.136 -0.149          0.201 
FE_Pflu_NP            0.145 -0.412        -0.188 -0.240 -0.203  0.224 -0.110 -0.429         -0.206 
FE_anflu_NP           0.197 -0.220  0.299               -0.529        -0.291         0.126         
G_pop_total_NP        0.280  0.140         0.111 -0.186  0.111 -0.166 -0.167 -0.153 -0.544   0.378 
G_15obj_NP            0.265         0.108        -0.354        -0.368  0.287 -0.208          0.176 
FE_T_rellotge_NP      0.243  0.347 -0.140        -0.314  0.106        -0.312         0.208  -0.201 
                     Comp.12 Comp.13 Comp.14 Comp.15 Comp.16 Comp.17 Comp.18 Comp.19
O_Total_NP            0.337   0.333                   0.206   0.194   0.182   0.116 
M_digtspan_direct_NP  0.410  -0.307  -0.155  -0.416   0.154                         
M_digtspan_invers_NP          0.478  -0.103   0.304  -0.457  -0.137   0.105   0.180 
LL_Namingtotal_NP                     0.209                          -0.235  -0.596 
LL_comprensio_NP      0.129   0.175          -0.263   0.176  -0.389  -0.343         
M_WMS_total_NP       -0.105   0.114  -0.218          -0.119   0.477  -0.502         
M_ret_NP                             -0.207           0.276  -0.262   0.523  -0.285 
M_recon_NP                   -0.277   0.551   0.190                  -0.123   0.361 
G_Luria_NP            0.342  -0.116   0.138  -0.104  -0.189           0.103         
P_Ecopraxiatotal_NP          -0.157           0.421   0.147  -0.300  -0.114         
P_ideo_total_NP                              -0.230                           0.271 
P_constr_total_NP             0.209   0.238           0.142                         
FE_SKTtemps_NP        0.421          -0.166   0.235   0.336          -0.149   0.231 
FE_SKTerrors_NP       0.233   0.438   0.249  -0.337  -0.256  -0.175          -0.143 
FE_Pflu_NP                    0.184   0.369           0.326   0.285          -0.114 
FE_anflu_NP           0.346  -0.225  -0.204          -0.339  -0.253           0.197 
G_pop_total_NP        0.298          -0.211   0.210           0.292          -0.240 
G_15obj_NP           -0.304   0.165  -0.348  -0.317   0.251  -0.128           0.229 
FE_T_rellotge_NP     -0.166  -0.210          -0.223  -0.206   0.325   0.416   0.246 

               Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8 Comp.9 Comp.10 Comp.11 Comp.12
SS loadings     1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000  1.000   1.000   1.000   1.000
Proportion Var  0.053  0.053  0.053  0.053  0.053  0.053  0.053  0.053  0.053   0.053   0.053   0.053
Cumulative Var  0.053  0.105  0.158  0.211  0.263  0.316  0.368  0.421  0.474   0.526   0.579   0.632
               Comp.13 Comp.14 Comp.15 Comp.16 Comp.17 Comp.18 Comp.19
SS loadings      1.000   1.000   1.000   1.000   1.000   1.000   1.000
Proportion Var   0.053   0.053   0.053   0.053   0.053   0.053   0.053
Cumulative Var   0.684   0.737   0.789   0.842   0.895   0.947   1.000

un vistazo rapido,

neuroimagen/bioface_np_cs.txt · Last modified: 2021/12/24 08:06 by osotolongo