1 Packages

library(tidyverse) #environment
## -- Attaching packages ------------------------------------------------------------------------------------------------------------------ tidyverse 1.3.0 --
## v ggplot2 3.3.1     v purrr   0.3.4
## v tibble  3.0.1     v dplyr   1.0.0
## v tidyr   1.1.0     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## -- Conflicts --------------------------------------------------------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(flextable)
## 
## Attaching package: 'flextable'
## The following object is masked from 'package:purrr':
## 
##     compose
library(janitor) #packages
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(summarytools) #description
## Registered S3 method overwritten by 'pryr':
##   method      from
##   print.bytes Rcpp
## For best results, restart R session and update pander using devtools:: or remotes::install_github('rapporter/pander')
## 
## Attaching package: 'summarytools'
## The following object is masked from 'package:tibble':
## 
##     view
library(DataExplorer) #description
library(psych)
## 
## Attaching package: 'psych'
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
#network plot
library(igraph)
## 
## Attaching package: 'igraph'
## The following object is masked from 'package:flextable':
## 
##     compose
## The following objects are masked from 'package:dplyr':
## 
##     as_data_frame, groups, union
## The following objects are masked from 'package:purrr':
## 
##     compose, simplify
## The following object is masked from 'package:tidyr':
## 
##     crossing
## The following object is masked from 'package:tibble':
## 
##     as_data_frame
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
library(corrr)
library(ggraph)

2 Dataaset

backup <- ds
#limpar nomes

ds <- clean_names(ds)
load("C:/Users/luisf/Dropbox/Puc-Rio/Consultoria - Vlaudimir/Base R - Vlaudimir.RData")

3 Descriptives

ds %>% 
  select(genero:qual_a_sua_frequencia_de_pratica_de_atividade_fisica_na_semana) %>% 
  tableone::CreateTableOne(data = .)
## Warning in ModuleReturnVarsExist(vars, data): These variables only have NA/NaN:
## qte_anos_maco Dropped
##                                                                     
##                                                                      Overall       
##   n                                                                      75        
##   genero = Masculino (%)                                                 65 (86.7) 
##   idade (mean (SD))                                                   40.15 (9.99) 
##   peso_em_kg (mean (SD))                                              87.29 (17.74)
##   altura_em_cm (mean (SD))                                           176.17 (8.22) 
##   imc (mean (SD))                                                     27.98 (4.57) 
##   estado_civil (%)                                                                 
##      Casado                                                              55 (73.3) 
##      Divorciado                                                           1 ( 1.3) 
##      Solteiro                                                            19 (25.3) 
##   numero_de_filhos (%)                                                             
##      1                                                                   12 (16.0) 
##      2                                                                   24 (32.0) 
##      3                                                                    9 (12.0) 
##      6                                                                    1 ( 1.3) 
##      Nenhum                                                              29 (38.7) 
##   nivel_educacional (%)                                                            
##      Doutorado                                                            3 ( 4.0) 
##      Especialização (Residência ou Estágio)                              61 (81.3) 
##      Graduação                                                            3 ( 4.0) 
##      Mestrado                                                             7 ( 9.3) 
##      Pós Doutorado                                                        1 ( 1.3) 
##   historia_de_tabagismo (%)                                                        
##      Ex tabagista                                                         8 (10.7) 
##      Não                                                                 63 (84.0) 
##      Sim                                                                  4 ( 5.3) 
##   ex_tabagista_ha_quantos_anos_voce_nao_fuma_mais (%)                              
##      1                                                                    1 ( 1.3) 
##      12                                                                   1 ( 1.3) 
##      13                                                                   1 ( 1.3) 
##      18                                                                   1 ( 1.3) 
##      4                                                                    1 ( 1.3) 
##      6                                                                    1 ( 1.3) 
##      7                                                                    1 ( 1.3) 
##      9                                                                    1 ( 1.3) 
##      NA                                                                  67 (89.3) 
##   ex_taabgista_com_qual_idade_voce_comecou_a_fumar (%)                             
##      14                                                                   2 ( 2.7) 
##      16                                                                   1 ( 1.3) 
##      17                                                                   1 ( 1.3) 
##      18                                                                   2 ( 2.7) 
##      23                                                                   2 ( 2.7) 
##      NA                                                                  67 (89.3) 
##   ex_tbagista_qual_a_quantidade_de_cigarros_voce_fumava_por_dia (%)                
##      10                                                                   4 ( 5.3) 
##      20                                                                   3 ( 4.0) 
##      40                                                                   1 ( 1.3) 
##      NA                                                                  67 (89.3) 
##   tabgista_com_qual_idade_voce_comecou_a_fumar (%)                                 
##      18                                                                   1 ( 1.3) 
##      20                                                                   1 ( 1.3) 
##      26                                                                   1 ( 1.3) 
##      28                                                                   1 ( 1.3) 
##      NA                                                                  71 (94.7) 
##   tabagista_qual_a_quantidade_de_cigarros_voce_fuma_por_dia (%)                    
##      10                                                                   1 ( 1.3) 
##      3                                                                    1 ( 1.3) 
##      4                                                                    1 ( 1.3) 
##      5                                                                    1 ( 1.3) 
##      NA                                                                  71 (94.7) 
##   voce_pratica_atividade_fisica_por_mais_de_30_minutos = Sim (%)         40 (53.3) 
##   qual_a_sua_frequencia_de_pratica_de_atividade_fisica_na_semana (%)               
##      2 vezes por semana                                                  14 (18.7) 
##      3 vezes por semana                                                  16 (21.3) 
##      4 vezes por semana                                                   6 ( 8.0) 
##      5 vezes por semana                                                   4 ( 5.3) 
##      Não pratica                                                         35 (46.7)
ds %>% 
  select(estando_em_casa_quantas_horas_voce_consegue_dormir_por_noite:qual_e_a_sua_carga_horaria_na_semana_para_plantao_presencial_noturno_na_sala_de_emergencia_urgencia_pronto_socorro_ou_pa) %>% 
   tableone::CreateTableOne(data = .)
##                                                                                                                                      
##                                                                                                                                       Overall   
##   n                                                                                                                                   75        
##   estando_em_casa_quantas_horas_voce_consegue_dormir_por_noite (%)                                                                              
##      Mais do que 3 até 6 horas                                                                                                        21 (28.0) 
##      Mais do que 6 horas até 8 horas                                                                                                  50 (66.7) 
##      Mais do que 8 horas                                                                                                               4 ( 5.3) 
##   estando_em_plantao_hospitalar_noturno_quantas_horas_voce_consegue_dormir_por_noite (%)                                                        
##      Até 3 horas                                                                                                                      37 (49.3) 
##      Mais do que 3 até 6 horas                                                                                                        28 (37.3) 
##      Mais do que 6 horas até 8 horas                                                                                                   1 ( 1.3) 
##      Não faço plantão presencial noturno em hospital                                                                                   9 (12.0) 
##   faco_atendimento_em_hospital_publico = sim (%)                                                                                      52 (69.3) 
##   faco_atendimento_em_hospital_privado = sim (%)                                                                                      64 (85.3) 
##   faco_atendimento_em_universitario = sim (%)                                                                                         31 (41.3) 
##   faco_atendimento_em_consultorio (%)                                                                                                           
##      não                                                                                                                              39 (52.0) 
##      sim                                                                                                                              35 (46.7) 
##      sm                                                                                                                                1 ( 1.3) 
##   faz_plantao_na_sala_de_urgencia_emergencia_pronto_socorro_ou_pa (%)                                                                           
##      Não                                                                                                                              25 (33.3) 
##      sim                                                                                                                               3 ( 4.0) 
##      Sim                                                                                                                              47 (62.7) 
##   ha_quanto_tempo_trabalha_na_sala_de_emergencia_urgencia_pronto_socorro_ou_pa (%)                                                              
##      De 1 ano até 2 anos                                                                                                               6 ( 8.0) 
##      De 2 anos até 3 anos                                                                                                              6 ( 8.0) 
##      De 3 anos até 4 anos                                                                                                              5 ( 6.7) 
##      Mais do que 4 anos                                                                                                               32 (42.7) 
##      Menos do que 1 ano                                                                                                                1 ( 1.3) 
##      não faço plantao na SUE                                                                                                          25 (33.3) 
##   qual_e_a_sua_carga_horaria_na_semana_para_plantao_presencial_dia_e_ou_noite_na_sala_de_emergencia_urgencia_pronto_socorro_ou_pa (%)           
##      Até 6 horas                                                                                                                       3 ( 4.0) 
##      Mais do que 12 até 18 horas                                                                                                       9 (12.0) 
##      Mais do que 18 até 24 horas                                                                                                       5 ( 6.7) 
##      Mais do que 24 até 30 horas                                                                                                       8 (10.7) 
##      Mais do que 30 até 36 horas                                                                                                       9 (12.0) 
##      Mais do que 36 até 42 horas                                                                                                       2 ( 2.7) 
##      Mais do que 42 até 48 horas                                                                                                       1 ( 1.3) 
##      Mais do que 48 até 60 horas                                                                                                       2 ( 2.7) 
##      Mais do que 6 até 12 horas                                                                                                       11 (14.7) 
##      não faço plantao na SUE                                                                                                          25 (33.3) 
##   qual_e_a_sua_carga_horaria_na_semana_para_plantao_presencial_noturno_na_sala_de_emergencia_urgencia_pronto_socorro_ou_pa (%)                  
##      Até 6 horas                                                                                                                       8 (10.7) 
##      Mais do que 12 até 18 horas                                                                                                      12 (16.0) 
##      Mais do que 18 até 24 horas                                                                                                      11 (14.7) 
##      Mais do que 24 até 30 horas                                                                                                       3 ( 4.0) 
##      Mais do que 30 até 36 horas                                                                                                       2 ( 2.7) 
##      Mais do que 36 até 42 horas                                                                                                       2 ( 2.7) 
##      Mais do que 42 até 48 horas                                                                                                       1 ( 1.3) 
##      Mais do que 6 até 12 horas                                                                                                       11 (14.7) 
##      não faço plantao na SUE                                                                                                          25 (33.3)

4 Copy variables (BIG 5)

ds <-  ds %>% 
  mutate_at(vars(eu_sou_uma_pessoa_comunicativa:eu_sou_uma_pessoa_audaciosa),
            list(cat = ~paste0(.))) %>% #copy all variables (duplicate) 
   rename_at(vars(ends_with( "_cat")), list(~paste0("big5_", 1:25))) 

5 Transform into numeric

ds <- ds %>% 
  mutate_at(vars(starts_with("big5_")),
            list(~str_extract(., "\\d") %>% as.numeric(.)))

6 Check distribution

ds %>% 
  select(starts_with("big5_")) %>% 
  pivot_longer(everything()) %>% 
  ggplot(., aes(name, value)) +
  geom_boxplot() +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, hjust=1)) +
  labs(x = "", y = "")

7 Reverse scale

ds <- ds %>% 
  mutate_at(vars(big5_6, big5_11, big5_21), list(~paste(abs(6-.)) %>% as.numeric(.)))

8 Compute totals

ds <- ds %>% 
  mutate(big_extroversao = rowSums(select(.,big5_1, big5_6, big5_11, big5_16, big5_21)), #<-- LUCAS, CONFERIR
         big_socializacao = rowSums(select(.,big5_2, big5_7, big5_12, big5_17, big5_22)),
         big_conscienciosidade = rowSums(select(.,big5_3, big5_8, big5_13, big5_18, big5_23)),
         big_neuroticismo = rowSums(select(.,big5_4, big5_9, big5_14, big5_19, big5_24)),
         big_abertura = rowSums(select(.,big5_5, big5_10, big5_15, big5_20, big5_25)))

9 Copy variables (Perceived stress)

ds <-  ds %>% 
  mutate_at(vars(neste_ultimo_mes_com_que_frequencia_voce_tem_ficado_triste_por_causa_de_algo_que_aconteceu_inesperadamente:neste_ultimo_mes_com_que_frequencia_voce_tem_sentido_que_as_dificuldades_se_acumulam_a_ponto_de_voce_acreditar_que_nao_pode_supera_las),
            list(stress = ~paste0(.))) %>% #copy all variables (duplicate) 
   rename_at(vars(ends_with( "_stress")), list(~paste0("stress_", 1:14))) 

10 Transform into numeric

ds <- ds %>% 
  mutate_at(vars(starts_with("stress_")),
            ~case_when(
              . == "Nunca" ~ 0,
              . == "Quase nunca" ~ 1,
              . == "Ás vezes" ~ 2,
              . == "Quase sempre" ~ 3,
              . == "Sempre" ~ 4))

11 Reverse scale

ds <- ds %>% 
  mutate_at(vars(stress_4, stress_5, stress_6, stress_7, stress_9, stress_10, stress_13), ~paste(abs(4-.))) %>% 
  mutate_at(vars(stress_4, stress_5, stress_6, stress_7, stress_9, stress_10, stress_13), ~as.numeric(.))

12 Check distribution

ds %>% 
  select(starts_with("stress_")) %>% 
  pivot_longer(everything()) %>% 
  ggplot(., aes(name, value)) +
  geom_boxplot() +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, hjust=1)) +
  labs(x = "", y = "")

13 Compute totals

ds <- ds %>% 
  mutate(sts_total = rowSums(select(.,starts_with("stress"))))

14 Copy variables (HADS)

ds <- ds %>% 
  mutate_at(vars(x1_eu_sinto_tenso_a_ou_contraido_a:x14_consigo_sentir_prazer_quando_assisto_a_um_bom_programa_de_televisao_de_radio_ou_quando_leio_alguma_coisa),
            list(hads = ~paste0(.))) %>% #copy all variables (duplicate) 
   rename_at(vars(ends_with( "_hads")), list(~paste0("hads_", 1:14))) 

15 Transform into numeric (Lucas em julho 11 2020)

# Transform into numeric <-- esperar
ds <- ds %>% 
  mutate_at(vars(hads_1), ~case_when(
    . == "A maior parte do tempo" ~ 3,
    . == "Boa parte do tempo" ~ 2,
    . == "De vez em quando" ~ 1,
    . == "Nunca" ~ 0
  ))
ds <- ds %>% 
  mutate_at(vars(hads_2), ~case_when(
    . =="Sim, do mesmo jeito que antes" ~ 0,
    . =="Não tanto quanto antes" ~ 1,
    . =="Só um pouco" ~2
  ))
ds <- ds %>% 
  mutate_at(vars(hads_3), ~case_when(
    . == "Não sinto nada disso" ~ 0,
    . == "Um pouco, mas isso não me preocupa" ~ 1, 
    . == "Sim, mas não tão forte" ~ 2,
    .== "Sim, de jeito muito forte"~ 3
  ))
ds <- ds %>% 
  mutate_at(vars(hads_4), ~case_when(
    . =="Do mesmo jeito que antes" ~0,
    .=="Atualmente um pouco menos" ~1,
    .== "Atualmente bem menos" ~2,
  ))

ds <- ds %>% 
  mutate_at(vars(hads_5), ~case_when(
    . =="Raramente" ~0,
    .=="De vez em quando" ~1,
    .=="Boa parte do tempo" ~2,
    .=="A maior parte do tempo"~3
  ))

ds <- ds %>% 
  mutate_at(vars(hads_6), ~case_when(
    . =="A maior parte do tempo" ~0,
    .=="Muitas vezes" ~1,
    .== "Poucas vezes" ~2
  ))

ds <- ds %>% 
  mutate_at(vars(hads_7), ~case_when(
    . =="Sim, quase sempre" ~0,
    .=="Muitas vezes" ~1,
    .== "Poucas vezes" ~2
  ))
ds <- ds %>% 
  mutate_at(vars(hads_8), ~case_when(
    . =="Nunca"~0,
    .=="Poucas vezes" ~1,
    .=="Muitas vezes" ~2,
    .=="Quase sempre" ~3
  ))
ds <- ds %>% 
  mutate_at(vars(hads_9), ~case_when(
    . =="Nunca" ~ 0,
    .=="De vez em quando" ~ 1,
    .=="Muitas vezes" ~ 2,
    .=="Quase sempre" ~ 3
  ))
ds <- ds %>% 
  mutate_at(vars(hads_10), ~case_when(
    . =="Me cuido do mesmo jeito que antes"~0,
    .=="Talvez não tanto quanto antes"~1,
    .=="Não estou mais me cuidando como eu deveria"~2,
    .=="Completamente"~3
  ))

ds <- ds %>% 
  mutate_at(vars(hads_11), ~case_when(
    . =="Não me sinto assim"~0,
    .=="Um pouco"~1,
    .=="Bastante"~2,
    .=="Sim, demais"~3
  ))

ds <- ds %>% 
  mutate_at(vars(hads_12), ~case_when(
    . =="Do mesmo jeito que antes"~0,
    .=="Um pouco menos que antes"~1,
    .=="Bem menos que antes"~2,
    .=="Quase nunca"~3
  ))
ds <- ds %>% 
  mutate_at(vars(hads_13), ~case_when(
    . =="Não senti isso"~0,
    .=="De vez em quando"~1,
    .=="Várias vezes"~2
  ))
ds <- ds %>% 
  mutate_at(vars(hads_14), ~case_when(
    .=="Quase sempre"~0,
    .=="Várias vezes" ~1,
    .=="Poucas vezes" ~2,
    .=="Quase nunca" ~3
  ))

ds <- ds %>% 
  mutate_at(vars(starts_with("hads_")), ~as.numeric(.))

16 Check distribution

ds %>% 
  select(starts_with("hads_")) %>% 
  pivot_longer(everything()) %>% 
  ggplot(., aes(name, value)) +
  geom_boxplot() +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, hjust=1)) +
  labs(x = "", y = "")
## Warning: Removed 1050 rows containing non-finite values (stat_boxplot).

17 Compute totals

ds <- ds %>% 
  mutate(had_total = rowSums(select(.,starts_with("hads_"))))

18 Psychometrics

18.1 Reliability (BIG 5)

descritivos_big5 <- ds %>%
  select(starts_with("big5_")) %>% alpha(.) #<--DONT CHECK KEYS if USE MEANS 

#Transform to a data frame
descritivos_big5 <- bind_cols(descritivos_big5$item.stats,descritivos_big5$alpha.drop)

#add row number and Supress some variables
descritivos_big5 <- descritivos_big5 %>% mutate(item=row_number()) %>% select(item, n, mean, sd, r.drop, raw_alpha) 

#add content
descritivos_big5 <- descritivos_big5 %>% mutate(conteudo = case_when(
  item == "1" ~ "1 comunicativa",
  item == "2" ~ "2 amável",
  item == "3" ~ "3 dedicada",
  item == "4" ~ "4 pessimista",
  item == "5" ~ "5 criativa",
  item == "6" ~ "6 quieta (R)",
  item == "7" ~ "7 gentil",
  item == "8" ~ "8 esforçada",
  item == "9" ~ "9 deprimida",
  item == "10" ~ "10 artística",
  item == "11" ~ "11 timida (R)",
  item == "12" ~ "12 simpatica",
  item == "13" ~ "13 responsavel",
  item == "14" ~ "14 insegura",
  item == "15" ~ "15 filosofica",
  item == "16" ~ "16 desembaracada",
  item == "17" ~ "17 bondosa",
  item == "18" ~ "18 organizada",
  item == "19" ~ "19 ansiosa",
  item == "20" ~ "20 aventureira",
  item == "21" ~ "21 inibida (R)",
  item == "22" ~ "22 compreensiva",
  item == "23" ~ "23 cuidadosa",
  item == "24" ~ "24 aborrecida",
  item == "25" ~ "25 audaciosa"))

# arrange
descritivos_big5 <- descritivos_big5 %>% 
 dplyr::select(item, conteudo, n, mean, sd, r.drop, raw_alpha) 

#translate names
descritivos_big5 <- descritivos_big5 %>% 
  rename("média" = mean, "DP" = sd, "cor item-total" = r.drop, "alfa se deletado" = raw_alpha)
descritivos_big5 %>% 
  flextable() %>% 
  autofit() %>% 
    colformat_num(.,digits = 3)

item

conteudo

n

média

DP

cor item-total

alfa se deletado

1.000

1 comunicativa

75.000

4.227

0.798

0.478

0.641

2.000

2 amável

75.000

3.787

0.776

0.459

0.643

3.000

3 dedicada

75.000

4.453

0.643

0.242

0.661

4.000

4 pessimista

75.000

2.293

0.882

-0.175

0.695

5.000

5 criativa

75.000

3.893

0.746

0.364

0.651

6.000

6 quieta (R)

75.000

3.293

1.323

0.172

0.671

7.000

7 gentil

75.000

4.053

0.751

0.502

0.640

8.000

8 esforçada

75.000

4.307

0.697

0.177

0.665

9.000

9 deprimida

75.000

2.000

1.000

0.189

0.665

10.000

10 artística

75.000

2.640

1.123

0.328

0.650

11.000

11 timida (R)

75.000

3.280

1.073

0.168

0.668

12.000

12 simpatica

75.000

3.893

0.781

0.676

0.625

13.000

13 responsavel

75.000

4.627

0.632

0.356

0.654

14.000

14 insegura

75.000

2.173

0.964

0.166

0.667

15.000

15 filosofica

75.000

2.800

1.263

0.139

0.674

16.000

16 desembaracada

75.000

3.893

0.764

0.257

0.659

17.000

17 bondosa

75.000

4.160

0.717

0.561

0.637

18.000

18 organizada

75.000

3.733

0.963

0.058

0.677

19.000

19 ansiosa

75.000

3.253

1.198

0.307

0.652

20.000

20 aventureira

75.000

3.040

1.202

0.189

0.667

21.000

21 inibida (R)

75.000

3.720

0.847

0.144

0.668

22.000

22 compreensiva

75.000

4.013

0.707

0.288

0.657

23.000

23 cuidadosa

75.000

4.227

0.649

0.303

0.657

24.000

24 aborrecida

75.000

2.440

0.990

-0.154

0.697

25.000

25 audaciosa

75.000

3.147

0.940

0.028

0.679

Gráfico de médias

descritivos_big5 %>% 
  select(conteudo, média) %>% 
  ggplot(., aes(conteudo, média)) +
  geom_bar(stat = "summary") +
  labs(x = "", y = "Média", title = "Marcadores da Personalidade") +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, hjust=1))
## No summary function supplied, defaulting to `mean_se()`

Em cada fator

#Extroversão
ds %>% 
  select(big5_1, big5_6, big5_11, big5_16, big5_21) %>% 
  alpha()

#Socialização
ds %>% 
  select(big5_2, big5_7, big5_12, big5_17, big5_22) %>% 
  alpha()

#Conscienciosidade
ds %>% 
  select(big5_3, big5_8, big5_13, big5_18, big5_23) %>% 
  alpha()

# Neuroticismo
ds %>% 
  select(big5_4, big5_9, big5_14, big5_19, big5_24) %>% 
  alpha()

#Abertura
ds %>% 
  select(big5_5, big5_10, big5_15, big5_20, big5_25) %>% 
  alpha()

Tabela de médias por dimensões

ds %>% 
  select(starts_with("big_")) %>% #select all variables of intereset
  rename_all(., ~str_remove(., "big_")) %>% 
  rename_all(.,~str_to_title(.)) %>% 
  tableone::CreateTableOne(data = .)
##                                
##                                 Overall     
##   n                                75       
##   Extroversao (mean (SD))       18.41 (3.49)
##   Socializacao (mean (SD))      19.91 (3.05)
##   Conscienciosidade (mean (SD)) 21.35 (2.71)
##   Neuroticismo (mean (SD))      12.16 (3.53)
##   Abertura (mean (SD))          15.52 (3.15)

Gráfico de rede entre dimensões do big 5

cor_graph <- ds %>% 
  select(starts_with("big_")) %>% #select all variables of intereset
  rename_all(., ~str_remove(., "big_")) %>% 
  rename_all(.,~str_to_title(.)) %>%  #sentence case
  nest(data = everything()) %>% #create specific dataset to each age intervla
  mutate(data = map(data, purrr::compose(stretch, correlate))) %>% #run correlation 
  unnest(cols = c(data)) %>% 
  select(x, y, r) %>% 
  graph_from_data_frame(directed = FALSE)
## 
## Correlation method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
ggraph(cor_graph, layout = "kk") +
  geom_edge_link(aes(edge_alpha = abs(r), color = r), edge_width = 5) +
  guides(edge_alpha = "none") +
  scale_edge_colour_gradientn(limits = c(-1, 1),  colors = c("firebrick2", "dodgerblue2")) +
  geom_node_point(color = "black", size = 4) +
  geom_node_text(aes(label = name), repel = TRUE) +
  theme_graph()
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family not
## found in Windows font database
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

ds %>% 
  select(starts_with("big_")) %>% #select all variables of intereset
  rename_all(., ~str_remove(., "big_")) %>% 
  rename_all(.,~str_to_title(.)) %>% 
  pivot_longer(everything()) %>% 
  ggplot(., aes(name, value))+
  geom_boxplot() +
  labs(x = "", y = "", title = "Distribuição dos fatores dos Marcadores de Personalidade") +
  theme_bw()

18.2 Reliability (Perceived stress)

descritivos_stress <- ds %>%
  select(starts_with("stress")) %>% alpha(.)

#Transform to a data frame
descritivos_stress <- bind_cols(descritivos_stress$item.stats,descritivos_stress$alpha.drop)

#add row number and Supress some variables
descritivos_stress <- descritivos_stress %>% mutate(item=row_number()) %>% select(item, n, mean, sd, r.drop, raw_alpha) 

#add content
descritivos_stress <- descritivos_stress %>% mutate(conteudo = case_when(
  item == "1" ~ "1 tem ficado triste",
  item == "2" ~ "2 incapaz de controlar coisas imporantes",
  item == "3" ~ "3 nervoso ou estressado",
  item == "4" ~ "4 tratado com sucesso problemas difíceis",
  item == "5" ~ "5 lidando bem com mudanças",
  item == "6" ~ "6 confiante em suas habilidades",
  item == "7" ~ "7 sente que as coisas estão de acordo com sua vontade",
  item == "8" ~ "8 não consegue lidar com as coisas",
  item == "9" ~ "9 consegue controlar a irritação",
  item == "10" ~ "10 coisas sob seu controle",
  item == "11" ~ "11 ficado irritado com as coisas",
  item == "12" ~ "12 pensando sobre coisas que deve fazer",
  item == "13" ~ "13 controlar como gasta o tempo",
  item == "14" ~ "14 sente que as dificuldades se acumular"))

# arrange
descritivos_stress <- descritivos_stress %>% 
 dplyr::select(item, conteudo, n, mean, sd, r.drop, raw_alpha) 

#translate names
descritivos_stress <- descritivos_stress %>% 
  rename("média" = mean, "DP" = sd, "cor item-total" = r.drop, "alfa se deletado" = raw_alpha)
descritivos_stress %>% 
  flextable() %>%
  autofit() %>% 
    colformat_num(.,digits = 3)

item

conteudo

n

média

DP

cor item-total

alfa se deletado

1.000

1 tem ficado triste

75.000

1.827

0.921

0.613

0.908

2.000

2 incapaz de controlar coisas imporantes

75.000

1.547

1.044

0.711

0.905

3.000

3 nervoso ou estressado

75.000

2.067

0.905

0.707

0.905

4.000

4 tratado com sucesso problemas difíceis

75.000

1.213

0.684

0.691

0.906

5.000

5 lidando bem com mudanças

75.000

1.213

0.827

0.811

0.901

6.000

6 confiante em suas habilidades

75.000

1.107

0.781

0.667

0.906

7.000

7 sente que as coisas estão de acordo com sua vontade

75.000

1.720

0.763

0.637

0.908

8.000

8 não consegue lidar com as coisas

75.000

1.747

0.856

0.556

0.910

9.000

9 consegue controlar a irritação

75.000

1.400

0.735

0.548

0.910

10.000

10 coisas sob seu controle

75.000

1.587

0.737

0.660

0.907

11.000

11 ficado irritado com as coisas

75.000

1.840

0.886

0.637

0.907

12.000

12 pensando sobre coisas que deve fazer

75.000

3.040

0.877

0.262

0.921

13.000

13 controlar como gasta o tempo

75.000

1.893

0.847

0.619

0.908

14.000

14 sente que as dificuldades se acumular

75.000

1.333

1.044

0.723

0.904

Gráfico de médias

descritivos_stress %>% 
  select(conteudo, média) %>% 
  ggplot(., aes(conteudo, média)) +
  geom_bar(stat = "summary") +
  labs(x = "", y = "Média", title = "Estresse Percebido") +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, hjust=1))
## No summary function supplied, defaulting to `mean_se()`

cor_graph <- ds %>% 
  select(starts_with("stress")) %>% #select all variables of intereset
  rename_all(., ~paste0("y", 1:14)) %>% 
  nest(data = everything()) %>% #create specific dataset to each age intervla
  mutate(data = map(data, purrr::compose(stretch, correlate))) %>% #run correlation 
  unnest(cols = c(data)) %>% 
  select(x, y, r) %>% 
  graph_from_data_frame(directed = FALSE)
## 
## Correlation method: 'pearson'
## Missing treated using: 'pairwise.complete.obs'
ggraph(cor_graph, layout = "kk") +
  geom_edge_link(aes(edge_alpha = abs(r), color = r), edge_width = 5) +
  guides(edge_alpha = "none") +
  scale_edge_colour_gradientn(limits = c(-1, 1),  colors = c("firebrick2", "dodgerblue2")) +
  geom_node_point(color = "black", size = 4) +
  geom_node_text(aes(label = name), repel = TRUE) +
  theme_graph()
## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

## Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : font
## family not found in Windows font database

18.3 Reliability (Depressão e Ansiedade)

descritivos_hads <- ds %>%
  select(starts_with("hads_")) %>% alpha(.)

#Transform to a data frame
descritivos_hads <- bind_cols(descritivos_hads$item.stats,descritivos_hads$alpha.drop)

#add row number and Supress some variables
descritivos_hads <- descritivos_hads %>% mutate(item=row_number()) %>% select(item, n, mean, sd, r.drop, raw_alpha) 

#add content
descritivos_hads <- descritivos_hads %>% mutate(conteudo = case_when(
  item == "1" ~ "1 Tenso ou contrariado",
  item == "2" ~ "2 Gosto das memas coisas que antes (R)",
  item == "3" ~ "3 Uma espécie de medo",
  item == "4" ~ "4 Dou risada e me divirto (R)",
  item == "5" ~ "5 Cabeça cheia de preocupações",
  item == "6" ~ "6 Sinto-me alegre (R)",
  item == "7" ~ "7 Consigo ficar à vontade (R)",
  item == "8" ~ "8 Estou lento para pensar",
  item == "9" ~ "9 Sensação ruim de medo",
  item == "10" ~ "10 Perdi o interesse em cuidar da aparência",
  item == "11" ~ "11 Sinto-me inquieto",
  item == "12" ~ "12 Fico animado esperando as coisas (R)",
  item == "13" ~ "13 Sensação de entrar em pânico",
  item == "14" ~ "14 Sentir prazer vendo televisão (R)"))

# arrange
descritivos_hads <- descritivos_hads %>% 
 dplyr::select(item, conteudo, n, mean, sd, r.drop, raw_alpha) 

#translate names
descritivos_hads <- descritivos_hads %>% 
  rename("média" = mean, "DP" = sd, "cor item-total" = r.drop, "alfa se deletado" = raw_alpha)
descritivos_hads %>% 
  flextable() %>%
  autofit() %>% 
    colformat_num(.,digits = 3)

item

conteudo

n

média

DP

cor item-total

alfa se deletado

1.000

1 Tenso ou contrariado

75.000

1.267

0.622

0.631

0.833

2.000

2 Gosto das memas coisas que antes (R)

75.000

0.587

0.572

0.363

0.847

3.000

3 Uma espécie de medo

75.000

0.960

0.845

0.517

0.840

4.000

4 Dou risada e me divirto (R)

75.000

0.453

0.664

0.436

0.844

5.000

5 Cabeça cheia de preocupações

75.000

1.587

0.840

0.498

0.841

6.000

6 Sinto-me alegre (R)

75.000

0.893

0.649

0.511

0.840

7.000

7 Consigo ficar à vontade (R)

75.000

1.040

0.667

0.496

0.841

8.000

8 Estou lento para pensar

75.000

0.960

0.625

0.463

0.842

9.000

9 Sensação ruim de medo

75.000

0.640

0.671

0.505

0.840

10.000

10 Perdi o interesse em cuidar da aparência

75.000

0.720

0.745

0.490

0.841

11.000

11 Sinto-me inquieto

75.000

0.653

0.762

0.552

0.837

12.000

12 Fico animado esperando as coisas (R)

75.000

0.827

0.844

0.502

0.841

13.000

13 Sensação de entrar em pânico

75.000

0.227

0.481

0.447

0.844

14.000

14 Sentir prazer vendo televisão (R)

75.000

0.600

0.771

0.541

0.838

Gráfico de médias

descritivos_hads %>% 
  select(conteudo, média) %>% 
  ggplot(., aes(conteudo, média)) +
  geom_bar(stat = "summary", fun=mean) +
  labs(x = "", y = "Média", title = "Escala Hospitalar de Ansiedade e Depressão") +
  theme_bw() +
  theme(axis.text.x = element_text(angle = 45, hjust=1)) +
  scale_x_discrete(labels = function(x) str_wrap(x, width = 20)) #break lines

19 Pergunta 1: Investigar o efeito de ser plantonista da sala de emergência na saúde mental

Definir plantonista

ds <- ds %>% 
  mutate(plantao = factor(if_else(faz_plantao_na_sala_de_urgencia_emergencia_pronto_socorro_ou_pa == "Não", "Não","Sim")))

19.1 Big 5

Teste de hipótese

lm(big_extroversao ~ plantao, ds) %>% apaTables::apa.aov.table(.,)
## 
## 
## ANOVA results using big_extroversao as the dependent variable
##  
## 
##    Predictor      SS df      MS      F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 7814.56  1 7814.56 646.77 .000                                
##      plantao   20.17  1   20.17   1.67 .200          .02         [.00, .10]
##        Error  882.02 73   12.08                                            
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
lm(big_socializacao ~ plantao, ds) %>% apaTables::apa.aov.table(.)
## 
## 
## ANOVA results using big_socializacao as the dependent variable
##  
## 
##    Predictor       SS df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 10000.00  1 10000.00 1057.94 .000                                
##      plantao     0.33  1     0.33    0.03 .853          .00         [.00, .03]
##        Error   690.02 73     9.45                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
lm(big_conscienciosidade ~ plantao, ds) %>% apaTables::apa.aov.table(.)
## 
## 
## ANOVA results using big_conscienciosidade as the dependent variable
##  
## 
##    Predictor       SS df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 12012.16  1 12012.16 1646.24 .000                                
##      plantao    12.33  1    12.33    1.69 .198          .02         [.00, .10]
##        Error   532.66 73     7.30                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
lm(big_neuroticismo ~ plantao, ds) %>% apaTables::apa.aov.table(.)
## 
## 
## ANOVA results using big_neuroticismo as the dependent variable
##  
## 
##    Predictor      SS df      MS      F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 3648.16  1 3648.16 288.90 .000                                
##      plantao    0.24  1    0.24   0.02 .891          .00         [.00, .02]
##        Error  921.84 73   12.63                                            
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
lm(big_abertura ~ plantao, ds) %>% apaTables::apa.aov.table(.)
## 
## 
## ANOVA results using big_abertura as the dependent variable
##  
## 
##    Predictor      SS df      MS      F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 5685.16  1 5685.16 572.07 .000                                
##      plantao    7.26  1    7.26   0.73 .396          .01         [.00, .08]
##        Error  725.46 73    9.94                                            
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared

Grafico estatístico

ds %>% 
  select(plantao,starts_with("big_")) %>% #select all variables of intereset
  rename_at(vars(-plantao), ~str_remove(., "big_")) %>% 
  rename_at(vars(-plantao),~str_to_title(.)) %>% 
  pivot_longer(cols=-plantao) %>% 
  ggstatsplot::grouped_ggbetweenstats(
  data = .,
  x = name,
  y = value,
  grouping.var = plantao,
  bar.fill = "orange",
  plot.type = "box",
  xlab = "",
  ylab = "",
  #pairwise.comparisons = TRUE,
  #pairwise.display = "significant",
  #p.adjust.method = "bonferroni",
  #ggplot.component = list(ggplot2::scale_y_continuous(sec.axis = ggplot2::dup_axis())),
  plotgrid.args = list(nrow = 2))
## Registered S3 methods overwritten by 'broom.mixed':
##   method         from 
##   augment.lme    broom
##   augment.merMod broom
##   glance.lme     broom
##   glance.merMod  broom
##   glance.stanreg broom
##   tidy.brmsfit   broom
##   tidy.gamlss    broom
##   tidy.lme       broom
##   tidy.merMod    broom
##   tidy.rjags     broom
##   tidy.stanfit   broom
##   tidy.stanreg   broom
## Registered S3 methods overwritten by 'lme4':
##   method                          from
##   cooks.distance.influence.merMod car 
##   influence.merMod                car 
##   dfbeta.influence.merMod         car 
##   dfbetas.influence.merMod        car

Gráfico de médias

ds %>% 
  select(plantao,starts_with("big_")) %>% #select all variables of intereset
  rename_at(vars(-plantao), ~str_remove(., "big_")) %>% 
  rename_at(vars(-plantao),~str_to_title(.)) %>% 
  pivot_longer(cols=-plantao) %>% 
  ggplot(., aes(name, value, fill=plantao)) +
  geom_bar(stat = "summary", position = "dodge", fun=mean) +
  stat_summary(fun.data = mean_se, geom = "errorbar",position = position_dodge(width=0.9), width=0.3) +
  labs(fill = "Plantão", x = "", y = "Valores médios") +
  theme_bw()

19.2 Stress percebido

Teste de hipótese

t.test(sts_total ~ plantao,ds)
## 
##  Welch Two Sample t-test
## 
## data:  sts_total by plantao
## t = -0.28207, df = 39.339, p-value = 0.7794
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -5.064671  3.824671
## sample estimates:
## mean in group Não mean in group Sim 
##             23.12             23.74

Gráfico estatístico

Plantonista

ggstatsplot::ggbetweenstats(
  data = ds,
  x = plantao,
  y = sts_total,
  bar.fill = "orange",
  plot.type = "box",
  xlab = "",
  ylab = "")

19.3 HADS

Teste de hipótese

t.test(had_total ~ plantao,ds)
## 
##  Welch Two Sample t-test
## 
## data:  had_total by plantao
## t = -0.86568, df = 38.031, p-value = 0.3921
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -4.473515  1.793515
## sample estimates:
## mean in group Não mean in group Sim 
##             10.52             11.86

Gráfico estatístico

Plantonista

ggstatsplot::ggbetweenstats(
  data = ds,
  x = plantao,
  y = had_total,
  bar.fill = "orange",
  plot.type = "box",
  xlab = "",
  ylab = "")

20 Pergunta 2: Investigar o efeito do tipo de formação da sala de emergência na saúde mental

Definir formacao

ds <- ds %>% 
  mutate(formacao = factor(case_when(
    especializacao_estagio_ou_residencia_medica == "Ainda estou cursando Estágio na área Cirúrgica ou afins"  ~ "cirurgica",
    especializacao_estagio_ou_residencia_medica == "Ainda estou cursando Residência  Médica na área Clínica ou afins"  ~ "clinica",
    especializacao_estagio_ou_residencia_medica == "Ainda estou cursando Residência Médica na área Cirúrgica ou afins"  ~ "cirurgica",
    especializacao_estagio_ou_residencia_medica == "Ainda não fiz qualquer tipo de Residência Médica"  ~ "clinica",
    especializacao_estagio_ou_residencia_medica == "Estágio concluido na área de Clinica Médica ou afins"  ~ "clinica",
    especializacao_estagio_ou_residencia_medica == "Residência  Médica concluida na área de Clinica Cirúrgica ou afins"  ~ "cirurgica",
    especializacao_estagio_ou_residencia_medica == "Residência  Médica concluida na área de Clinica Médica ou afins"  ~ "clinica"),
    levels=c("clinica","cirurgica"))) 

20.1 Big 5

Teste de hipótese

lm(big_extroversao ~ formacao, ds) %>% apaTables::apa.aov.table(.,)
## 
## 
## ANOVA results using big_extroversao as the dependent variable
##  
## 
##    Predictor      SS df      MS      F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 8076.57  1 8076.57 656.07 .000                                
##     formacao    3.52  1    3.52   0.29 .594          .00         [.00, .06]
##        Error  898.67 73   12.31                                            
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
lm(big_socializacao ~ formacao, ds) %>% apaTables::apa.aov.table(.)
## 
## 
## ANOVA results using big_socializacao as the dependent variable
##  
## 
##    Predictor      SS df      MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 9809.78  1 9809.78 1065.79 .000                                
##     formacao   18.44  1   18.44    2.00 .161          .03         [.00, .11]
##        Error  671.91 73    9.20                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
lm(big_conscienciosidade ~ formacao, ds) %>% apaTables::apa.aov.table(.)
## 
## 
## ANOVA results using big_conscienciosidade as the dependent variable
##  
## 
##    Predictor       SS df       MS       F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 10653.26  1 10653.26 1429.65 .000                                
##     formacao     1.02  1     1.02    0.14 .713          .00         [.00, .05]
##        Error   543.97 73     7.45                                             
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
lm(big_neuroticismo ~ formacao, ds) %>% apaTables::apa.aov.table(.)
## 
## 
## ANOVA results using big_neuroticismo as the dependent variable
##  
## 
##    Predictor      SS df      MS      F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 3240.39  1 3240.39 257.32 .000                                
##     formacao    2.80  1    2.80   0.22 .639          .00         [.00, .05]
##        Error  919.28 73   12.59                                            
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
lm(big_abertura ~ formacao, ds) %>% apaTables::apa.aov.table(.)
## 
## 
## ANOVA results using big_abertura as the dependent variable
##  
## 
##    Predictor      SS df      MS      F    p partial_eta2 CI_90_partial_eta2
##  (Intercept) 5417.78  1 5417.78 540.49 .000                                
##     formacao    0.98  1    0.98   0.10 .755          .00         [.00, .04]
##        Error  731.74 73   10.02                                            
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared

Gráfico estatístico

ds %>% 
  select(formacao,starts_with("big_")) %>% #select all variables of intereset
  rename_at(vars(-formacao), ~str_remove(., "big_")) %>% 
  rename_at(vars(-formacao),~str_to_title(.)) %>% 
  pivot_longer(cols=-formacao) %>% 
  ggstatsplot::grouped_ggbetweenstats(
  data = .,
  x = name,
  y = value,
  grouping.var = formacao,
  bar.fill = "orange",
  plot.type = "box",
  xlab = "",
  ylab = "",
  #pairwise.comparisons = TRUE,
  #pairwise.display = "significant",
  #p.adjust.method = "bonferroni",
  #ggplot.component = list(ggplot2::scale_y_continuous(sec.axis = ggplot2::dup_axis())),
  plotgrid.args = list(nrow = 2))

Gráfico de médias

ds %>% 
  select(formacao,starts_with("big_")) %>% #select all variables of intereset
  rename_at(vars(-formacao), ~str_remove(., "big_")) %>% 
  rename_at(vars(-formacao),~str_to_title(.)) %>% 
  pivot_longer(cols=-formacao) %>% 
  ggplot(., aes(name, value, fill=formacao)) +
  geom_bar(stat = "summary", position = "dodge", fun=mean) +
  stat_summary(fun.data = mean_se, geom = "errorbar",position = position_dodge(width=0.9), width=0.3) +
  labs(fill = "Formação", x = "", y = "Valores médios") +
  theme_bw()

20.2 Estresse Percebido

Teste de hipótese

t.test(sts_total ~ formacao,ds)
## 
##  Welch Two Sample t-test
## 
## data:  sts_total by formacao
## t = -0.39768, df = 50.093, p-value = 0.6926
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -4.654195  3.115734
## sample estimates:
##   mean in group clinica mean in group cirurgica 
##                23.00000                23.76923

Gráfico estatístico

ggstatsplot::ggbetweenstats(
  data = ds,
  x = formacao,
  y = sts_total,
  bar.fill = "orange",
  plot.type = "box",
  xlab = "",
  ylab = "")

Gráfico de médias

ggplot(ds, aes(x = plantao, y=sts_total)) +
  geom_bar(stat = "summary", fun=mean) +
  stat_summary(fun.data = mean_se, geom = "errorbar",position = position_dodge(width=0.9), width=0.3) +
  labs(x = "Faz plantão", y = "Valores médios") +
  theme_bw()

20.3 HADS

Teste de hipótese

t.test(had_total ~ formacao,ds)
## 
##  Welch Two Sample t-test
## 
## data:  had_total by formacao
## t = 0.38231, df = 46.325, p-value = 0.704
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -2.271110  3.336327
## sample estimates:
##   mean in group clinica mean in group cirurgica 
##                11.78261                11.25000

Gráfico estatístico

Plantonista

ggstatsplot::ggbetweenstats(
  data = ds,
  x = plantao,
  y = had_total,
  bar.fill = "orange",
  plot.type = "box",
  xlab = "",
  ylab = "")

21 Pergunta 3 Combinados: Qual o efeito combinado de ser plantonista e ter formação cirúrgica na saúde mental desses participantes.

lm(sts_total ~ plantao*formacao, ds) %>% apaTables::apa.aov.table(.,)
## 
## 
## ANOVA results using sts_total as the dependent variable
##  
## 
##           Predictor      SS df      MS     F    p partial_eta2
##         (Intercept) 2773.50  1 2773.50 39.44 .000             
##             plantao   18.26  1   18.26  0.26 .612          .00
##            formacao   20.72  1   20.72  0.29 .589          .00
##  plantao x formacao   10.65  1   10.65  0.15 .698          .00
##               Error 4992.40 71   70.32                        
##  CI_90_partial_eta2
##                    
##          [.00, .06]
##          [.00, .06]
##          [.00, .05]
##                    
## 
## Note: Values in square brackets indicate the bounds of the 90% confidence interval for partial eta-squared
lm(sts_total ~ plantao*formacao, ds) %>% apaTables::apa.reg.table()
## 
## 
## Regression results using sts_total as the criterion
##  
## 
##                     Predictor       b       b_95%_CI sr2  sr2_95%_CI
##                   (Intercept) 21.50** [14.67, 28.33]                
##                    plantaoSim    2.03  [-5.91, 9.97] .00 [-.02, .03]
##             formacaocirurgica    2.13  [-5.70, 9.96] .00 [-.02, .03]
##  plantaoSim:formacaocirurgica   -1.81 [-11.10, 7.47] .00 [-.02, .02]
##                                                                     
##                                                                     
##                                                                     
##              Fit
##                 
##                 
##                 
##                 
##        R2 = .006
##  95% CI[.00,.03]
##                 
## 
## 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.
## 
ds %>% 
  select(sts_total, plantao, formacao) %>% 
  ggplot(., aes(x = plantao, fill = formacao, y = sts_total)) +
  geom_bar(stat = "summary", position = "dodge", fun=mean) +
  stat_summary(fun.data = mean_se, geom = "errorbar",position = position_dodge(width=0.9), width=0.3) +
  labs(x = "Plantonista", y = "Valores médios (Estresse Percebido)", fill = "Formação") +
  theme_bw()

22 Full SEM

library(lavaan)
library(semPlot)
model.institution <- 'sts_total =~  plantao + formacao'
mimic.institution <- sem(model.institution, 
                         data=ds %>% select(sts_total, plantao, formacao), 
                         estimator = 'mlr', 
                         mimic = 'mplus',
                         auto.var=TRUE, auto.fix.first=TRUE, auto.cov.lv.x=TRUE, 
                         meanstructure = TRUE)
plot_default <- semPaths(mimic.institution, 
         layout = 'tree3', 
          what = 'std', 
         intercepts = FALSE, 
         residuals = FALSE,
         sizeLat = 7, 
         sizeMan = 6, 
         theme = 'gray', 
         edge.label.cex = 0.8,
         label.font = 2, #bold in all text 
         label.cex = 1, #font size 
         label.prop = 0.9, #font size
         nCharNodes = 5, 
         fade = FALSE, 
         rotation = 2,
         DoNotPlot = T)

model.institution <- 'trait =~  csum + gmsum + fmsum + pssum  + psum
trait ~ age 
trait ~  male
trait ~ white
trait ~ disability'

# Test the mimic model