Bancos de dados

library(tidyverse)
library(readxl)
# Banco de dados parcial (IBNeuro)
parcial <- read_excel("C:/Dropbox/Laboratorio/Carina/SDMT/SDMT_manual_REVISADO_nov2019_FINAL.xlsx", sheet = "NORMAS")
parcial <- parcial %>% type.convert()

# Banco de dados completo (IBNeuro e FM USP)
todos <- read_excel("C:/Dropbox/Laboratorio/Carina/SDMT/SDMT_manual_REVISADO_nov2019_FINAL.xlsx", sheet = "NormasSDMT")
todos <- todos %>% type.convert()

# Banco de dados (com MMSE_SV Normal)
dados <- read_excel("C:/Dropbox/Laboratorio/Carina/SDMT/SDMT_manual_REVISADO_nov2019_FINAL.xlsx", sheet = "NormasSDMT")
dados <- dados %>% type.convert()

# Banco de dados da Ressonância Magnética
Ress <- read_excel("C:/Dropbox/Laboratorio/Carina/SDMT/SDMT_manual_REVISADO_nov2019_FINAL.xlsx", sheet = "EM_Resson")
Ress <- Ress %>% type.convert()

# Banco de dados da Esclerose Múltipla
EM <- read_excel("C:/Dropbox/Laboratorio/Carina/SDMT/SDMT_manual_REVISADO_nov2019_FINAL.xlsx", sheet = "EM")
EM <- EM %>% type.convert()

# Banco de dados Caso-Controle
caso <- read_excel("C:/Dropbox/Laboratorio/Carina/SDMT/SDMT_manual_REVISADO_nov2019_FINAL.xlsx", sheet = "Caso_contr_RM")
caso <- caso %>% type.convert()

# Banco de dados Teste-Reteste
conf <- read_excel("C:/Dropbox/Laboratorio/Carina/SDMT/SDMT_manual_REVISADO_nov2019_FINAL.xlsx", sheet = "Confiabilidade")
conf <- conf %>% type.convert()

Análise descritiva

# Análise descritiva dos dados numéricos
library(knitr)
library(psych)

# Banco de dados que será usado na elaboração das normas
kable(psych::describe(dplyr::select_if(dados, is.numeric), tr=.2), digits = 2)
vars n mean sd median trimmed mad min max range skew kurtosis se
Idade 1 587 44.50 16.39 41 42.95 19.27 18 92 74 0.43 -0.77 0.68
FaixaEtaria 2 587 3.02 1.63 3 2.88 1.48 1 7 6 0.45 -0.80 0.07
Escola 3 587 3.46 0.74 4 3.68 0.00 2 4 2 -0.96 -0.55 0.03
BAI 4 455 8.92 8.47 6 6.95 5.93 0 43 43 1.28 1.22 0.40
BDI 5 455 9.35 7.96 7 7.88 5.93 0 51 51 1.28 2.15 0.37
HADS_A 6 587 5.84 3.85 5 5.33 2.97 0 21 21 0.79 0.31 0.16
HADS_D 7 587 4.50 3.36 4 3.97 2.97 0 19 19 1.03 1.01 0.14
MMSE_SV 8 574 28.49 1.84 29 29.02 1.48 21 30 9 -1.36 1.33 0.08
SD_escr 9 586 43.94 17.14 45 44.17 16.31 2 110 108 0.28 0.77 0.71
SD_oral 10 587 47.84 18.34 50 48.16 17.79 2 110 108 0.13 0.20 0.76
SD_oral_escrito 11 587 3.98 4.90 5 4.84 5.93 -9 9 18 -0.60 -0.74 0.20
# Banco de dados parcial (somente do IBNeuro) e servirá pra correlações
kable(psych::describe(dplyr::select_if(parcial, is.numeric), tr=.2), digits = 2)
vars n mean sd median trimmed mad min max range skew kurtosis se
Idade 1 471 42.33 15.20 39 40.60 16.31 18 89 71 0.52 -0.61 0.70
BAI 2 471 9.06 8.64 7 7.05 7.41 0 45 45 1.33 1.46 0.40
BDI 3 471 9.35 7.94 7 7.87 5.93 0 51 51 1.27 2.06 0.37
HADS_A 4 471 6.15 4.05 6 5.69 4.45 0 21 21 0.67 0.05 0.19
HADS_D 5 471 4.68 3.59 4 4.13 2.97 0 19 19 0.90 0.44 0.17
Escrita 6 471 0.97 0.16 1 1.00 0.00 0 1 1 -6.00 34.12 0.01
Desenho 7 471 0.92 0.27 1 1.00 0.00 0 1 1 -3.07 7.44 0.01
VelProc 8 471 17.75 6.15 18 17.71 5.93 0 35 35 0.22 0.37 0.28
MMSE2_BV 9 471 15.47 0.95 16 15.77 0.00 8 16 8 -2.87 13.24 0.04
MMSE2_SV 10 471 28.51 2.05 29 29.13 1.48 13 30 17 -2.24 8.25 0.09
MMSE2_EV 11 471 60.44 10.30 60 60.59 8.90 25 87 62 -0.13 0.33 0.47
A1_acerto 12 471 7.11 2.29 7 6.88 2.97 0 15 15 0.50 0.22 0.11
A1_intrus 13 471 0.46 0.89 0 0.14 0.00 0 6 6 2.48 7.72 0.04
A1_repet 14 471 0.41 0.92 0 0.09 0.00 0 8 8 3.58 17.93 0.04
A5_acerto 15 471 13.15 2.51 14 13.49 2.97 0 16 16 -0.94 1.11 0.12
A5_intrus 16 471 0.17 0.45 0 0.00 0.00 0 3 3 3.20 11.92 0.02
A5_repet 17 471 1.10 1.58 0 0.60 0.00 0 8 8 1.82 3.38 0.07
BVMTR1 18 471 5.78 3.18 6 5.63 2.97 0 12 12 0.22 -0.72 0.15
BVMTR3 19 471 9.36 2.98 10 10.16 2.97 0 12 12 -1.26 0.84 0.14
SD_escr 20 470 44.66 16.04 45 44.55 14.83 6 110 104 0.61 2.00 0.74
SD_oral 21 470 50.31 18.16 51 50.29 17.05 9 110 101 0.26 0.51 0.84
SD_oral_escrito 22 470 5.65 9.92 6 5.67 8.90 -31 55 86 0.20 2.75 0.46
# Banco de dados do estudo com Ressonância Magnética
kable(psych::describe(dplyr::select_if(Ress, is.numeric), tr=.2), digits = 2)
vars n mean sd median trimmed mad min max range skew kurtosis se
Idade 1 54 36.28 9.22 34.5 35.21 6.67 18.00 61.0 43.00 0.67 0.28 1.25
Escolaridade 2 54 13.80 4.54 13.5 13.68 3.71 4.00 28.0 24.00 0.31 0.70 0.62
Comorbidades 3 54 0.17 0.38 0.0 0.00 0.00 0.00 1.0 1.00 1.74 1.05 0.05
Medicamentos 4 54 0.81 0.39 1.0 1.00 0.00 0.00 1.0 1.00 -1.58 0.49 0.05
TempoDoenca 5 52 6.80 6.24 5.5 5.53 5.93 0.25 32.0 31.75 1.60 3.33 0.87
EDSS 6 54 1.56 2.04 1.0 0.94 1.48 0.00 7.5 7.50 1.27 0.57 0.28
Passos25 7 54 7.26 2.56 7.0 6.76 2.97 4.00 15.0 11.00 1.47 2.21 0.35
pinosdir9 8 54 28.81 6.61 27.0 27.56 5.93 18.00 45.0 27.00 0.84 -0.21 0.90
pinosesq9 9 54 30.81 9.34 28.0 28.85 5.93 19.00 70.0 51.00 1.96 4.68 1.27
MedicamentoEM 10 54 0.78 0.42 1.0 0.94 0.00 0.00 1.0 1.00 -1.30 -0.32 0.06
VitD 11 54 62.73 29.98 55.5 63.23 37.06 7.00 100.0 93.00 0.09 -1.52 4.08
FSS 12 54 35.74 16.72 35.5 35.47 17.79 9.00 63.0 54.00 0.04 -1.14 2.27
HADS_A 13 54 6.43 3.97 5.5 6.09 3.71 0.00 16.0 16.00 0.44 -0.74 0.54
HADS_D 14 54 4.50 3.96 3.0 3.59 2.97 0.00 15.0 15.00 1.26 0.86 0.54
SF36 15 54 91.65 11.74 94.0 93.88 7.41 53.00 105.0 52.00 -1.86 3.42 1.60
SD_escr 16 54 44.26 15.77 47.5 43.59 21.50 11.00 77.0 66.00 0.09 -1.04 2.15
SD_oral 17 54 46.30 15.44 49.0 46.59 15.57 12.00 77.0 65.00 -0.11 -0.89 2.10
BVMT_T1 18 54 2.11 1.83 2.0 1.82 1.48 0.00 9.0 9.00 1.36 2.38 0.25
BVMT_T2 19 54 4.00 2.56 3.0 3.79 2.97 0.00 12.0 12.00 0.85 0.72 0.35
BVMT_T3 20 54 4.80 2.72 5.0 4.76 1.48 0.00 12.0 12.00 0.50 0.41 0.37
BVMT 21 54 10.91 6.65 10.0 10.53 7.41 0.00 33.0 33.00 0.88 1.26 0.91
CVLT_A1 22 54 6.30 1.66 6.0 6.00 1.48 4.00 10.0 6.00 0.59 -0.84 0.23
CVLT_A2 23 54 9.69 2.48 10.0 9.76 2.97 4.00 14.0 10.00 -0.29 -0.49 0.34
CVLT_A3 24 54 11.33 2.94 11.5 11.53 3.71 4.00 16.0 12.00 -0.38 -0.63 0.40
CVLT_A4 25 54 12.17 3.18 13.0 12.59 2.97 0.00 16.0 16.00 -1.27 2.37 0.43
CVLT_A5 26 54 12.44 3.28 14.0 13.09 2.97 1.00 16.0 15.00 -1.21 1.31 0.45
CVLT 27 54 51.93 11.73 52.5 53.09 12.60 22.00 70.0 48.00 -0.55 -0.37 1.60
CVLT_rep 28 54 7.46 5.77 6.0 6.35 4.45 0.00 27.0 27.00 1.38 1.80 0.79
MMSE_MST 29 54 53.37 9.83 53.0 53.59 9.64 31.00 81.0 50.00 0.01 0.08 1.34
VolCereb 30 54 1504.43 70.44 1514.5 1514.45 55.60 1291.00 1643.0 352.00 -0.82 0.63 9.59
VolCinz 31 54 890.75 52.32 893.0 894.04 49.67 766.00 995.0 229.00 -0.32 -0.36 7.12
LesoesFlair 32 54 9.70 8.55 6.7 7.50 5.04 1.20 38.9 37.70 1.48 1.63 1.16
LesoesImpreg 33 54 0.01 0.07 0.0 0.00 0.00 0.00 0.4 0.40 4.57 21.35 0.01
# Banco de dados do estudo de Esclerose Múltipla
kable(psych::describe(dplyr::select_if(EM, is.numeric), tr=.2), digits = 2)
vars n mean sd median trimmed mad min max range skew kurtosis se
Idade 1 256 40.68 11.88 40.0 40.03 13.34 17 72 55 0.28 -0.65 0.74
Escolaridade 2 256 12.51 4.15 12.0 12.61 3.71 1 28 27 0.07 0.96 0.26
HADS_D 3 256 6.00 3.75 5.0 5.56 2.97 0 19 19 0.79 0.43 0.23
HADS_A 4 256 7.20 4.21 6.0 6.62 2.97 0 21 21 0.77 0.32 0.26
SD_escr 5 256 34.16 15.56 33.5 33.99 15.57 0 77 77 0.12 -0.21 0.97
SD_oral 6 256 37.57 15.45 38.0 37.73 16.31 0 77 77 0.03 -0.41 0.97
EDSS 7 171 3.05 2.27 3.0 2.88 2.97 0 8 8 0.32 -1.05 0.17
A1 8 238 6.06 1.99 6.0 5.97 1.48 1 13 12 0.37 0.54 0.13
A5 9 238 11.21 3.13 11.0 11.40 4.45 1 16 15 -0.32 -0.64 0.20
A1_A5 10 238 45.16 14.16 47.0 46.13 14.83 11 75 64 -0.32 -0.57 0.92
BVMT_1 11 224 3.89 2.92 3.0 3.46 2.97 0 12 12 0.72 -0.23 0.20
BVMT_2 12 224 5.84 3.61 5.0 5.57 4.45 0 12 12 0.28 -1.11 0.24
BVMT_3 13 224 6.78 3.90 6.0 6.85 5.93 0 12 12 -0.02 -1.33 0.26
BVMT_total 14 224 16.48 9.78 15.5 15.85 12.60 1 36 35 0.27 -1.10 0.65
# Banco de dados do estudo Caso-Controle
kable(psych::describe(dplyr::select_if(caso, is.numeric), tr=.2), digits = 2)
vars n mean sd median trimmed mad min max range skew kurtosis se
Idade 1 26 30.46 4.81 31.00 30.31 2.97 21.00 45.00 24.00 0.66 1.85 0.94
Escolaridade 2 26 14.92 3.19 15.00 14.75 4.45 8.00 20.00 12.00 -0.05 -1.02 0.62
EDSS 3 26 0.54 1.09 0.00 0.12 0.00 0.00 4.50 4.50 2.15 4.28 0.21
Grupo 4 26 0.54 0.51 1.00 0.56 0.00 0.00 1.00 1.00 -0.15 -2.05 0.10
A1 5 26 7.19 2.10 7.00 7.00 2.97 4.00 12.00 8.00 0.43 -0.96 0.41
A2 6 26 10.31 2.00 10.00 10.00 1.48 7.00 15.00 8.00 0.72 -0.22 0.39
A3 7 26 11.88 2.52 12.00 12.06 2.97 5.00 16.00 11.00 -0.51 0.16 0.49
A4 8 26 12.19 3.41 13.00 12.81 2.97 0.00 16.00 16.00 -1.73 3.74 0.67
A5 9 26 12.92 3.35 14.00 13.56 2.97 1.00 16.00 15.00 -1.72 3.58 0.66
Total_A1_A5 10 26 54.50 11.28 55.50 54.94 9.64 23.00 75.00 52.00 -0.62 0.62 2.21
CVLT _rep 11 26 5.58 5.52 4.00 4.56 5.93 0.00 20.00 20.00 1.02 0.28 1.08
BVMT_T1 12 26 4.81 4.22 2.00 4.12 1.48 0.00 12.00 12.00 0.48 -1.57 0.83
BVMT_T2 13 26 6.96 4.09 6.00 6.81 4.45 0.00 12.00 12.00 0.09 -1.68 0.80
BVMT_T3 14 26 7.88 3.59 7.00 8.00 4.45 1.00 12.00 11.00 -0.08 -1.56 0.70
BVMT 15 26 19.65 11.54 15.50 18.94 11.86 1.00 36.00 35.00 0.15 -1.69 2.26
SD_escr 16 26 49.81 12.62 51.00 51.50 12.60 23.00 68.00 45.00 -0.57 -0.72 2.48
SD_oral 17 26 52.69 13.67 52.50 53.69 17.05 23.00 75.00 52.00 -0.38 -0.72 2.68
Oral_Escrito 18 26 2.88 5.46 1.50 1.88 3.71 -8.00 19.00 27.00 1.01 1.30 1.07
HADS_A 19 26 6.54 3.85 5.00 5.94 2.97 1.00 14.00 13.00 0.57 -1.01 0.75
HADS_D 20 26 4.27 4.11 3.00 3.12 2.97 0.00 15.00 15.00 1.29 0.59 0.81
HPT9_RH 21 26 23.64 5.81 21.30 22.44 4.89 17.91 39.00 21.09 1.13 0.46 1.14
HPT9_LH 22 26 24.67 6.82 22.20 23.35 4.41 18.00 51.00 33.00 2.20 5.89 1.34
HPT9_total 23 26 24.15 6.04 21.34 23.02 4.00 18.00 45.00 27.00 1.62 2.97 1.18
VolCereb 24 14 1540.73 32.58 1534.00 1536.22 33.58 1503.00 1603.00 100.00 0.52 -1.16 8.71
VolCinz 25 14 903.11 27.38 905.50 900.77 26.17 860.80 952.00 91.20 0.35 -0.95 7.32
lesoesflair 26 14 10.65 5.39 10.60 10.60 6.52 1.50 19.64 18.14 0.00 -1.28 1.44
lesoesimpreg 27 14 0.04 0.12 0.00 0.00 0.00 0.00 0.40 0.40 2.23 3.72 0.03
# Banco de dados do estudo de Confiabilidade Teste-Reteste
kable(psych::describe(dplyr::select_if(conf, is.numeric), tr=.2), digits = 2)
vars n mean sd median trimmed mad min max range skew kurtosis se
Idade 1 98 60.87 13.44 62.0 61.80 8.90 22 92 70 -0.50 0.60 1.36
Escolaridade 2 98 9.76 5.36 11.0 9.43 7.41 1 27 26 0.34 -0.34 0.54
SD_escr_teste 3 98 29.42 13.28 29.5 29.02 14.83 5 69 64 0.25 -0.53 1.34
SD_oral_teste 4 98 31.62 14.93 32.0 30.88 16.31 2 70 68 0.35 -0.36 1.51
SD_escr_reteste 5 91 31.34 14.47 32.0 31.49 17.79 0 70 70 0.01 -0.65 1.52
SD_oral_reteste 6 91 33.56 14.52 34.0 33.53 16.31 0 68 68 0.01 -0.53 1.52
alter_escr 7 75 23.48 11.15 23.0 23.00 13.34 0 47 47 0.15 -0.83 1.29
altern_oral 8 75 25.40 11.28 25.0 25.00 13.34 4 50 46 0.16 -0.74 1.30

Análise gráfica

library(DataExplorer)

# Análise gráfica dos dados normativos
plot_missing(dados)

plot_histogram(dados)

plot_density(dados)

plot_correlation(dados, type = 'continuous', cor_args = list("use" = "pairwise.complete.obs"))

plot_correlation(dados, type = 'discrete', cor_args = list("use" = "pairwise.complete.obs"))

plot_bar(dados)

# Proporções das categorias demográficas
kable(table(dados$Regiao, dados$Escolaridade))
Fundamental Medio Superior
CO 10 41 135
N 3 3 10
NE 5 6 6
S 28 47 131
SE 43 44 75
# Porcentagem das categorias demográficas
kable(prop.table(table(dados$Regiao, dados$Escolaridade)) %>% {. * 100} %>% 
round(1))
Fundamental Medio Superior
CO 1.7 7.0 23.0
N 0.5 0.5 1.7
NE 0.9 1.0 1.0
S 4.8 8.0 22.3
SE 7.3 7.5 12.8
# Gráfico da porcentagem das categorias demográficas
plot(prop.table(table(dados$Escolaridade, dados$Regiao)) %>% {. * 100}, main = "")

# Densidades coloridas e padronizadas
library(hrbrthemes)
library(viridis)

data <- dados %>% 
  gather(key="text", value="value") %>%
  mutate(text = gsub("\\.", " ",text)) %>%
  mutate(value = round(as.numeric(value),0)) %>%
  filter(text %in% c("BAI","BDI","HADS_A","HADS_D","MMSE_SV","SD_escr","SD_oral"))

library(ggridges)

data %>%
  mutate(text = fct_reorder(text, value)) %>%
  ggplot( aes(y=text, x=scale(value),  fill=text)) +
    geom_density_ridges(alpha=0.6, bandwidth=1) +
    scale_fill_viridis(discrete=TRUE) +
    scale_color_viridis(discrete=TRUE) +
    theme_ipsum() +
    theme(
      legend.position="none",
      panel.spacing = unit(0.1, "lines"),
      strip.text.x = element_text(size = 8)
    ) +
    xlab("Escore z") +
    ylab("Variáveis")

Bancos SDMT

# Cria um banco pra predição do SDMT Escrito e para o SDMT Oral
Escr <- parcial %>% 
  dplyr::select(c(Regiao:HADS_D, VelProc:BVMTR3, SD_escr))
Escr <- Escr %>% type.convert()
Escr <- na.omit(Escr)
Escr <- as.data.frame(Escr)

Oral <- parcial %>% 
  dplyr::select(c(Regiao:HADS_D, VelProc:BVMTR3, SD_oral))
Oral <- Oral %>% type.convert()
Oral <- na.omit(Oral)
Oral <- as.data.frame(Oral)

Arvores de inferência condicional

# Gera árvores de inferência condicional para o SDMT Oral e para o SDMT Escrito
library(partykit)

# Explorando as variáveis (do banco Normativo) que possam predizer o escore do SDMT Escrito
tree_escr <- ctree(SD_escr ~ ., Escr)
plot(tree_escr)

#plot(tree_escr, tp_args = list(col = "blue"))

# Explorando as variáveis (do banco Normativo) que possam predizer o escore do SDMT Oral
tree_oral <- ctree(SD_oral ~ ., Oral)
plot(tree_oral)

SDMT Escrito

library(partykit)
# Explorando as variáveis demográficas relevantes para gerar as tabelas normativas do SDMT Escrito
tree_escr <- party::ctree(SD_escr ~ Regiao + Idade + Escolaridade + Sexo, data = Escr)
plot(tree_escr)

detach("package:partykit", unload=TRUE)
library(party)

# Obtenção das médias, medianas, DP e SSEs das árvores condicionais
t(sapply(unique(where(tree_escr)), function(x) {
    n <- nodes(tree_escr, x)[[1]]
    SD_escr <- Escr[as.logical(n$weights), "SD_escr"]
    cbind.data.frame("Node" = as.integer(x),
                     psych::describe(SD_escr, quant=c(.25,.50,.75), skew = FALSE),
                     "SSE" = sum((SD_escr - mean(SD_escr))^2))  
}))
##      Node vars n   mean     sd       min max range se        Q0.25 Q0.5 Q0.75
## [1,] 15   1    19  17.21053 6.712997 6   30  24    1.540067  12    18   21.5 
## [2,] 10   1    65  42       14.36141 17  110 93    1.781313  33    40   46   
## [3,] 8    1    10  32.6     9.347608 20  48  28    2.955973  25.75 34   38.75
## [4,] 14   1    25  23.72    8.408924 12  54  42    1.681785  19    21   27   
## [5,] 13   1    45  33.8     11.35501 11  50  39    1.692706  24    32   46   
## [6,] 5    1    15  52.73333 10.78005 39  76  37    2.783397  43.5  50   61   
## [7,] 3    1    245 52.0898  13.57795 25  110 85    0.8674635 44    50   58   
## [8,] 7    1    46  42.17391 10.15722 14  68  54    1.4976    35.25 42.5 48.75
##      SSE     
## [1,] 811.1579
## [2,] 13200   
## [3,] 786.4   
## [4,] 1697.04 
## [5,] 5673.2  
## [6,] 1626.933
## [7,] 44984.02
## [8,] 4642.609

SDMT Oral

library(partykit)
detach("package:partykit", unload=TRUE)
library(party)

# Explorando as variáveis demográficas relevantes para gerar as tabelas normativas do SDMT Oral
tree_oral <- party::ctree(SD_oral ~ Regiao + Idade + Escolaridade + Sexo, data = Oral)
plot(tree_oral)

# Obtenção das médias, medianas, DP e SSEs das árvores condicionais
t(sapply(unique(where(tree_oral)), function(x) {
    n <- nodes(tree_oral, x)[[1]]
    SD_oral <- Oral[as.logical(n$weights), "SD_oral"]
    cbind.data.frame("Node" = as.integer(x),
                     psych::describe(SD_oral, quant=c(.25,.50,.75), skew = FALSE),
                     "SSE" = sum((SD_oral - mean(SD_oral))^2))  
}))
##      Node vars n   mean     sd       min max range se        Q0.25 Q0.5 Q0.75
## [1,] 13   1    8   17.25    9.528154 9   33  24    3.368711  9     15   22   
## [2,] 9    1    58  43.86207 14.33123 10  82  72    1.881783  34    43   51   
## [3,] 10   1    50  36.56    14.49723 9   62  53    2.050219  24.5  36   49.75
## [4,] 6    1    28  39.25    13.91409 11  60  49    2.629516  29    44   50   
## [5,] 12   1    28  29.5     8.094351 14  52  38    1.529689  24.75 29.5 33.25
## [6,] 5    1    46  52.56522 14.92746 21  93  72    2.200934  41.25 51.5 62.25
## [7,] 3    1    252 58.69841 15.57645 9   110 101   0.9812242 50    58   67   
##      SSE     
## [1,] 635.5   
## [2,] 11706.9 
## [3,] 10298.32
## [4,] 5227.25 
## [5,] 1769    
## [6,] 10027.3 
## [7,] 60899.08

Parâmetros adicionais

library(strucchange)
library(partykit)
tree_oral <- partykit::ctree(SD_oral ~ Regiao + Idade + Escolaridade + Sexo, data = Oral)
sctest(tree_oral, node = 1)
##               Regiao        Idade Escolaridade       Sexo
## statistic 9.27905799 1.212839e+02 1.087457e+02 6.96634966
## p.value   0.03809244 1.324753e-27 9.732428e-24 0.03281109
nodeapply(tree_oral, ids = nodeids(tree_oral), function(n) info_node(n)$p.value)
## $`1`
##        Idade 
## 1.324753e-27 
## 
## $`2`
## Escolaridade 
## 2.221176e-07 
## 
## $`3`
##       Idade 
## 0.003373876 
## 
## $`4`
##    Idade 
## 0.746904 
## 
## $`5`
## Escolaridade 
##    0.1003573 
## 
## $`6`
##     Idade 
## 0.1431062 
## 
## $`7`
## Escolaridade 
## 1.827919e-06 
## 
## $`8`
##      Idade 
## 0.01290161 
## 
## $`9`
##       Sexo 
## 0.07621009 
## 
## $`10`
## NULL
## 
## $`11`
## Escolaridade 
##   0.04160667 
## 
## $`12`
##    Regiao 
## 0.1159515 
## 
## $`13`
##     Idade 
## 0.5037684
tab <- tapply(Oral$SD_oral, predict(tree_oral, type = "node"),
  function(y) c("n" = length(y), 100 * prop.table(table(y))))
do.call("rbind", tab)
##      n          9         23         27         29        30        31
## 4   46  2.1739130  4.3478261  4.3478261  2.1739130  4.347826 4.3478261
## 5   28  3.5714286  3.5714286  3.5714286  3.5714286  3.571429 3.5714286
## 6  252  0.3968254  0.3968254  0.3968254  0.3968254  1.587302 0.3968254
## 9   28  3.5714286  7.1428571  3.5714286  3.5714286  3.571429 3.5714286
## 10   8 37.5000000 12.5000000 25.0000000 12.5000000 12.500000 8.0000000
## 12  50  2.0000000  4.0000000  4.0000000  6.0000000  4.000000 6.0000000
## 13  58  1.7241379  1.7241379  1.7241379  3.4482759  1.724138 1.7241379
##            32         34         35        36         37        38         39
## 4   4.3478261  4.3478261  6.5217391  2.173913  2.1739130 6.5217391  2.1739130
## 5   7.1428571  3.5714286  7.1428571  3.571429  3.5714286 3.5714286  3.5714286
## 6   0.3968254  0.3968254  0.7936508  1.984127  0.7936508 0.7936508  0.7936508
## 9   7.1428571  3.5714286  3.5714286 10.714286  7.1428571 3.5714286  3.5714286
## 10 37.5000000 12.5000000 25.0000000 12.500000 12.5000000 8.0000000 37.5000000
## 12  2.0000000  2.0000000  2.0000000  6.000000  4.0000000 2.0000000  4.0000000
## 13  3.4482759  5.1724138  8.6206897  3.448276  6.8965517 1.7241379  1.7241379
##           42        43         44        45       46        47        48
## 4   4.347826  2.173913  4.3478261  2.173913 4.347826  2.173913  2.173913
## 5   7.142857  3.571429 14.2857143  3.571429 3.571429  3.571429  3.571429
## 6   1.587302  1.190476  0.7936508  2.777778 2.777778  1.984127  1.190476
## 9  10.714286  3.571429  3.5714286  3.571429 3.571429  3.571429  3.571429
## 10 12.500000 25.000000 12.5000000 12.500000 8.000000 37.500000 12.500000
## 12  2.000000  4.000000  2.0000000  2.000000 2.000000  4.000000  2.000000
## 13  1.724138  1.724138  5.1724138  3.448276 3.448276  5.172414  3.448276
##           49        50        51       52        53        54        55
## 4   2.173913  2.173913  4.347826 2.173913  2.173913  2.173913  4.347826
## 5   3.571429  3.571429 28.000000 3.571429  3.571429  3.571429  3.571429
## 6   2.777778  3.174603  4.365079 3.571429  3.571429  1.587302  1.587302
## 9   3.571429 28.000000  3.571429 7.142857  3.571429  3.571429  3.571429
## 10 25.000000 12.500000 12.500000 8.000000 37.500000 12.500000 25.000000
## 12  2.000000  4.000000  2.000000 4.000000  2.000000  2.000000  2.000000
## 13  1.724138  1.724138  5.172414 1.724138  3.448276  1.724138  3.448276
##           56        57       58        59        60        61        62
## 4   2.173913  2.173913 2.173913  2.173913 46.000000  2.173913  4.347826
## 5   3.571429  3.571429 7.142857  3.571429  7.142857  3.571429  3.571429
## 6   3.571429  2.380952 3.174603  3.174603  3.968254  5.555556  2.380952
## 9   3.571429  7.142857 3.571429  3.571429 10.714286  7.142857  3.571429
## 10 12.500000 12.500000 8.000000 37.500000 12.500000 25.000000 12.500000
## 12  2.000000  6.000000 2.000000  4.000000  2.000000 50.000000  2.000000
## 13  1.724138  3.448276 1.724138  1.724138  1.724138  1.724138  1.724138
##           63        64        65         66        67        68        69
## 4   4.347826  2.173913  4.347826  4.3478261  4.347826  4.347826  6.521739
## 5   3.571429  3.571429  7.142857  3.5714286 14.285714  3.571429  3.571429
## 6   3.174603  1.190476  2.380952  0.7936508  1.587302  1.190476  1.984127
## 9   3.571429 10.714286  3.571429  3.5714286  3.571429  3.571429  3.571429
## 10 12.500000  8.000000 37.500000 12.5000000 25.000000 12.500000 12.500000
## 12  4.000000  4.000000  6.000000  4.0000000  6.000000  2.000000  2.000000
## 13 58.000000  1.724138  1.724138  1.7241379  3.448276  1.724138  1.724138
##          70        71         72        73        74        75       76
## 4  2.173913  2.173913  6.5217391  2.173913  4.347826  2.173913 4.347826
## 5  3.571429  3.571429  3.5714286  3.571429 28.000000  3.571429 3.571429
## 6  1.587302  2.380952  0.3968254  1.190476  2.380952  1.190476 1.190476
## 9  3.571429  3.571429 28.0000000  3.571429  7.142857  3.571429 3.571429
## 10 8.000000 37.500000 12.5000000 25.000000 12.500000 12.500000 8.000000
## 12 2.000000  6.000000  4.0000000  2.000000  4.000000  2.000000 4.000000
## 13 3.448276  5.172414  8.6206897  3.448276  6.896552  1.724138 1.724138
##           77        78        79         80         81         83         85
## 4   2.173913  4.347826  2.173913  2.1739130  2.1739130  2.1739130  4.3478261
## 5   3.571429  3.571429  3.571429  3.5714286  7.1428571  3.5714286  7.1428571
## 6   1.190476  1.984127  1.190476  0.7936508  0.3968254  0.3968254  0.3968254
## 9   3.571429  3.571429  7.142857  3.5714286  3.5714286 10.7142857  7.1428571
## 10 37.500000 12.500000 25.000000 12.5000000 12.5000000  8.0000000 37.5000000
## 12  2.000000  2.000000  2.000000  4.0000000  2.0000000  2.0000000  4.0000000
## 13  1.724138  1.724138  5.172414  3.4482759  3.4482759  5.1724138  3.4482759
##            87         92         95         97       106        107       110
## 4   2.1739130  2.1739130  2.1739130  4.3478261 2.1739130  2.1739130  2.173913
## 5   3.5714286  3.5714286  3.5714286  3.5714286 7.1428571  3.5714286 14.285714
## 6   0.3968254  0.3968254  0.7936508  0.3968254 0.3968254  0.3968254  1.587302
## 9   3.5714286  3.5714286 10.7142857  3.5714286 3.5714286  3.5714286  3.571429
## 10 12.5000000 25.0000000 12.5000000 12.5000000 8.0000000 37.5000000 12.500000
## 12  2.0000000  4.0000000  2.0000000  2.0000000 2.0000000  2.0000000  6.000000
## 13  1.7241379  1.7241379  5.1724138  1.7241379 3.4482759  1.7241379  3.448276
tree_escr <- partykit::ctree(SD_escr ~ Regiao + Idade + Escolaridade + Sexo, data = Escr)
sctest(tree_escr, node = 1)
##              Regiao        Idade Escolaridade      Sexo
## statistic 3.5376213 1.282718e+02 1.274068e+02 4.4901492
## p.value   0.5266408 3.915127e-29 8.630209e-28 0.1295469
nodeapply(tree_escr, ids = nodeids(tree_escr), function(n) info_node(n)$p.value)
## $`1`
##        Idade 
## 3.915127e-29 
## 
## $`2`
## Escolaridade 
##  2.38226e-06 
## 
## $`3`
##       Idade 
## 0.002508197 
## 
## $`4`
## NULL
## 
## $`5`
## Escolaridade 
##   0.03803933 
## 
## $`6`
## NULL
## 
## $`7`
##    Regiao 
## 0.6914571 
## 
## $`8`
##      Idade 
## 0.07815086 
## 
## $`9`
## Escolaridade 
## 1.391909e-10 
## 
## $`10`
##        Idade 
## 2.968167e-05 
## 
## $`11`
## Escolaridade 
##  0.001613891 
## 
## $`12`
##    Regiao 
## 0.9457338 
## 
## $`13`
##     Idade 
## 0.2356542 
## 
## $`14`
## NULL
## 
## $`15`
##     Idade 
## 0.1928753
tab <- tapply(Escr$SD_escr, predict(tree_escr, type = "node"),
  function(y) c("n" = length(y), 100 * prop.table(table(y))))
do.call("rbind", tab)
##      n         25        29        30         31         32        33        34
## 4   15  6.6666667  6.666667  6.666667  6.6666667  6.6666667  6.666667  6.666667
## 6   10 20.0000000 10.000000 10.000000 20.0000000 10.0000000 10.000000 10.000000
## 7   46  2.1739130  2.173913  2.173913  2.1739130  2.1739130  4.347826  2.173913
## 8  245  0.4081633  1.224490  1.224490  0.8163265  0.8163265  1.224490  2.040816
## 12  25  4.0000000  4.000000 12.000000  4.0000000 12.0000000  8.000000  8.000000
## 13  45  2.2222222  4.444444  2.222222  4.4444444  2.2222222  4.444444  2.222222
## 14  19  5.2631579  5.263158 10.526316 10.5263158  5.2631579  5.263158  5.263158
## 15  65  1.5384615  3.076923  3.076923  1.5384615  3.0769231  6.153846  6.153846
##           35         36        37        38        39        40         41
## 4   6.666667  6.6666667  6.666667 13.333333  6.666667  6.666667  6.6666667
## 6  10.000000 10.0000000 20.000000 10.000000 10.000000 20.000000 10.0000000
## 7   6.521739  2.1739130  2.173913  4.347826  2.173913  4.347826  4.3478261
## 8   2.040816  0.4081633  2.448980  1.224490  2.040816  1.224490  0.4081633
## 12  8.000000  4.0000000 12.000000  4.000000  4.000000  8.000000  4.0000000
## 13  8.888889  4.4444444  6.666667  2.222222  6.666667  2.222222  4.4444444
## 14 10.526316 15.7894737 15.789474  5.263158  5.263158 19.000000  5.2631579
## 15  1.538462  1.5384615  6.153846  3.076923  1.538462  3.076923  4.6153846
##           42        43        44        45        46        47        48
## 4  15.000000  6.666667  6.666667  6.666667  6.666667  6.666667  6.666667
## 6  10.000000 10.000000 10.000000 10.000000 20.000000 10.000000 10.000000
## 7   4.347826  2.173913  6.521739 10.869565  4.347826  2.173913  2.173913
## 8   2.040816  2.857143  3.673469  2.857143  4.489796  5.714286  2.040816
## 12  4.000000 25.000000  4.000000  4.000000 12.000000  4.000000 12.000000
## 13  4.444444  2.222222  2.222222  2.222222  2.222222  2.222222  6.666667
## 14  5.263158 10.526316 10.526316  5.263158  5.263158  5.263158 10.526316
## 15  4.615385  4.615385  9.230769  4.615385  3.076923  3.076923  1.538462
##           49        50        51        52        53        54        55
## 4   6.666667  6.666667  6.666667  6.666667 13.333333  6.666667  6.666667
## 6  20.000000 10.000000 10.000000 10.000000 10.000000 10.000000 20.000000
## 7   4.347826  2.173913  2.173913  4.347826  4.347826  4.347826  2.173913
## 8   3.673469  5.306122  3.265306  3.265306  1.224490  3.673469  2.040816
## 12  8.000000  8.000000  8.000000  4.000000 12.000000  4.000000  4.000000
## 13  8.888889  2.222222  8.888889 45.000000  2.222222  4.444444  2.222222
## 14 15.789474 15.789474  5.263158  5.263158 19.000000  5.263158  5.263158
## 15  3.076923  3.076923  1.538462  1.538462  1.538462  1.538462  1.538462
##           56        57        58        59        60        61        62
## 4   6.666667 15.000000  6.666667  6.666667  6.666667  6.666667  6.666667
## 6  10.000000 10.000000 20.000000 10.000000 10.000000 10.000000 10.000000
## 7  46.000000  2.173913  2.173913  2.173913  2.173913  2.173913  4.347826
## 8   4.489796  4.489796  2.448980  2.448980  2.448980  1.632653  1.632653
## 12  8.000000  4.000000  4.000000 25.000000  4.000000  4.000000 12.000000
## 13  4.444444  2.222222  4.444444  2.222222  8.888889  4.444444  6.666667
## 14 10.526316 10.526316  5.263158  5.263158  5.263158 10.526316 15.789474
## 15  3.076923  1.538462  1.538462  1.538462  1.538462 65.000000  1.538462
##           63        64        65        66        67         68        69
## 4   6.666667  6.666667  6.666667  6.666667  6.666667 13.3333333  6.666667
## 6  10.000000 20.000000 10.000000 10.000000 20.000000 10.0000000 10.000000
## 7   2.173913  6.521739  2.173913  2.173913  4.347826  2.1739130  4.347826
## 8   2.448980  1.632653  2.040816  2.040816  1.224490  0.4081633  1.632653
## 12  4.000000 12.000000  8.000000  8.000000  8.000000  4.0000000 12.000000
## 13  2.222222  6.666667  2.222222  4.444444  4.444444  2.2222222  2.222222
## 14 15.789474  5.263158  5.263158 19.000000  5.263158  5.2631579 10.526316
## 15  3.076923  3.076923  1.538462  3.076923  6.153846  6.1538462  1.538462
##            73         74         76         81         82         90         91
## 4   6.6666667  6.6666667 15.0000000  6.6666667  6.6666667  6.6666667  6.6666667
## 6  10.0000000 10.0000000 10.0000000 20.0000000 10.0000000 10.0000000 20.0000000
## 7   4.3478261  4.3478261  2.1739130  6.5217391 10.8695652  4.3478261  2.1739130
## 8   0.4081633  0.8163265  0.4081633  0.4081633  0.4081633  0.8163265  0.4081633
## 12  4.0000000  4.0000000  8.0000000  4.0000000  4.0000000 25.0000000  4.0000000
## 13  2.2222222  2.2222222  2.2222222  6.6666667  8.8888889  2.2222222  8.8888889
## 14 10.5263158  5.2631579  5.2631579  5.2631579 10.5263158 15.7894737 15.7894737
## 15  1.5384615  6.1538462  3.0769231  1.5384615  3.0769231  4.6153846  4.6153846
##           109       110
## 4   6.6666667  6.666667
## 6  10.0000000 10.000000
## 7   2.1739130  4.347826
## 8   0.4081633  1.224490
## 12  4.0000000 12.000000
## 13 45.0000000  2.222222
## 14  5.2631579  5.263158
## 15  4.6153846  9.230769

Regressões múltiplas

fit1 <- lm(SD_escr ~ Escolaridade + Idade + Sexo + Regiao, data = dados)
apaTables::apa.reg.table(fit1)
## 
## 
## Regression results using SD_escr as the criterion
##  
## 
##             Predictor       b       b_95%_CI sr2  sr2_95%_CI             Fit
##           (Intercept) 55.29** [50.10, 60.48]                                
##     EscolaridadeMedio  7.35**  [3.91, 10.80] .02  [.00, .03]                
##  EscolaridadeSuperior 14.61** [11.36, 17.86] .07  [.04, .10]                
##                 Idade -0.49** [-0.56, -0.42] .17  [.13, .22]                
##         SexoMasculino    1.87  [-0.28, 4.03] .00 [-.00, .01]                
##               RegiaoN    6.17 [-0.16, 12.49] .00 [-.00, .01]                
##              RegiaoNE    1.91  [-4.29, 8.10] .00 [-.00, .00]                
##               RegiaoS   -0.44  [-2.90, 2.02] .00 [-.00, .00]                
##              RegiaoSE   -2.47  [-5.20, 0.27] .00 [-.00, .01]                
##                                                                  R2 = .492**
##                                                              95% CI[.43,.53]
##                                                                             
## 
## Note. A significant b-weight indicates the semi-partial correlation is also significant.
## b represents unstandardized regression weights. 
## sr2 represents the semi-partial correlation squared.
## Square brackets are used to enclose the lower and upper limits of a confidence interval.
## * indicates p < .05. ** indicates p < .01.
## 
fit2 <- lm(SD_oral ~ Escolaridade + Idade + Sexo + Regiao, data = dados)
apaTables::apa.reg.table(fit2)
## 
## 
## Regression results using SD_oral as the criterion
##  
## 
##             Predictor       b       b_95%_CI sr2  sr2_95%_CI             Fit
##           (Intercept) 60.13** [54.47, 65.78]                                
##     EscolaridadeMedio  7.42**  [3.65, 11.18] .01 [-.00, .03]                
##  EscolaridadeSuperior 14.94** [11.38, 18.49] .06  [.03, .09]                
##                 Idade -0.50** [-0.57, -0.42] .15  [.11, .20]                
##         SexoMasculino   2.81*   [0.46, 5.16] .01 [-.00, .01]                
##               RegiaoN    3.12 [-3.79, 10.02] .00 [-.00, .00]                
##              RegiaoNE   -1.92  [-8.69, 4.84] .00 [-.00, .00]                
##               RegiaoS   -1.52  [-4.21, 1.16] .00 [-.00, .01]                
##              RegiaoSE -5.01** [-8.00, -2.03] .01 [-.00, .02]                
##                                                                  R2 = .471**
##                                                              95% CI[.41,.51]
##                                                                             
## 
## Note. A significant b-weight indicates the semi-partial correlation is also significant.
## b represents unstandardized regression weights. 
## sr2 represents the semi-partial correlation squared.
## Square brackets are used to enclose the lower and upper limits of a confidence interval.
## * indicates p < .05. ** indicates p < .01.
## 

Interações

# Mostra as interações da Idade com a Escolaridade (quando houver)
library(jtools)
library(interactions)

summ(fit1)
Observations 586 (1 missing obs. deleted)
Dependent variable SD_escr
Type OLS linear regression
F(8,577) 69.78
0.49
Adj. R² 0.48
Est. S.E. t val. p
(Intercept) 55.29 2.64 20.92 0.00
EscolaridadeMedio 7.35 1.76 4.19 0.00
EscolaridadeSuperior 14.61 1.66 8.82 0.00
Idade -0.49 0.04 -13.99 0.00
SexoMasculino 1.87 1.10 1.71 0.09
RegiaoN 6.17 3.22 1.92 0.06
RegiaoNE 1.91 3.16 0.60 0.55
RegiaoS -0.44 1.25 -0.35 0.72
RegiaoSE -2.47 1.39 -1.77 0.08
Standard errors: OLS
summ(fit1, scale = TRUE)
Observations 586 (1 missing obs. deleted)
Dependent variable SD_escr
Type OLS linear regression
F(8,577) 69.78
0.49
Adj. R² 0.48
Est. S.E. t val. p
(Intercept) 33.29 1.73 19.22 0.00
EscolaridadeMedio 7.35 1.76 4.19 0.00
EscolaridadeSuperior 14.61 1.66 8.82 0.00
Idade -8.09 0.58 -13.99 0.00
Sexo 1.87 1.10 1.71 0.09
RegiaoN 6.17 3.22 1.92 0.06
RegiaoNE 1.91 3.16 0.60 0.55
RegiaoS -0.44 1.25 -0.35 0.72
RegiaoSE -2.47 1.39 -1.77 0.08
Standard errors: OLS; Continuous predictors are mean-centered and scaled by 1 s.d.
interact_plot(fit1, pred = "Idade", modx = "Escolaridade")

# Plot with transparency
#png(file = "C:/Users/danil/Desktop/Rplot.png", bg = "transparent",
#    type = c("cairo"), width=2400, height=1800, res=300)
interact_plot(fit1, pred = "Idade", modx = "Escolaridade", interval = TRUE, int.width = 0.8,
              x.label = "Idade", y.label = "SDMT Escrito", main.title = "")

#dev.off()

summ(fit2)
Observations 587
Dependent variable SD_oral
Type OLS linear regression
F(8,578) 64.34
0.47
Adj. R² 0.46
Est. S.E. t val. p
(Intercept) 60.13 2.88 20.88 0.00
EscolaridadeMedio 7.42 1.92 3.87 0.00
EscolaridadeSuperior 14.94 1.81 8.26 0.00
Idade -0.50 0.04 -12.95 0.00
SexoMasculino 2.81 1.20 2.35 0.02
RegiaoN 3.12 3.51 0.89 0.38
RegiaoNE -1.92 3.45 -0.56 0.58
RegiaoS -1.52 1.37 -1.12 0.26
RegiaoSE -5.01 1.52 -3.30 0.00
Standard errors: OLS
summ(fit2, scale = TRUE)
Observations 587
Dependent variable SD_oral
Type OLS linear regression
F(8,578) 64.34
0.47
Adj. R² 0.46
Est. S.E. t val. p
(Intercept) 37.93 1.89 20.08 0.00
EscolaridadeMedio 7.42 1.92 3.87 0.00
EscolaridadeSuperior 14.94 1.81 8.26 0.00
Idade -8.17 0.63 -12.95 0.00
Sexo 2.81 1.20 2.35 0.02
RegiaoN 3.12 3.51 0.89 0.38
RegiaoNE -1.92 3.45 -0.56 0.58
RegiaoS -1.52 1.37 -1.12 0.26
RegiaoSE -5.01 1.52 -3.30 0.00
Standard errors: OLS; Continuous predictors are mean-centered and scaled by 1 s.d.
interact_plot(fit2, pred = "Idade", modx = "Escolaridade")

# Plot with transparency
#png(file = "C:/Users/danil/Desktop/Rplot.png", bg = "transparent",
#    type = c("cairo"), width=2400, height=1800, res=300)
interact_plot(fit2, pred = "Idade", modx = "Escolaridade", interval = TRUE, int.width = 0.8,
              x.label = "Idade", y.label = "SDMT Oral", main.title = "")

#dev.off()

Teste Reteste

Escrito

library(WRS2)
# Correlação robusta Teste-Reteste do SDMT Escrito
pbcor(conf$SD_escr_teste, conf$SD_escr_reteste)
## Call:
## pbcor(x = conf$SD_escr_teste, y = conf$SD_escr_reteste)
## 
## Robust correlation coefficient: 0.9532
## Test statistic: 29.738
## p-value: 0
ggplot(conf) +
 aes(x = SD_escr_teste, y = SD_escr_reteste, colour = Idade, size = Escolaridade) +
 geom_point() +
 geom_smooth(span = 0.75) +
 scale_color_gradient() +
 labs(title = "SDMT Escrito", x = "Teste", y = "Reteste") +
 theme_minimal()

Oral

# Correlação robusta Teste-Reteste do SDMT Escrito
pbcor(conf$SD_oral_teste, conf$SD_oral_reteste)
## Call:
## pbcor(x = conf$SD_oral_teste, y = conf$SD_oral_reteste)
## 
## Robust correlation coefficient: 0.9198
## Test statistic: 22.1129
## p-value: 0
ggplot(conf) +
 aes(x = SD_oral_teste, y = SD_oral_reteste, colour = Idade, size = Escolaridade) +
 geom_point() +
 geom_smooth(span = 0.75) +
 scale_color_gradient() +
 labs(title = "SDMT Oral", x = "Teste", y = "Reteste") +
 theme_minimal()

Medidas clínicas

Análise de cluster RM

library(cluster)

# Seleciona variáveis do banco de dados da Ressonância
dados2 <- na.omit(Ress[c(8:15, 17:38)])

# Kmeans clustering (2 clusters)
dados3 <- prcomp(dados2, center = FALSE, scale. = FALSE)$x %>% as.data.frame()
km.cluster <- kmeans(dados3, centers = 2, iter.max = 20, nstart = 2)
dados3$kmeans.cluster <- km.cluster$cluster

ggplot(dados3) +
  aes(x = PC1, y = PC2, colour = as.factor(kmeans.cluster)) +
  geom_point(size = 2L) +
  scale_color_hue() +
  labs(x = "PC1", y = "PC2", title = "Kmeans Clustering", color = "Clusters") +
  theme_minimal()

Gráficos RM

library(DataExplorer)
colnames(Ress)
##  [1] "Idade"         "Sexo"          "Escolaridade"  "Trabalha"     
##  [5] "Profissao"     "Civil"         "Comorbidades"  "Medicamentos" 
##  [9] "TempoDoenca"   "EDSS"          "Passos25"      "pinosdir9"    
## [13] "pinosesq9"     "MedicamentoEM" "VitD"          "Lateralidade" 
## [17] "FSS"           "HADS_A"        "HADS_D"        "SF36"         
## [21] "SD_escr"       "SD_oral"       "BVMT_T1"       "BVMT_T2"      
## [25] "BVMT_T3"       "BVMT"          "CVLT_A1"       "CVLT_A2"      
## [29] "CVLT_A3"       "CVLT_A4"       "CVLT_A5"       "CVLT"         
## [33] "CVLT_rep"      "MMSE_MST"      "VolCereb"      "VolCinz"      
## [37] "LesoesFlair"   "LesoesImpreg"
# Análise gráfica dos dados
plot_missing(Ress)

plot_histogram(Ress)

#plot_density(Ress)
plot_correlation(Ress, type = 'continuous', cor_args = list("use" = "pairwise.complete.obs"))

plot_correlation(dados, type = 'discrete', cor_args = list("use" = "pairwise.complete.obs"))

plot_bar(Ress)

library(qgraph)
# Correlação entre as variáveis do banco RM
clinic <- cor_auto(Ress)

library(corrplot)
corrplot(clinic, type="lower", order="hclust")

# cria um banco RM diferente (USAR EM OUTRAS ANALISES)
Ress2 <- Ress %>% dplyr::select(Idade, Escolaridade, Comorbidades:VitD, FSS:SD_oral, BVMT, CVLT, CVLT_rep:LesoesImpreg)

Árvores condicionais RM

library(partykit)

# Análise exploratória pra prever o VolCereb
plot(ctree(VolCereb ~ . , data = Ress))

plot(ctree(I(VolCereb + VolCinz) ~ . , data = Ress)) # Escore composto

plot(ctree(VolCereb ~ SD_escr + SD_oral, data = Ress))

plot(ctree(I(VolCereb + VolCinz) ~ SD_oral , data = Ress))

plot(ctree(I(VolCereb + VolCinz) ~ SD_escr + SD_oral , data = Ress))

plot(ctree(VolCereb ~ SD_escr + SD_oral + BVMT + CVLT + MMSE_MST + pinosdir9 + pinosesq9 + Passos25, data = Ress))

# Árvores condicionais exploratórias para prever dificuldades motores
plot(ctree(EDSS ~ . , data = Ress))

plot(ctree(EDSS ~ . , data = Ress[-c(12,13)]))

plot(ctree(I(pinosesq9 + pinosdir9) ~ . , data = Ress))

# Prever lesões
plot(ctree(LesoesFlair ~ . , data = Ress))

plot(ctree(LesoesImpreg ~ . , data = Ress))

# Banco de dados Ress2
plot(ctree(BVMT ~ . , data = Ress2))

plot(ctree(CVLT ~ . , data = Ress2))

plot(ctree(MMSE_MST ~ . , data = Ress2))

# Prever SDMT
plot(ctree(I(SD_escr + SD_oral) ~ . , data = Ress2))

plot(ctree(I(SD_escr + SD_oral) ~ . , data = Ress2[-21]))

plot(ctree(SD_escr ~ pinosdir9 + pinosesq9, data = Ress))

plot(ctree(SD_oral ~ pinosdir9 + pinosesq9, data = Ress))

# Prever Severidade da Fadiga (FSS)
plot(ctree(FSS ~ . , data = Ress))

# Prever Humor
plot(ctree(HADS_D ~ . , data = Ress))

plot(ctree(HADS_A ~ . , data = Ress))

plot(ctree(I(HADS_A + HADS_D) ~ . , data = Ress))

# Prever Qualidade de Vida (SF-36)
plot(ctree(SF36 ~ . , data = Ress))