Sequência das análise 1. Análise descritiva 2. Análise de confiabilidade (consistência interna) 3. Análise Fatorial Exploratória (AFE) 4. Análise Fatorial Confirmatória (AFC)

Instalar pacotes

install_if_missing <- function(pkg) {
  if (!require(pkg, character.only = TRUE)) {
    install.packages(pkg, dependencies = TRUE)
    library(pkg, character.only = TRUE)
  }
}

#Lista de pacotes
packages <- c("tidyverse", "psych", "lavaan", "GPArotation")

#Aplicar a função a todos os pacotes
invisible(sapply(packages, install_if_missing))
## Loading required package: tidyverse
## Warning: package 'tidyverse' was built under R version 4.4.3
## Warning: package 'ggplot2' was built under R version 4.4.3
## Warning: package 'tibble' was built under R version 4.4.3
## Warning: package 'tidyr' was built under R version 4.4.3
## Warning: package 'readr' was built under R version 4.4.3
## Warning: package 'purrr' was built under R version 4.4.3
## Warning: package 'dplyr' was built under R version 4.4.3
## Warning: package 'stringr' was built under R version 4.4.3
## Warning: package 'forcats' was built under R version 4.4.3
## Warning: package 'lubridate' was built under R version 4.4.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.2     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## Loading required package: psych
## Warning: package 'psych' was built under R version 4.4.3
## 
## Attaching package: 'psych'
## 
## The following objects are masked from 'package:ggplot2':
## 
##     %+%, alpha
## 
## Loading required package: lavaan
## Warning: package 'lavaan' was built under R version 4.4.3
## This is lavaan 0.6-20
## lavaan is FREE software! Please report any bugs.
## 
## Attaching package: 'lavaan'
## 
## The following object is masked from 'package:psych':
## 
##     cor2cov
## 
## Loading required package: GPArotation
## Warning: package 'GPArotation' was built under R version 4.4.3
## 
## Attaching package: 'GPArotation'
## 
## The following objects are masked from 'package:psych':
## 
##     equamax, varimin

Carregamento do banco de dados

dados <- read.csv("dados.csv")

#visualizar as primeiras linhas e a estrutura dos dados
head(dados)
##   idade sexo estcivil raca graduacao ano periodo estagio atividade q1 q2 q3 q4
## 1    37    1        2    3         1   1       1       1         0  4  5  4  5
## 2    18    1        1    1         0   1       1       1         1  3  5  3  4
## 3    22    1        1    1         0   3       0       0         0  3  4  4  5
## 4    18    1        1    1         0   1       1       1         1  4  4  4  2
## 5    25    0        1    5         0   3       0       0         0  4  3  5  3
## 6    18    1        3    1         0   1       1       1         0  5  5  5  5
##   q5 q6 q7 q8 q9 q10 q11 q12 q13 q14 q15 q16 q17 q18 q19 q20 q21 q22 q23 q24
## 1  5  3  5  5  4   5   5   5   3   5   5   5   5   3   4   5   5   5   5   5
## 2  3  4  3  3  3   5   4   5   3   5   3   3   4   4   2   3   3   2   3   4
## 3  5  3  4  4  4   4   5   5   3   5   5   4   5   3   3   3   3   3   4   3
## 4  3  4  4  5  5   5   5   5   4   4   5   3   5   3   4   4   4   4   5   4
## 5  2  3  5  4  1   5   4   3   1   4   4   5   2   1   2   1   1   5   4   3
## 6  5  3  5  4  5   4   3   5   5   5   5   5   4   4   5   5   5   5   5   5
##   q25
## 1   5
## 2   4
## 3   5
## 4   4
## 5   3
## 6   5
str(dados)
## 'data.frame':    304 obs. of  34 variables:
##  $ idade    : int  37 18 22 18 25 18 26 18 18 23 ...
##  $ sexo     : int  1 1 1 1 0 1 1 0 1 0 ...
##  $ estcivil : int  2 1 1 1 1 3 1 1 1 1 ...
##  $ raca     : int  3 1 1 1 5 1 1 1 1 1 ...
##  $ graduacao: int  1 0 0 0 0 0 1 0 0 0 ...
##  $ ano      : int  1 1 3 1 3 1 1 1 1 3 ...
##  $ periodo  : int  1 1 0 1 0 1 1 1 0 0 ...
##  $ estagio  : int  1 1 0 1 0 1 1 1 1 0 ...
##  $ atividade: int  0 1 0 1 0 0 1 1 0 0 ...
##  $ q1       : int  4 3 3 4 4 5 5 3 5 5 ...
##  $ q2       : int  5 5 4 4 3 5 5 4 5 5 ...
##  $ q3       : int  4 3 4 4 5 5 5 5 4 3 ...
##  $ q4       : int  5 4 5 2 3 5 5 4 5 5 ...
##  $ q5       : int  5 3 5 3 2 5 5 5 5 4 ...
##  $ q6       : int  3 4 3 4 3 3 3 5 5 1 ...
##  $ q7       : int  5 3 4 4 5 5 5 3 5 5 ...
##  $ q8       : int  5 3 4 5 4 4 5 5 5 5 ...
##  $ q9       : int  4 3 4 5 1 5 5 5 5 5 ...
##  $ q10      : int  5 5 4 5 5 4 3 5 5 5 ...
##  $ q11      : int  5 4 5 5 4 3 3 3 5 1 ...
##  $ q12      : int  5 5 5 5 3 5 5 5 1 5 ...
##  $ q13      : int  3 3 3 4 1 5 3 5 4 1 ...
##  $ q14      : int  5 5 5 4 4 5 5 5 5 5 ...
##  $ q15      : int  5 3 5 5 4 5 5 4 5 5 ...
##  $ q16      : int  5 3 4 3 5 5 5 5 5 5 ...
##  $ q17      : int  5 4 5 5 2 4 5 5 4 5 ...
##  $ q18      : int  3 4 3 3 1 4 5 3 5 2 ...
##  $ q19      : int  4 2 3 4 2 5 5 5 5 5 ...
##  $ q20      : int  5 3 3 4 1 5 5 4 5 5 ...
##  $ q21      : int  5 3 3 4 1 5 5 5 5 5 ...
##  $ q22      : int  5 2 3 4 5 5 3 4 5 5 ...
##  $ q23      : int  5 3 4 5 4 5 5 4 5 5 ...
##  $ q24      : int  5 4 3 4 3 5 5 4 5 5 ...
##  $ q25      : int  5 4 5 4 3 5 5 5 5 5 ...

Transformar dados

dados$sexo <- factor(dados$sexo,
                     levels = c(0, 1, 2),
                     labels = c("Masculino", "Feminino", "Prefiro nao declarar"))

dados$estcivil <- factor(dados$estcivil,
                         levels = c(1, 2, 3, 4, 5),
                         labels = c("Solteiro", "Casado", "Uniao estavel", "Divorciado", "Viuvo"))

dados$raca <- factor(dados$raca,
                         levels = c(1, 2, 3, 4, 5),
                         labels = c("Branca", "Preta", "Parda", "Amarela", "Outra"))

dados$graduacao <- factor(dados$graduacao,
                          levels = c(0, 1),
                          labels = c("Sim", "Nao"))

dados$ano <- factor(dados$ano,
                    levels = c(1, 2, 3),
                    labels = c("1 ano", "4 ano", "5 ano"))

dados$periodo <- factor(dados$periodo,
                        levels = c(0, 1),
                        labels = c("Matutino", "Noturno"))

dados$estagio <- factor(dados$estagio,
                        levels = c(0, 1),
                        labels = c("Sim", "Nao"))

dados$atividade <- factor(dados$atividade,
                        levels = c(0, 1),
                        labels = c("Sim", "Nao"))

str(dados)
## 'data.frame':    304 obs. of  34 variables:
##  $ idade    : int  37 18 22 18 25 18 26 18 18 23 ...
##  $ sexo     : Factor w/ 3 levels "Masculino","Feminino",..: 2 2 2 2 1 2 2 1 2 1 ...
##  $ estcivil : Factor w/ 5 levels "Solteiro","Casado",..: 2 1 1 1 1 3 1 1 1 1 ...
##  $ raca     : Factor w/ 5 levels "Branca","Preta",..: 3 1 1 1 5 1 1 1 1 1 ...
##  $ graduacao: Factor w/ 2 levels "Sim","Nao": 2 1 1 1 1 1 2 1 1 1 ...
##  $ ano      : Factor w/ 3 levels "1 ano","4 ano",..: 1 1 3 1 3 1 1 1 1 3 ...
##  $ periodo  : Factor w/ 2 levels "Matutino","Noturno": 2 2 1 2 1 2 2 2 1 1 ...
##  $ estagio  : Factor w/ 2 levels "Sim","Nao": 2 2 1 2 1 2 2 2 2 1 ...
##  $ atividade: Factor w/ 2 levels "Sim","Nao": 1 2 1 2 1 1 2 2 1 1 ...
##  $ q1       : int  4 3 3 4 4 5 5 3 5 5 ...
##  $ q2       : int  5 5 4 4 3 5 5 4 5 5 ...
##  $ q3       : int  4 3 4 4 5 5 5 5 4 3 ...
##  $ q4       : int  5 4 5 2 3 5 5 4 5 5 ...
##  $ q5       : int  5 3 5 3 2 5 5 5 5 4 ...
##  $ q6       : int  3 4 3 4 3 3 3 5 5 1 ...
##  $ q7       : int  5 3 4 4 5 5 5 3 5 5 ...
##  $ q8       : int  5 3 4 5 4 4 5 5 5 5 ...
##  $ q9       : int  4 3 4 5 1 5 5 5 5 5 ...
##  $ q10      : int  5 5 4 5 5 4 3 5 5 5 ...
##  $ q11      : int  5 4 5 5 4 3 3 3 5 1 ...
##  $ q12      : int  5 5 5 5 3 5 5 5 1 5 ...
##  $ q13      : int  3 3 3 4 1 5 3 5 4 1 ...
##  $ q14      : int  5 5 5 4 4 5 5 5 5 5 ...
##  $ q15      : int  5 3 5 5 4 5 5 4 5 5 ...
##  $ q16      : int  5 3 4 3 5 5 5 5 5 5 ...
##  $ q17      : int  5 4 5 5 2 4 5 5 4 5 ...
##  $ q18      : int  3 4 3 3 1 4 5 3 5 2 ...
##  $ q19      : int  4 2 3 4 2 5 5 5 5 5 ...
##  $ q20      : int  5 3 3 4 1 5 5 4 5 5 ...
##  $ q21      : int  5 3 3 4 1 5 5 5 5 5 ...
##  $ q22      : int  5 2 3 4 5 5 3 4 5 5 ...
##  $ q23      : int  5 3 4 5 4 5 5 4 5 5 ...
##  $ q24      : int  5 4 3 4 3 5 5 4 5 5 ...
##  $ q25      : int  5 4 5 4 3 5 5 5 5 5 ...

Análise descritiva

vars_socio <- c("idade", "sexo", "estcivil", "raca", "graduacao", "ano", "periodo", "estagio", "atividade")
vars_itens <- paste0("q", 1:25)

summary(dados$idade)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   17.00   19.00   21.00   25.08   26.00   60.00
sd(dados$idade, na.rm = TRUE)
## [1] 9.569434
#Tabelas de frequencia para variaveis categoricas

for(var in setdiff(vars_socio, "idade")){
  print(paste("Tabela de Frequência para:", var))
  print(table(dados[[var]], useNA = "ifany"))
}
## [1] "Tabela de Frequência para: sexo"
## 
##            Masculino             Feminino Prefiro nao declarar 
##                   56                  246                    2 
## [1] "Tabela de Frequência para: estcivil"
## 
##      Solteiro        Casado Uniao estavel    Divorciado         Viuvo 
##           236            48            11             7             2 
## [1] "Tabela de Frequência para: raca"
## 
##  Branca   Preta   Parda Amarela   Outra 
##     237       8      50       7       2 
## [1] "Tabela de Frequência para: graduacao"
## 
## Sim Nao 
## 241  63 
## [1] "Tabela de Frequência para: ano"
## 
## 1 ano 4 ano 5 ano 
##   165    75    64 
## [1] "Tabela de Frequência para: periodo"
## 
## Matutino  Noturno 
##      194      110 
## [1] "Tabela de Frequência para: estagio"
## 
## Sim Nao 
## 133 171 
## [1] "Tabela de Frequência para: atividade"
## 
## Sim Nao 
## 203 101

Itens do instrumento

describe(dados[vars_itens])
##     vars   n mean   sd median trimmed  mad min max range  skew kurtosis   se
## q1     1 304 4.62 0.78      5    4.81 0.00   1   5     4 -2.43     6.54 0.04
## q2     2 304 4.52 0.81      5    4.70 0.00   1   5     4 -1.97     4.18 0.05
## q3     3 304 4.37 0.91      5    4.54 0.00   1   5     4 -1.54     2.13 0.05
## q4     4 304 4.64 0.74      5    4.82 0.00   1   5     4 -2.30     5.45 0.04
## q5     5 304 4.54 0.82      5    4.71 0.00   1   5     4 -1.93     3.73 0.05
## q6     6 304 3.62 1.18      4    3.72 1.48   1   5     4 -0.45    -0.71 0.07
## q7     7 304 4.42 0.85      5    4.57 0.00   1   5     4 -1.47     1.87 0.05
## q8     8 304 4.43 0.86      5    4.59 0.00   1   5     4 -1.54     2.06 0.05
## q9     9 304 4.40 0.87      5    4.55 0.00   1   5     4 -1.55     2.37 0.05
## q10   10 304 4.58 0.72      5    4.74 0.00   1   5     4 -1.73     2.73 0.04
## q11   11 304 4.29 0.91      5    4.43 0.00   1   5     4 -1.16     0.79 0.05
## q12   12 304 4.61 0.91      5    4.86 0.00   1   5     4 -2.70     7.03 0.05
## q13   13 304 3.61 1.31      4    3.76 1.48   1   5     4 -0.58    -0.72 0.07
## q14   14 304 4.67 0.68      5    4.83 0.00   1   5     4 -2.37     5.92 0.04
## q15   15 304 4.48 0.78      5    4.62 0.00   1   5     4 -1.47     1.98 0.04
## q16   16 304 4.64 0.77      5    4.84 0.00   1   5     4 -2.37     5.65 0.04
## q17   17 304 4.54 0.82      5    4.73 0.00   1   5     4 -2.00     4.08 0.05
## q18   18 304 3.61 1.25      4    3.73 1.48   1   5     4 -0.43    -0.80 0.07
## q19   19 304 3.92 1.14      4    4.07 1.48   1   5     4 -0.80    -0.19 0.07
## q20   20 304 4.36 0.88      5    4.50 0.00   1   5     4 -1.39     1.71 0.05
## q21   21 304 4.35 0.96      5    4.52 0.00   1   5     4 -1.54     1.93 0.06
## q22   22 304 4.40 0.84      5    4.53 0.00   1   5     4 -1.22     0.65 0.05
## q23   23 304 4.63 0.68      5    4.79 0.00   2   5     3 -1.61     1.34 0.04
## q24   24 304 4.38 0.87      5    4.52 0.00   1   5     4 -1.35     1.54 0.05
## q25   25 304 4.81 0.50      5    4.95 0.00   3   5     2 -2.62     5.83 0.03
for (item in vars_itens) {
  cat("\n--------------------------------------\n")
  cat("Frquências para o iten:", item, "\n")
  cat("\n--------------------------------------\n")
print(table(dados[[item]], useNA = "ifany"))
}
## 
## --------------------------------------
## Frquências para o iten: q1 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   5   1  23  48 227 
## 
## --------------------------------------
## Frquências para o iten: q2 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   4   5  23  70 202 
## 
## --------------------------------------
## Frquências para o iten: q3 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   5   8  35  77 179 
## 
## --------------------------------------
## Frquências para o iten: q4 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   2   5  20  46 231 
## 
## --------------------------------------
## Frquências para o iten: q5 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   4   3  32  52 213 
## 
## --------------------------------------
## Frquências para o iten: q6 
## 
## --------------------------------------
## 
##  1  2  3  4  5 
## 16 37 83 77 91 
## 
## --------------------------------------
## Frquências para o iten: q7 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   3   5  39  70 187 
## 
## --------------------------------------
## Frquências para o iten: q8 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   3   7  35  70 189 
## 
## --------------------------------------
## Frquências para o iten: q9 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   5   3  40  73 183 
## 
## --------------------------------------
## Frquências para o iten: q10 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   1   3  27  62 211 
## 
## --------------------------------------
## Frquências para o iten: q11 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   3   9  48  80 164 
## 
## --------------------------------------
## Frquências para o iten: q12 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##  11   2  17  35 239 
## 
## --------------------------------------
## Frquências para o iten: q13 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##  31  25  79  65 104 
## 
## --------------------------------------
## Frquências para o iten: q14 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   1   5  15  50 233 
## 
## --------------------------------------
## Frquências para o iten: q15 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   2   2  36  73 191 
## 
## --------------------------------------
## Frquências para o iten: q16 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   3   4  24  37 236 
## 
## --------------------------------------
## Frquências para o iten: q17 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   4   4  28  55 213 
## 
## --------------------------------------
## Frquências para o iten: q18 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##  22  30  97  51 104 
## 
## --------------------------------------
## Frquências para o iten: q19 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##  13  20  72  73 126 
## 
## --------------------------------------
## Frquências para o iten: q20 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   4   5  42  79 174 
## 
## --------------------------------------
## Frquências para o iten: q21 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   7   8  40  66 183 
## 
## --------------------------------------
## Frquências para o iten: q22 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   1   7  44  70 182 
## 
## --------------------------------------
## Frquências para o iten: q23 
## 
## --------------------------------------
## 
##   2   3   4   5 
##   1  31  48 224 
## 
## --------------------------------------
## Frquências para o iten: q24 
## 
## --------------------------------------
## 
##   1   2   3   4   5 
##   4   2  49  68 181 
## 
## --------------------------------------
## Frquências para o iten: q25 
## 
## --------------------------------------
## 
##   3   4   5 
##  15  28 261
#Itens conhecimento
conhecimento_itens <- paste0("q", 1:9)

#Itens Atitudes
atitudes_itens <- paste0("q", 10:17)

#Itens Práticas
praticas_itens <- paste0("q", 18:25)

#Escala Total
total_itens <- vars_itens

Confiabilidade

df_conhecimento <- dados[, conhecimento_itens]
df_atitudes <- dados[, atitudes_itens]
df_praticas <- dados[, praticas_itens]
df_total <- dados[, total_itens]

alpha_conhecimento <- psych::alpha(df_conhecimento, n.iter = 1000, check.keys = TRUE)
print(alpha_conhecimento)
## 
## Reliability analysis   
## Call: psych::alpha(x = df_conhecimento, check.keys = TRUE, n.iter = 1000)
## 
##   raw_alpha std.alpha G6(smc) average_r S/N   ase mean   sd median_r
##       0.67      0.69    0.68       0.2 2.2 0.029  4.4 0.46     0.21
## 
##     95% confidence boundaries 
##              lower alpha upper
## Feldt         0.61  0.67  0.72
## Duhachek      0.61  0.67  0.72
## bootstrapped  0.54  0.65  0.77
## 
##  Reliability if an item is dropped:
##    raw_alpha std.alpha G6(smc) average_r S/N alpha se  var.r med.r
## q1      0.64      0.66    0.65      0.20 2.0    0.032 0.0091  0.20
## q2      0.62      0.65    0.63      0.19 1.8    0.033 0.0092  0.20
## q3      0.66      0.68    0.67      0.21 2.1    0.030 0.0100  0.24
## q4      0.63      0.65    0.64      0.19 1.9    0.032 0.0085  0.20
## q5      0.61      0.64    0.62      0.18 1.8    0.034 0.0087  0.20
## q6      0.70      0.71    0.69      0.23 2.4    0.026 0.0051  0.24
## q7      0.62      0.64    0.63      0.18 1.8    0.034 0.0084  0.20
## q8      0.64      0.67    0.66      0.20 2.0    0.031 0.0103  0.21
## q9      0.63      0.66    0.64      0.19 1.9    0.032 0.0093  0.20
## 
##  Item statistics 
##      n raw.r std.r r.cor r.drop mean   sd
## q1 304  0.52  0.54  0.45   0.36  4.6 0.78
## q2 304  0.59  0.60  0.53   0.44  4.5 0.81
## q3 304  0.47  0.45  0.32   0.27  4.4 0.91
## q4 304  0.55  0.58  0.51   0.40  4.6 0.74
## q5 304  0.61  0.63  0.57   0.47  4.5 0.82
## q6 304  0.41  0.33  0.16   0.13  3.6 1.18
## q7 304  0.61  0.62  0.56   0.45  4.4 0.85
## q8 304  0.50  0.51  0.40   0.32  4.4 0.86
## q9 304  0.55  0.56  0.47   0.38  4.4 0.87
## 
## Non missing response frequency for each item
##       1    2    3    4    5 miss
## q1 0.02 0.00 0.08 0.16 0.75    0
## q2 0.01 0.02 0.08 0.23 0.66    0
## q3 0.02 0.03 0.12 0.25 0.59    0
## q4 0.01 0.02 0.07 0.15 0.76    0
## q5 0.01 0.01 0.11 0.17 0.70    0
## q6 0.05 0.12 0.27 0.25 0.30    0
## q7 0.01 0.02 0.13 0.23 0.62    0
## q8 0.01 0.02 0.12 0.23 0.62    0
## q9 0.02 0.01 0.13 0.24 0.60    0
alpha_atitudes <- psych::alpha(df_atitudes, n.iter = 1000, check.keys = TRUE)
print(alpha_atitudes)
## 
## Reliability analysis   
## Call: psych::alpha(x = df_atitudes, check.keys = TRUE, n.iter = 1000)
## 
##   raw_alpha std.alpha G6(smc) average_r S/N   ase mean   sd median_r
##       0.66      0.68    0.67      0.21 2.1 0.029  4.4 0.48      0.2
## 
##     95% confidence boundaries 
##              lower alpha upper
## Feldt         0.60  0.66  0.71
## Duhachek      0.60  0.66  0.72
## bootstrapped  0.57  0.66  0.73
## 
##  Reliability if an item is dropped:
##     raw_alpha std.alpha G6(smc) average_r S/N alpha se  var.r med.r
## q10      0.62      0.64    0.62      0.21 1.8    0.032 0.0057  0.18
## q11      0.61      0.64    0.62      0.20 1.8    0.034 0.0068  0.18
## q12      0.63      0.66    0.64      0.21 1.9    0.032 0.0069  0.20
## q13      0.67      0.67    0.65      0.22 2.0    0.029 0.0047  0.20
## q14      0.64      0.66    0.65      0.22 2.0    0.031 0.0070  0.21
## q15      0.62      0.64    0.62      0.21 1.8    0.033 0.0058  0.20
## q16      0.63      0.65    0.63      0.21 1.9    0.032 0.0059  0.20
## q17      0.60      0.62    0.60      0.19 1.7    0.034 0.0050  0.18
## 
##  Item statistics 
##       n raw.r std.r r.cor r.drop mean   sd
## q10 304  0.53  0.57  0.48   0.37  4.6 0.72
## q11 304  0.61  0.59  0.51   0.42  4.3 0.91
## q12 304  0.53  0.53  0.41   0.33  4.6 0.91
## q13 304  0.59  0.48  0.35   0.29  3.6 1.31
## q14 304  0.45  0.50  0.36   0.29  4.7 0.68
## q15 304  0.56  0.57  0.48   0.40  4.5 0.78
## q16 304  0.51  0.55  0.45   0.34  4.6 0.77
## q17 304  0.61  0.64  0.58   0.45  4.5 0.82
## 
## Non missing response frequency for each item
##        1    2    3    4    5 miss
## q10 0.00 0.01 0.09 0.20 0.69    0
## q11 0.01 0.03 0.16 0.26 0.54    0
## q12 0.04 0.01 0.06 0.12 0.79    0
## q13 0.10 0.08 0.26 0.21 0.34    0
## q14 0.00 0.02 0.05 0.16 0.77    0
## q15 0.01 0.01 0.12 0.24 0.63    0
## q16 0.01 0.01 0.08 0.12 0.78    0
## q17 0.01 0.01 0.09 0.18 0.70    0
alpha_praticas <- psych::alpha(df_praticas, n.iter = 1000, check.keys = TRUE)
print(alpha_praticas)
## 
## Reliability analysis   
## Call: psych::alpha(x = df_praticas, check.keys = TRUE, n.iter = 1000)
## 
##   raw_alpha std.alpha G6(smc) average_r S/N   ase mean   sd median_r
##       0.71      0.75    0.74      0.27   3 0.025  4.3 0.53     0.27
## 
##     95% confidence boundaries 
##              lower alpha upper
## Feldt         0.66  0.71  0.76
## Duhachek      0.66  0.71  0.76
## bootstrapped  0.64  0.71  0.76
## 
##  Reliability if an item is dropped:
##     raw_alpha std.alpha G6(smc) average_r S/N alpha se  var.r med.r
## q18      0.72      0.75    0.74      0.30 3.1    0.024 0.0094  0.31
## q19      0.71      0.75    0.73      0.30 2.9    0.026 0.0106  0.31
## q20      0.65      0.70    0.68      0.25 2.3    0.031 0.0085  0.24
## q21      0.67      0.72    0.70      0.27 2.5    0.029 0.0091  0.24
## q22      0.68      0.72    0.71      0.27 2.6    0.028 0.0125  0.24
## q23      0.67      0.71    0.69      0.26 2.4    0.029 0.0100  0.24
## q24      0.69      0.74    0.72      0.29 2.8    0.027 0.0113  0.31
## q25      0.68      0.70    0.69      0.25 2.4    0.029 0.0089  0.24
## 
##  Item statistics 
##       n raw.r std.r r.cor r.drop mean   sd
## q18 304  0.54  0.47  0.32   0.28  3.6 1.25
## q19 304  0.55  0.50  0.37   0.32  3.9 1.14
## q20 304  0.69  0.70  0.67   0.56  4.4 0.88
## q21 304  0.63  0.64  0.58   0.46  4.3 0.96
## q22 304  0.59  0.61  0.51   0.43  4.4 0.84
## q23 304  0.62  0.67  0.62   0.51  4.6 0.68
## q24 304  0.53  0.55  0.43   0.36  4.4 0.87
## q25 304  0.62  0.69  0.65   0.54  4.8 0.50
## 
## Non missing response frequency for each item
##        1    2    3    4    5 miss
## q18 0.07 0.10 0.32 0.17 0.34    0
## q19 0.04 0.07 0.24 0.24 0.41    0
## q20 0.01 0.02 0.14 0.26 0.57    0
## q21 0.02 0.03 0.13 0.22 0.60    0
## q22 0.00 0.02 0.14 0.23 0.60    0
## q23 0.00 0.00 0.10 0.16 0.74    0
## q24 0.01 0.01 0.16 0.22 0.60    0
## q25 0.00 0.00 0.05 0.09 0.86    0
alpha_total <- psych::alpha(df_total, n.iter = 1000, check.keys = TRUE)
print(alpha_total)
## 
## Reliability analysis   
## Call: psych::alpha(x = df_total, check.keys = TRUE, n.iter = 1000)
## 
##   raw_alpha std.alpha G6(smc) average_r S/N   ase mean   sd median_r
##       0.85      0.86    0.88       0.2 6.3 0.013  4.4 0.41      0.2
## 
##     95% confidence boundaries 
##              lower alpha upper
## Feldt         0.82  0.85  0.87
## Duhachek      0.82  0.85  0.87
## bootstrapped  0.81  0.85  0.88
## 
##  Reliability if an item is dropped:
##     raw_alpha std.alpha G6(smc) average_r S/N alpha se  var.r med.r
## q1       0.84      0.86    0.88      0.20 6.1    0.013 0.0079  0.20
## q2       0.84      0.86    0.87      0.20 5.9    0.013 0.0080  0.20
## q3       0.85      0.86    0.88      0.21 6.2    0.013 0.0080  0.21
## q4       0.84      0.86    0.88      0.20 6.0    0.013 0.0082  0.20
## q5       0.84      0.86    0.87      0.20 5.9    0.013 0.0081  0.20
## q6       0.85      0.86    0.88      0.21 6.4    0.012 0.0069  0.21
## q7       0.84      0.86    0.88      0.20 6.0    0.013 0.0082  0.20
## q8       0.84      0.86    0.88      0.20 6.0    0.013 0.0082  0.20
## q9       0.84      0.86    0.87      0.20 6.0    0.013 0.0078  0.20
## q10      0.84      0.86    0.87      0.20 6.0    0.013 0.0080  0.20
## q11      0.84      0.86    0.88      0.20 6.1    0.013 0.0084  0.20
## q12      0.84      0.86    0.88      0.20 6.0    0.013 0.0081  0.20
## q13      0.85      0.86    0.88      0.21 6.3    0.012 0.0077  0.21
## q14      0.85      0.86    0.88      0.20 6.2    0.013 0.0082  0.21
## q15      0.84      0.86    0.88      0.20 6.0    0.013 0.0082  0.20
## q16      0.84      0.86    0.88      0.20 6.0    0.013 0.0079  0.20
## q17      0.84      0.86    0.87      0.20 5.9    0.013 0.0080  0.20
## q18      0.85      0.86    0.88      0.20 6.2    0.013 0.0082  0.21
## q19      0.85      0.86    0.88      0.20 6.2    0.013 0.0082  0.21
## q20      0.84      0.85    0.87      0.19 5.8    0.013 0.0071  0.20
## q21      0.84      0.85    0.87      0.20 5.9    0.013 0.0076  0.20
## q22      0.84      0.86    0.87      0.20 5.9    0.013 0.0081  0.20
## q23      0.84      0.85    0.87      0.20 5.9    0.013 0.0076  0.20
## q24      0.84      0.86    0.88      0.20 6.1    0.013 0.0080  0.20
## q25      0.84      0.85    0.87      0.20 5.8    0.013 0.0076  0.20
## 
##  Item statistics 
##       n raw.r std.r r.cor r.drop mean   sd
## q1  304  0.41  0.42  0.38   0.34  4.6 0.78
## q2  304  0.54  0.54  0.53   0.48  4.5 0.81
## q3  304  0.36  0.36  0.31   0.28  4.4 0.91
## q4  304  0.46  0.47  0.44   0.40  4.6 0.74
## q5  304  0.55  0.55  0.53   0.49  4.5 0.82
## q6  304  0.31  0.26  0.21   0.20  3.6 1.18
## q7  304  0.51  0.51  0.49   0.44  4.4 0.85
## q8  304  0.50  0.50  0.47   0.44  4.4 0.86
## q9  304  0.53  0.53  0.51   0.46  4.4 0.87
## q10 304  0.49  0.51  0.48   0.44  4.6 0.72
## q11 304  0.48  0.47  0.44   0.41  4.3 0.91
## q12 304  0.48  0.49  0.45   0.41  4.6 0.91
## q13 304  0.39  0.34  0.29   0.27  3.6 1.31
## q14 304  0.37  0.39  0.34   0.31  4.7 0.68
## q15 304  0.48  0.49  0.46   0.42  4.5 0.78
## q16 304  0.48  0.50  0.48   0.42  4.6 0.77
## q17 304  0.54  0.55  0.53   0.48  4.5 0.82
## q18 304  0.43  0.40  0.36   0.33  3.6 1.25
## q19 304  0.44  0.41  0.37   0.34  3.9 1.14
## q20 304  0.62  0.62  0.62   0.56  4.4 0.88
## q21 304  0.56  0.57  0.55   0.49  4.3 0.96
## q22 304  0.53  0.54  0.51   0.46  4.4 0.84
## q23 304  0.55  0.58  0.56   0.50  4.6 0.68
## q24 304  0.46  0.46  0.43   0.39  4.4 0.87
## q25 304  0.56  0.59  0.58   0.53  4.8 0.50
## 
## Non missing response frequency for each item
##        1    2    3    4    5 miss
## q1  0.02 0.00 0.08 0.16 0.75    0
## q2  0.01 0.02 0.08 0.23 0.66    0
## q3  0.02 0.03 0.12 0.25 0.59    0
## q4  0.01 0.02 0.07 0.15 0.76    0
## q5  0.01 0.01 0.11 0.17 0.70    0
## q6  0.05 0.12 0.27 0.25 0.30    0
## q7  0.01 0.02 0.13 0.23 0.62    0
## q8  0.01 0.02 0.12 0.23 0.62    0
## q9  0.02 0.01 0.13 0.24 0.60    0
## q10 0.00 0.01 0.09 0.20 0.69    0
## q11 0.01 0.03 0.16 0.26 0.54    0
## q12 0.04 0.01 0.06 0.12 0.79    0
## q13 0.10 0.08 0.26 0.21 0.34    0
## q14 0.00 0.02 0.05 0.16 0.77    0
## q15 0.01 0.01 0.12 0.24 0.63    0
## q16 0.01 0.01 0.08 0.12 0.78    0
## q17 0.01 0.01 0.09 0.18 0.70    0
## q18 0.07 0.10 0.32 0.17 0.34    0
## q19 0.04 0.07 0.24 0.24 0.41    0
## q20 0.01 0.02 0.14 0.26 0.57    0
## q21 0.02 0.03 0.13 0.22 0.60    0
## q22 0.00 0.02 0.14 0.23 0.60    0
## q23 0.00 0.00 0.10 0.16 0.74    0
## q24 0.01 0.01 0.16 0.22 0.60    0
## q25 0.00 0.00 0.05 0.09 0.86    0

Análise Fatorial Exploratória Antes da AFE, verificamos se os dados são fatorizáveis usando o teste de Kaiser-Meyer-Olkin (KMO) e o teste de esfericidade de Bartlett. - KMO: Valores acima de 0.7 são considerados bons. - Teste de Bartlett: Um resultado significativo (p < 0.05) indica que as correlações entre os itens são suficientemente grandes para uma AFE.

#matriz de correlação
cor_matrix <- cor(dados[vars_itens], use = "pairwise.complete.obs")

#Teste de Bartlett
cortest.bartlett(cor_matrix, n = nrow(dados))
## $chisq
## [1] 1770.116
## 
## $p.value
## [1] 1.667612e-206
## 
## $df
## [1] 300
#Teste KMO
KMO(cor_matrix)
## Kaiser-Meyer-Olkin factor adequacy
## Call: KMO(r = cor_matrix)
## Overall MSA =  0.84
## MSA for each item = 
##   q1   q2   q3   q4   q5   q6   q7   q8   q9  q10  q11  q12  q13  q14  q15  q16 
## 0.78 0.82 0.85 0.86 0.87 0.64 0.87 0.87 0.84 0.82 0.82 0.90 0.71 0.87 0.80 0.86 
##  q17  q18  q19  q20  q21  q22  q23  q24  q25 
## 0.83 0.89 0.85 0.83 0.88 0.86 0.86 0.76 0.87
#Análise Paralela
fa.parallel(dados[vars_itens], fa = "fa", fm = "pa")

## Parallel analysis suggests that the number of factors =  6  and the number of components =  NA
#considerando os 5 fatores sugeridos na análise paralela
afa_6fatores <- fa(dados[vars_itens],
                   nfactors = 1,
                   rotate = "oblimin",
                   fm = "pa")

print(afa_6fatores$loadings, sort = TRUE, cut = 0.4)
## 
## Loadings:
##     PA1  
## q2  0.515
## q5  0.525
## q9  0.514
## q17 0.518
## q20 0.625
## q21 0.566
## q22 0.509
## q23 0.568
## q25 0.589
## q1       
## q3       
## q4  0.440
## q6       
## q7  0.480
## q8  0.469
## q10 0.482
## q11 0.407
## q12 0.462
## q13      
## q14      
## q15 0.440
## q16 0.482
## q18      
## q19      
## q24 0.426
## 
##                  PA1
## SS loadings    5.287
## Proportion Var 0.211
#considerando os 3 fatores do instrumento original
afa_3fatores <- fa(dados[vars_itens],
                   nfactors = 3,
                   rotate = "oblimin",
                   fm = "pa")

print(afa_3fatores$loadings, sort = TRUE, cut = 0.3)
## 
## Loadings:
##     PA1    PA3    PA2   
## q4   0.520              
## q7   0.516              
## q10  0.554              
## q16  0.533              
## q17  0.519              
## q20         0.901       
## q6                 0.598
## q1                      
## q2   0.404              
## q3   0.349              
## q5   0.356              
## q8   0.472              
## q9          0.457       
## q11  0.382         0.356
## q12  0.417              
## q13                0.435
## q14  0.405              
## q15                0.359
## q18  0.340              
## q19                     
## q21         0.415       
## q22  0.389              
## q23  0.372              
## q24                     
## q25  0.320  0.315       
## 
##                  PA1   PA3   PA2
## SS loadings    3.338 1.644 0.971
## Proportion Var 0.134 0.066 0.039
## Cumulative Var 0.134 0.199 0.238

A Análise Fatorial Exploratória não suporta a estrutura teórica inicial de três fatores (Conhecimento, Atitudes e Práticas). Os fatores extraídos são uma mistura de itens das diferentes dimensões teóricas.

Itens 1, 19 e 24 não carregaram em nenhum fator, vou tentar remover eles para ver como fica a análise. #q20 foi excluído porque é muito idêntico ao q9 #q5 foi excluído porque é muito idêntico ao q21 #q11 foi excluído porque é muito idêntico ao q17

itens_para_remover <- c("q1", "q3", "q5", "q6", "q11", "q13", "q14", "q18", "q19")

vars_itens_revised <- setdiff(vars_itens, itens_para_remover)

print(vars_itens_revised)
##  [1] "q2"  "q4"  "q7"  "q8"  "q9"  "q10" "q12" "q15" "q16" "q17" "q20" "q21"
## [13] "q22" "q23" "q24" "q25"
#considerando os 3 fatores do instrumento original
afa_3fatores_revisado <- fa(dados[vars_itens_revised],
                   nfactors = 1,
         #          nfactors = 3,
                   rotate = "oblimin",
                   fm = "pa")

print(afa_3fatores_revisado$loadings, sort = TRUE, cut = 0.4)
## 
## Loadings:
##     PA1  
## q2  0.506
## q9  0.506
## q17 0.508
## q20 0.637
## q21 0.593
## q22 0.517
## q23 0.596
## q25 0.602
## q4  0.422
## q7  0.462
## q8  0.466
## q10 0.476
## q12 0.472
## q15 0.419
## q16 0.485
## q24 0.438
## 
##                  PA1
## SS loadings    4.174
## Proportion Var 0.261

De fato os itens não estão ajustando adequadamente, mas vamos tentar a AFC mesmo assim

modelo_afc <- ' 
#Fatores Latentes
Conhecimento =~ #q1 + 
                 q2 + q3 + q4 + #q5
                 q6 + q7 + q8 + q9
Atitudes     =~ q10 + #q11 + 
                q12 + q13 + q14 + q15 + q16 + q17
Praticas     =~ q18 + #q19 + q20 + 
                q21 + q22 + q23 + #q24 + 
                q25
' 

Avaliamos a qualidade do ajuste do modelo usando vários índices. - Qui-quadrado (\(\chi^2\)): Desejável não significativo (p > 0.05), mas sensível a amostras grandes. - CFI (Comparative Fit Index): > 0.90 (aceitável), > 0.95 (bom). - TLI (Tucker-Lewis Index): > 0.90 (aceitável), > 0.95 (bom). - RMSEA (Root Mean Square Error of Approximation): < 0.08 (aceitável), < 0.06 (bom). O intervalo de confiança de 90% também é informativo. - SRMR (Standardized Root Mean Square Residual): < 0.08 (bom).

#ajustando o modelo de AFC

fit_afc <- cfa(modelo_afc, data = dados, std.lv=TRUE, missing = "FIML")

summary(fit_afc, fit.measures=TRUE, standardized=TRUE)
## lavaan 0.6-20 ended normally after 28 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        60
## 
##   Number of observations                           304
##   Number of missing patterns                         1
## 
## Model Test User Model:
##                                                       
##   Test statistic                               276.445
##   Degrees of freedom                               149
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1132.195
##   Degrees of freedom                               171
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.867
##   Tucker-Lewis Index (TLI)                       0.848
##                                                       
##   Robust Comparative Fit Index (CFI)             0.867
##   Robust Tucker-Lewis Index (TLI)                0.848
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -6778.941
##   Loglikelihood unrestricted model (H1)      -6640.718
##                                                       
##   Akaike (AIC)                               13677.881
##   Bayesian (BIC)                             13900.903
##   Sample-size adjusted Bayesian (SABIC)      13710.613
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.053
##   90 Percent confidence interval - lower         0.043
##   90 Percent confidence interval - upper         0.063
##   P-value H_0: RMSEA <= 0.050                    0.294
##   P-value H_0: RMSEA >= 0.080                    0.000
##                                                       
##   Robust RMSEA                                   0.053
##   90 Percent confidence interval - lower         0.043
##   90 Percent confidence interval - upper         0.063
##   P-value H_0: Robust RMSEA <= 0.050             0.294
##   P-value H_0: Robust RMSEA >= 0.080             0.000
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.051
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Conhecimento =~                                                       
##     q2                0.427    0.050    8.535    0.000    0.427    0.527
##     q3                0.298    0.057    5.202    0.000    0.298    0.329
##     q4                0.362    0.045    7.983    0.000    0.362    0.493
##     q6                0.166    0.077    2.165    0.030    0.166    0.140
##     q7                0.442    0.053    8.382    0.000    0.442    0.522
##     q8                0.424    0.053    8.066    0.000    0.424    0.495
##     q9                0.415    0.054    7.746    0.000    0.415    0.476
##   Atitudes =~                                                           
##     q10               0.366    0.043    8.534    0.000    0.366    0.507
##     q12               0.439    0.054    8.087    0.000    0.439    0.483
##     q13               0.326    0.082    3.963    0.000    0.326    0.250
##     q14               0.248    0.042    5.942    0.000    0.248    0.367
##     q15               0.339    0.048    7.098    0.000    0.339    0.435
##     q16               0.403    0.045    8.864    0.000    0.403    0.527
##     q17               0.449    0.050    9.040    0.000    0.449    0.549
##   Praticas =~                                                           
##     q18               0.435    0.078    5.584    0.000    0.435    0.349
##     q21               0.530    0.057    9.253    0.000    0.530    0.551
##     q22               0.458    0.050    9.149    0.000    0.458    0.545
##     q23               0.436    0.040   10.975    0.000    0.436    0.645
##     q25               0.323    0.030   10.935    0.000    0.323    0.643
## 
## Covariances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Conhecimento ~~                                                       
##     Atitudes          0.918    0.053   17.391    0.000    0.918    0.918
##     Praticas          0.799    0.056   14.152    0.000    0.799    0.799
##   Atitudes ~~                                                           
##     Praticas          0.888    0.050   17.806    0.000    0.888    0.888
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .q2                4.516    0.047   97.106    0.000    4.516    5.569
##    .q3                4.372    0.052   84.223    0.000    4.372    4.830
##    .q4                4.641    0.042  110.208    0.000    4.641    6.321
##    .q6                3.625    0.068   53.565    0.000    3.625    3.072
##    .q7                4.424    0.049   91.041    0.000    4.424    5.222
##    .q8                4.431    0.049   90.293    0.000    4.431    5.179
##    .q9                4.401    0.050   88.026    0.000    4.401    5.049
##    .q10               4.576    0.041  110.571    0.000    4.576    6.342
##    .q12               4.609    0.052   88.533    0.000    4.609    5.078
##    .q13               3.612    0.075   48.328    0.000    3.612    2.772
##    .q14               4.674    0.039  120.632    0.000    4.674    6.919
##    .q15               4.477    0.045  100.378    0.000    4.477    5.757
##    .q16               4.641    0.044  105.783    0.000    4.641    6.067
##    .q17               4.543    0.047   96.821    0.000    4.543    5.553
##    .q18               3.609    0.071   50.471    0.000    3.609    2.895
##    .q21               4.349    0.055   78.858    0.000    4.349    4.523
##    .q22               4.398    0.048   91.217    0.000    4.398    5.232
##    .q23               4.628    0.039  119.342    0.000    4.628    6.845
##    .q25               4.809    0.029  166.682    0.000    4.809    9.560
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .q2                0.475    0.044   10.741    0.000    0.475    0.722
##    .q3                0.730    0.061   11.893    0.000    0.730    0.891
##    .q4                0.408    0.037   11.067    0.000    0.408    0.757
##    .q6                1.365    0.111   12.256    0.000    1.365    0.980
##    .q7                0.522    0.049   10.708    0.000    0.522    0.727
##    .q8                0.553    0.050   11.117    0.000    0.553    0.755
##    .q9                0.588    0.052   11.269    0.000    0.588    0.774
##    .q10               0.387    0.034   11.302    0.000    0.387    0.743
##    .q12               0.631    0.055   11.445    0.000    0.631    0.767
##    .q13               1.592    0.131   12.123    0.000    1.592    0.938
##    .q14               0.395    0.033   11.861    0.000    0.395    0.866
##    .q15               0.490    0.042   11.560    0.000    0.490    0.811
##    .q16               0.423    0.038   11.135    0.000    0.423    0.723
##    .q17               0.468    0.044   10.680    0.000    0.468    0.699
##    .q18               1.365    0.115   11.871    0.000    1.365    0.878
##    .q21               0.644    0.059   10.871    0.000    0.644    0.697
##    .q22               0.497    0.045   10.922    0.000    0.497    0.703
##    .q23               0.267    0.028    9.660    0.000    0.267    0.584
##    .q25               0.149    0.015    9.699    0.000    0.149    0.587
##     Conhecimento      1.000                               1.000    1.000
##     Atitudes          1.000                               1.000    1.000
##     Praticas          1.000                               1.000    1.000
#como o ajuste não foi bom, vamos verificar

modindices(fit_afc) %>%
as.data.frame() %>%
arrange(-mi) %>%
head(10)
##         lhs op rhs        mi         epc     sepc.lv   sepc.all   sepc.nox
## 1       q16 ~~ q23 22.296596  0.10572694  0.10572694  0.3146416  0.3146416
## 2        q6 ~~ q13 16.105764  0.34251931  0.34251931  0.2323757  0.2323757
## 3  Praticas =~ q17 14.556665 -0.76647156 -0.76647156 -0.9369369 -0.9369369
## 4       q13 ~~ q15 13.135058  0.19062729  0.19062729  0.2158055  0.2158055
## 5       q23 ~~ q25 11.777932  0.05448004  0.05448004  0.2735554  0.2735554
## 6       q15 ~~ q17 11.088885  0.10123294  0.10123294  0.2114059  0.2114059
## 7       q14 ~~ q23  8.866271 -0.06199768 -0.06199768 -0.1908745 -0.1908745
## 8  Atitudes =~  q8  7.843268  0.86755314  0.86755314  1.0139573  1.0139573
## 9        q8 ~~ q17  7.729117  0.09001501  0.09001501  0.1770210  0.1770210
## 10       q2 ~~  q7  7.160522  0.08927718  0.08927718  0.1792633  0.1792633
# Especificação de um modelo unidimensional
modelo_unidimensional_afc <- '
  # Todos os itens a carregar num único fator "Competencia_Etica"
  Competencia_Etica =~ q2 + q4 + q5 + q7 + q8 + q9 + q10 + 
                       q12 + q15 + q16 + q17 + q20 + q21 + q22 + q23 + q25
'

# Ajustar o modelo de AFC unidimensional
fit_unidimensional_afc <- cfa(modelo_unidimensional_afc, data = dados, std.lv=TRUE, missing = "FIML")

summary(fit_unidimensional_afc, fit.measures=TRUE, standardized=TRUE)
## lavaan 0.6-20 ended normally after 20 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        48
## 
##   Number of observations                           304
##   Number of missing patterns                         1
## 
## Model Test User Model:
##                                                       
##   Test statistic                               289.828
##   Degrees of freedom                               104
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1220.681
##   Degrees of freedom                               120
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.831
##   Tucker-Lewis Index (TLI)                       0.805
##                                                       
##   Robust Comparative Fit Index (CFI)             0.831
##   Robust Tucker-Lewis Index (TLI)                0.805
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5298.678
##   Loglikelihood unrestricted model (H1)      -5153.764
##                                                       
##   Akaike (AIC)                               10693.356
##   Bayesian (BIC)                             10871.773
##   Sample-size adjusted Bayesian (SABIC)      10719.541
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.077
##   90 Percent confidence interval - lower         0.066
##   90 Percent confidence interval - upper         0.087
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    0.310
##                                                       
##   Robust RMSEA                                   0.077
##   90 Percent confidence interval - lower         0.066
##   90 Percent confidence interval - upper         0.087
##   P-value H_0: Robust RMSEA <= 0.050             0.000
##   P-value H_0: Robust RMSEA >= 0.080             0.310
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.057
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                        Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##   Competencia_Etica =~                                                      
##     q2                    0.391    0.047    8.298    0.000    0.391    0.483
##     q4                    0.320    0.043    7.381    0.000    0.320    0.436
##     q5                    0.422    0.047    8.904    0.000    0.422    0.513
##     q7                    0.385    0.050    7.737    0.000    0.385    0.454
##     q8                    0.392    0.050    7.812    0.000    0.392    0.458
##     q9                    0.467    0.050    9.325    0.000    0.467    0.536
##     q10                   0.348    0.042    8.274    0.000    0.348    0.482
##     q12                   0.431    0.053    8.151    0.000    0.431    0.475
##     q15                   0.322    0.046    6.983    0.000    0.322    0.414
##     q16                   0.374    0.045    8.391    0.000    0.374    0.489
##     q17                   0.419    0.047    8.870    0.000    0.419    0.512
##     q20                   0.568    0.048   11.798    0.000    0.568    0.650
##     q21                   0.571    0.054   10.588    0.000    0.571    0.594
##     q22                   0.418    0.049    8.588    0.000    0.418    0.497
##     q23                   0.395    0.038   10.335    0.000    0.395    0.583
##     q25                   0.304    0.028   10.784    0.000    0.304    0.603
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .q2                4.516    0.047   97.106    0.000    4.516    5.569
##    .q4                4.641    0.042  110.208    0.000    4.641    6.321
##    .q5                4.536    0.047   96.172    0.000    4.536    5.516
##    .q7                4.424    0.049   91.041    0.000    4.424    5.222
##    .q8                4.431    0.049   90.293    0.000    4.431    5.179
##    .q9                4.401    0.050   88.026    0.000    4.401    5.049
##    .q10               4.576    0.041  110.571    0.000    4.576    6.342
##    .q12               4.609    0.052   88.533    0.000    4.609    5.078
##    .q15               4.477    0.045  100.378    0.000    4.477    5.757
##    .q16               4.641    0.044  105.783    0.000    4.641    6.067
##    .q17               4.543    0.047   96.821    0.000    4.543    5.553
##    .q20               4.362    0.050   87.019    0.000    4.362    4.991
##    .q21               4.349    0.055   78.858    0.000    4.349    4.523
##    .q22               4.398    0.048   91.217    0.000    4.398    5.232
##    .q23               4.628    0.039  119.342    0.000    4.628    6.845
##    .q25               4.809    0.029  166.682    0.000    4.809    9.560
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)   Std.lv  Std.all
##    .q2                0.504    0.043   11.677    0.000    0.504    0.767
##    .q4                0.437    0.037   11.814    0.000    0.437    0.810
##    .q5                0.498    0.043   11.564    0.000    0.498    0.737
##    .q7                0.570    0.048   11.765    0.000    0.570    0.794
##    .q8                0.579    0.049   11.754    0.000    0.579    0.790
##    .q9                0.542    0.047   11.419    0.000    0.542    0.713
##    .q10               0.400    0.034   11.672    0.000    0.400    0.768
##    .q12               0.638    0.054   11.714    0.000    0.638    0.775
##    .q15               0.501    0.042   11.884    0.000    0.501    0.829
##    .q16               0.445    0.038   11.628    0.000    0.445    0.761
##    .q17               0.494    0.043   11.549    0.000    0.494    0.738
##    .q20               0.441    0.041   10.669    0.000    0.441    0.578
##    .q21               0.599    0.054   11.156    0.000    0.599    0.648
##    .q22               0.532    0.046   11.623    0.000    0.532    0.753
##    .q23               0.302    0.027   11.174    0.000    0.302    0.660
##    .q25               0.161    0.015   11.069    0.000    0.161    0.636
##     Competenci_Etc    1.000                               1.000    1.000
# Analisar os índices de ajuste
cat("--- Resultados do Modelo de 1 Fator (o seu modelo validado) ---\n")
## --- Resultados do Modelo de 1 Fator (o seu modelo validado) ---
summary(fit_unidimensional_afc, fit.measures=TRUE) # Use o nome do seu objeto de modelo bem-sucedido aqui
## lavaan 0.6-20 ended normally after 20 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        48
## 
##   Number of observations                           304
##   Number of missing patterns                         1
## 
## Model Test User Model:
##                                                       
##   Test statistic                               289.828
##   Degrees of freedom                               104
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1220.681
##   Degrees of freedom                               120
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.831
##   Tucker-Lewis Index (TLI)                       0.805
##                                                       
##   Robust Comparative Fit Index (CFI)             0.831
##   Robust Tucker-Lewis Index (TLI)                0.805
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5298.678
##   Loglikelihood unrestricted model (H1)      -5153.764
##                                                       
##   Akaike (AIC)                               10693.356
##   Bayesian (BIC)                             10871.773
##   Sample-size adjusted Bayesian (SABIC)      10719.541
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.077
##   90 Percent confidence interval - lower         0.066
##   90 Percent confidence interval - upper         0.087
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    0.310
##                                                       
##   Robust RMSEA                                   0.077
##   90 Percent confidence interval - lower         0.066
##   90 Percent confidence interval - upper         0.087
##   P-value H_0: Robust RMSEA <= 0.050             0.000
##   P-value H_0: Robust RMSEA >= 0.080             0.310
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.057
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                        Estimate  Std.Err  z-value  P(>|z|)
##   Competencia_Etica =~                                    
##     q2                    0.391    0.047    8.298    0.000
##     q4                    0.320    0.043    7.381    0.000
##     q5                    0.422    0.047    8.904    0.000
##     q7                    0.385    0.050    7.737    0.000
##     q8                    0.392    0.050    7.812    0.000
##     q9                    0.467    0.050    9.325    0.000
##     q10                   0.348    0.042    8.274    0.000
##     q12                   0.431    0.053    8.151    0.000
##     q15                   0.322    0.046    6.983    0.000
##     q16                   0.374    0.045    8.391    0.000
##     q17                   0.419    0.047    8.870    0.000
##     q20                   0.568    0.048   11.798    0.000
##     q21                   0.571    0.054   10.588    0.000
##     q22                   0.418    0.049    8.588    0.000
##     q23                   0.395    0.038   10.335    0.000
##     q25                   0.304    0.028   10.784    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .q2                4.516    0.047   97.106    0.000
##    .q4                4.641    0.042  110.208    0.000
##    .q5                4.536    0.047   96.172    0.000
##    .q7                4.424    0.049   91.041    0.000
##    .q8                4.431    0.049   90.293    0.000
##    .q9                4.401    0.050   88.026    0.000
##    .q10               4.576    0.041  110.571    0.000
##    .q12               4.609    0.052   88.533    0.000
##    .q15               4.477    0.045  100.378    0.000
##    .q16               4.641    0.044  105.783    0.000
##    .q17               4.543    0.047   96.821    0.000
##    .q20               4.362    0.050   87.019    0.000
##    .q21               4.349    0.055   78.858    0.000
##    .q22               4.398    0.048   91.217    0.000
##    .q23               4.628    0.039  119.342    0.000
##    .q25               4.809    0.029  166.682    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .q2                0.504    0.043   11.677    0.000
##    .q4                0.437    0.037   11.814    0.000
##    .q5                0.498    0.043   11.564    0.000
##    .q7                0.570    0.048   11.765    0.000
##    .q8                0.579    0.049   11.754    0.000
##    .q9                0.542    0.047   11.419    0.000
##    .q10               0.400    0.034   11.672    0.000
##    .q12               0.638    0.054   11.714    0.000
##    .q15               0.501    0.042   11.884    0.000
##    .q16               0.445    0.038   11.628    0.000
##    .q17               0.494    0.043   11.549    0.000
##    .q20               0.441    0.041   10.669    0.000
##    .q21               0.599    0.054   11.156    0.000
##    .q22               0.532    0.046   11.623    0.000
##    .q23               0.302    0.027   11.174    0.000
##    .q25               0.161    0.015   11.069    0.000
##     Competenci_Etc    1.000
cat("\n\n--- Resultados do Modelo de 1 Fator ---\n")
## 
## 
## --- Resultados do Modelo de 1 Fator ---
summary(fit_unidimensional_afc, fit.measures=TRUE)
## lavaan 0.6-20 ended normally after 20 iterations
## 
##   Estimator                                         ML
##   Optimization method                           NLMINB
##   Number of model parameters                        48
## 
##   Number of observations                           304
##   Number of missing patterns                         1
## 
## Model Test User Model:
##                                                       
##   Test statistic                               289.828
##   Degrees of freedom                               104
##   P-value (Chi-square)                           0.000
## 
## Model Test Baseline Model:
## 
##   Test statistic                              1220.681
##   Degrees of freedom                               120
##   P-value                                        0.000
## 
## User Model versus Baseline Model:
## 
##   Comparative Fit Index (CFI)                    0.831
##   Tucker-Lewis Index (TLI)                       0.805
##                                                       
##   Robust Comparative Fit Index (CFI)             0.831
##   Robust Tucker-Lewis Index (TLI)                0.805
## 
## Loglikelihood and Information Criteria:
## 
##   Loglikelihood user model (H0)              -5298.678
##   Loglikelihood unrestricted model (H1)      -5153.764
##                                                       
##   Akaike (AIC)                               10693.356
##   Bayesian (BIC)                             10871.773
##   Sample-size adjusted Bayesian (SABIC)      10719.541
## 
## Root Mean Square Error of Approximation:
## 
##   RMSEA                                          0.077
##   90 Percent confidence interval - lower         0.066
##   90 Percent confidence interval - upper         0.087
##   P-value H_0: RMSEA <= 0.050                    0.000
##   P-value H_0: RMSEA >= 0.080                    0.310
##                                                       
##   Robust RMSEA                                   0.077
##   90 Percent confidence interval - lower         0.066
##   90 Percent confidence interval - upper         0.087
##   P-value H_0: Robust RMSEA <= 0.050             0.000
##   P-value H_0: Robust RMSEA >= 0.080             0.310
## 
## Standardized Root Mean Square Residual:
## 
##   SRMR                                           0.057
## 
## Parameter Estimates:
## 
##   Standard errors                             Standard
##   Information                                 Observed
##   Observed information based on                Hessian
## 
## Latent Variables:
##                        Estimate  Std.Err  z-value  P(>|z|)
##   Competencia_Etica =~                                    
##     q2                    0.391    0.047    8.298    0.000
##     q4                    0.320    0.043    7.381    0.000
##     q5                    0.422    0.047    8.904    0.000
##     q7                    0.385    0.050    7.737    0.000
##     q8                    0.392    0.050    7.812    0.000
##     q9                    0.467    0.050    9.325    0.000
##     q10                   0.348    0.042    8.274    0.000
##     q12                   0.431    0.053    8.151    0.000
##     q15                   0.322    0.046    6.983    0.000
##     q16                   0.374    0.045    8.391    0.000
##     q17                   0.419    0.047    8.870    0.000
##     q20                   0.568    0.048   11.798    0.000
##     q21                   0.571    0.054   10.588    0.000
##     q22                   0.418    0.049    8.588    0.000
##     q23                   0.395    0.038   10.335    0.000
##     q25                   0.304    0.028   10.784    0.000
## 
## Intercepts:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .q2                4.516    0.047   97.106    0.000
##    .q4                4.641    0.042  110.208    0.000
##    .q5                4.536    0.047   96.172    0.000
##    .q7                4.424    0.049   91.041    0.000
##    .q8                4.431    0.049   90.293    0.000
##    .q9                4.401    0.050   88.026    0.000
##    .q10               4.576    0.041  110.571    0.000
##    .q12               4.609    0.052   88.533    0.000
##    .q15               4.477    0.045  100.378    0.000
##    .q16               4.641    0.044  105.783    0.000
##    .q17               4.543    0.047   96.821    0.000
##    .q20               4.362    0.050   87.019    0.000
##    .q21               4.349    0.055   78.858    0.000
##    .q22               4.398    0.048   91.217    0.000
##    .q23               4.628    0.039  119.342    0.000
##    .q25               4.809    0.029  166.682    0.000
## 
## Variances:
##                    Estimate  Std.Err  z-value  P(>|z|)
##    .q2                0.504    0.043   11.677    0.000
##    .q4                0.437    0.037   11.814    0.000
##    .q5                0.498    0.043   11.564    0.000
##    .q7                0.570    0.048   11.765    0.000
##    .q8                0.579    0.049   11.754    0.000
##    .q9                0.542    0.047   11.419    0.000
##    .q10               0.400    0.034   11.672    0.000
##    .q12               0.638    0.054   11.714    0.000
##    .q15               0.501    0.042   11.884    0.000
##    .q16               0.445    0.038   11.628    0.000
##    .q17               0.494    0.043   11.549    0.000
##    .q20               0.441    0.041   10.669    0.000
##    .q21               0.599    0.054   11.156    0.000
##    .q22               0.532    0.046   11.623    0.000
##    .q23               0.302    0.027   11.174    0.000
##    .q25               0.161    0.015   11.069    0.000
##     Competenci_Etc    1.000
modindices(fit_unidimensional_afc) %>%
as.data.frame() %>%
arrange(-mi) %>%
head(10)
##    lhs op rhs        mi         epc     sepc.lv   sepc.all   sepc.nox
## 1   q9 ~~ q20 32.423893  0.17934736  0.17934736  0.3666895  0.3666895
## 2  q16 ~~ q23 21.976455  0.10679782  0.10679782  0.2913657  0.2913657
## 3  q23 ~~ q25 19.147158  0.06180048  0.06180048  0.2805096  0.2805096
## 4  q20 ~~ q21 14.799149  0.12980400  0.12980400  0.2524845  0.2524845
## 5  q15 ~~ q17 13.550683  0.11060103  0.11060103  0.2223521  0.2223521
## 6   q2 ~~  q7 12.680781  0.11536556  0.11536556  0.2151594  0.2151594
## 7   q8 ~~ q17 10.872937  0.10710609  0.10710609  0.2004092  0.2004092
## 8   q4 ~~ q20 10.675668 -0.09040994 -0.09040994 -0.2058730 -0.2058730
## 9   q4 ~~  q5  9.243871  0.08594911  0.08594911  0.1842125  0.1842125
## 10  q9 ~~ q15  9.076539 -0.09528414 -0.09528414 -0.1828335 -0.1828335