Ative as bibliotecas e abra o arquivo de dados do enem

  setwd("~/Dropbox (Personal)/TRI/2017_exercicios")
  load("enem2015b.RData")
 # save.image("~/Dropbox (Personal)/TRI/2017_exercicios/enem2015b.RData")
  library(psych)
  library(mirt)
  library(dplyr)
  library(ggplot2)
  library(stringr)

Análise TRI 3 parâmetros usando o MIRT com a especificação de prioris

Especifica o modelo e extrai o dataframe com os parâmetros
  • Examine o dataframe com os valores iniciais e fixos dos parâmetros
  • Note que a média da distribuição é M = 0 e DP = 1
# Especifica o modelo
        m3pl <- mirt.model( "th_ch = 1-45  
                PRIOR = (1-45, a1, lnorm, 1, 0.3), 
                (1-45, d, norm, 0, 1),
                (1-45, g, norm, -1.386294, .2)"
                   )

# Extrai data frame com valores iniciais

        df <- mirt(score_ch, 
                model = m3pl, 
                itemtype="3PL", 
                pars = 'values')
Calibração dos parâmetros dos itens no modo default
  • Veja a métrica dos parâmetros
# Calibra itens

        ch_m3pl1 <- mirt(score_ch, 
                model = m3pl,  TOL = .001,
                itemtype="3PL")
# parâmetros dos itens
  
        ch_m3pl_pars1 <- coef(ch_m3pl1 , simplify=TRUE, IRTpars=TRUE)

  View(ch_m3pl_pars1$items)
## Warning: execução do comando ''/usr/bin/otool' -L '/Library/Frameworks/
## R.framework/Resources/modules/R_de.so'' teve status 69
        describe(ch_m3pl_pars1$items)
##   vars  n mean   sd median trimmed  mad   min  max range skew kurtosis
## a    1 45 1.28 0.56   1.28    1.27 0.59  0.34 2.36  2.02 0.14    -0.96
## b    2 45 1.09 1.38   1.18    1.07 0.88 -2.11 6.28  8.39 0.69     3.18
## g    3 45 0.18 0.09   0.16    0.16 0.09  0.06 0.44  0.38 1.07     0.73
## u    4 45 1.00 0.00   1.00    1.00 0.00  1.00 1.00  0.00  NaN      NaN
##     se
## a 0.08
## b 0.21
## g 0.01
## u 0.00
  • Mas note qual a média da distribuição das notas a partir da qual estamos calibrando
  • Note que o ENEM está na escala M=500 e DP=100. Esses valores correspondem a média dos alunos das escolas públicas em 2009
  • Precisamos fazer o calculo para \(z =\frac{ENEM-500}{100}\) na escala 0 e 1
  • Essa amostra em 2015 está praticamente meio desvio padrão acima da média
        M <- (mean(enem_2015$NU_NOTA_CH, na.rm = TRUE) - 500) / 100
        DP <- sd(enem_2015$NU_NOTA_CH, na.rm = TRUE) / 100
        
        M
## [1] 0.593585
        DP
## [1] 0.7050225
Calibração dos parâmetros dos itens fixando a métrica na distribuição observada
  • Vamos então fixar a M e DP nesses alores e ver o que acontece.
# Fixando os parâmetros M e DP
        df[df$name == "MEAN_1", ]$value <- M
        df[df$name == "COV_11", ]$value <- DP*DP

# Calibrando novamente
        ch_m3pl2 <- mirt(score_ch, 
                model = m3pl,  TOL = .001,
                itemtype="3PL", 
                pars = df 
                )

 # Parâmetros dos itens 
        ch_m3pl_pars2 <- coef(ch_m3pl2 , simplify=TRUE, IRTpars=TRUE)
        
        
# Calibrando novamente com empiricalhist = TRUE   
        ch_m3pl3 <- mirt(score_ch, 
                model = m3pl,  TOL = .001,
                itemtype="3PL", 
                empiricalhist = TRUE
                )     
 
        ch_m3pl_pars3 <- coef(ch_m3pl3 , simplify=TRUE, IRTpars=TRUE)
        

# Calibrando novamente eliminando itens 11 17, 26, 33, 36, 40 

        m3plb <- mirt.model( "th_ch = 1-10, 12-16, 18-25, 27-32, 34-35, 37-39, 41-45 
                PRIOR = (1-10, 12-16, 18-25, 27-32, 34-35, 37-39, 41-45 , a1, lnorm, 1, 0.3), 
                (1-10, 12-16, 18-25, 27-32, 34-35, 37-39, 41-45 , d, norm, 0, 1),
                (1-10, 12-16, 18-25, 27-32, 34-35, 37-39, 41-45 , g, norm, -1.386294, .2)"
                   )
        
        dfb <- mirt(score_ch, 
                model = m3plb, 
                itemtype="3PL", 
                pars = 'values')
         
        dfb[dfb$name == "MEAN_1", ]$value <- M
        dfb[dfb$name == "COV_11", ]$value <- DP*DP

        ch_m3pl4 <- mirt(score_ch, 
                model = m3plb,  TOL = .001,
                itemtype="3PL", 
                pars = dfb 
                )    
        
        ch_m3pl_pars4 <- coef(ch_m3pl4 , simplify=TRUE, IRTpars=TRUE)
       
        View(ch_m3pl_pars4$items)
  describe(ch_m3pl_pars2$items)
##   vars  n mean   sd median trimmed  mad   min  max range skew kurtosis
## a    1 45 1.79 0.78   1.72    1.78 0.83  0.43 3.31  2.87 0.13    -0.96
## b    2 45 1.37 0.99   1.40    1.34 0.66 -0.90 5.23  6.13 0.85     3.66
## g    3 45 0.17 0.09   0.15    0.16 0.09  0.06 0.44  0.38 1.02     0.63
## u    4 45 1.00 0.00   1.00    1.00 0.00  1.00 1.00  0.00  NaN      NaN
##     se
## a 0.12
## b 0.15
## g 0.01
## u 0.00
  describe(ch_m3pl_pars3$items)
##   vars  n mean   sd median trimmed  mad   min  max range skew kurtosis
## a    1 45 3.43 1.61    3.5    3.42 1.45  0.65 6.44  5.78 0.01    -0.97
## b    2 45 0.05 0.64    0.1    0.06 0.35 -1.80 2.65  4.45 0.62     5.74
## g    3 45 0.22 0.09    0.2    0.21 0.09  0.07 0.47  0.40 0.75     0.17
## u    4 45 1.00 0.00    1.0    1.00 0.00  1.00 1.00  0.00  NaN      NaN
##     se
## a 0.24
## b 0.10
## g 0.01
## u 0.00
  describe(ch_m3pl_pars4$items, na.rm = TRUE)
##   vars  n mean   sd median trimmed  mad  min  max range  skew kurtosis
## a    1 45 1.60 0.90   1.70    1.61 0.80 0.00 3.29  3.29 -0.23    -0.67
## b    2 45  NaN  NaN   1.42    1.41 0.83 -Inf  Inf   Inf   NaN      NaN
## g    3 45 0.16 0.07   0.15    0.15 0.07 0.06 0.35  0.29  0.74     0.08
## u    4 45 1.00 0.00   1.00    1.00 0.00 1.00 1.00  0.00   NaN      NaN
##     se
## a 0.13
## b  NaN
## g 0.01
## u 0.00
Comparando a métrica das estimativas de theta
  • Estima os thetas segundo os 3 modelos
# Estima habilidades usando os tres modelos
        theta_ch1 = fscores(ch_m3pl1 , method = "EAP", full.scores.SE = TRUE)
        theta_ch2 = fscores(ch_m3pl2 , method = "EAP", full.scores.SE = TRUE)
        theta_ch3 = fscores(ch_m3pl3 , method = "EAP", full.scores.SE = TRUE)
        theta_ch4 = fscores(ch_m3pl4 , method = "EAP", full.scores.SE = TRUE)

#  Adiciona na base  

        df_scores <- as.data.frame(cbind(theta_ch1 = theta_ch1[ , 1], 
                                         theta_ch2 = theta_ch2[ , 1], 
                                         theta_ch3 = theta_ch3[ , 1],
                                         theta_ch4 = theta_ch4[ , 1]))

# Transformando a nota na base de 500/100 para 0/1
        
        
        describe(enem_2015$NU_NOTA_CHz)
        names(enem_2015)
        enem_2015 <- enem_2015[ , c(1:167)]
        enem_2015$NU_NOTA_CHz <- (enem_2015$NU_NOTA_CH - 500)/100
        
        
        enem_2015 <- cbind(enem_2015, df_scores)
    describe(enem_2015[ , c(167:172)])
##             vars      n  mean   sd median trimmed  mad   min   max range
## totCH          1 119827 19.06 6.67  18.00   18.63 5.93  0.00 43.00 43.00
## NU_NOTA_CHz    2 119827  0.59 0.71   0.65    0.62 0.69 -5.00  3.23  8.23
## theta_ch1      3 119827  0.00 0.89  -0.06   -0.03 0.94 -2.30  3.24  5.55
## theta_ch2      4 119827  0.59 0.63   0.55    0.57 0.66 -1.04  2.88  3.92
## theta_ch3      5 119827 -0.56 0.55  -0.51   -0.54 0.60 -2.07  1.41  3.48
## theta_ch4      6 119827  0.59 0.63   0.55    0.57 0.66 -0.93  2.88  3.81
##              skew kurtosis   se
## totCH        0.57    -0.03 0.02
## NU_NOTA_CHz -0.33     0.29 0.00
## theta_ch1    0.26    -0.36 0.00
## theta_ch2    0.26    -0.36 0.00
## theta_ch3   -0.27    -0.56 0.00
## theta_ch4    0.29    -0.37 0.00
  • Vamos ver a distribuição e a relação entre esses escores estimados
# Distribuição dos escores
         ggplot(data=enem_2015, aes(x=NU_NOTA_CHz)) + 
            geom_histogram(alpha =.4, fill ="red", color="gray",  binwidth=.25)+ 
            scale_x_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3))
## Warning: Removed 15 rows containing non-finite values (stat_bin).

        ggplot(data=enem_2015, aes(x=theta_ch1)) + 
            geom_histogram(alpha =.4, fill ="blue", color="gray",  binwidth=.25)+ 
            scale_x_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3))
## Warning: Removed 11 rows containing non-finite values (stat_bin).

        ggplot(data=enem_2015, aes(x=theta_ch2)) + 
            geom_histogram(alpha =.4, fill ="orange", color="gray",  binwidth=.25)+ 
            scale_x_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3))

        ggplot(data=enem_2015, aes(x=theta_ch3)) + 
            geom_histogram(alpha =.4, fill ="green",color="gray",  binwidth=.25)+ 
            scale_x_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3))

        ggplot(data=enem_2015, aes(x=theta_ch4)) + 
            geom_histogram(alpha =.4, fill ="yellow", color="gray",  binwidth=.25)+ 
            scale_x_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3))

# Correlação entre estimações   
        ggplot(data=enem_2015, aes(y=NU_NOTA_CHz, x=theta_ch1, colour = theta_ch1)) + 
            geom_point(alpha = 1/8) +
            geom_smooth(method = "lm") +    
            scale_x_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3)) +
            scale_y_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3))    
## Warning: Removed 24 rows containing non-finite values (stat_smooth).
## Warning: Removed 24 rows containing missing values (geom_point).

        ggplot(data=enem_2015, aes(y=NU_NOTA_CHz, x=theta_ch2, colour = theta_ch2)) + 
            geom_point(alpha = 1/8) +
            geom_smooth(method = "lm") +    
            scale_x_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3)) +
            scale_y_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3))  
## Warning: Removed 15 rows containing non-finite values (stat_smooth).
## Warning: Removed 15 rows containing missing values (geom_point).
## Warning: Removed 1 rows containing missing values (geom_smooth).

        ggplot(data=enem_2015, aes(y=NU_NOTA_CHz, x=theta_ch3, colour = theta_ch3)) + 
            geom_point(alpha = 1/8) +
            geom_smooth(method = "lm") +    
            scale_x_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3)) +
            scale_y_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3))
## Warning: Removed 15 rows containing non-finite values (stat_smooth).
## Warning: Removed 15 rows containing missing values (geom_point).

         ggplot(data=enem_2015, aes(y=NU_NOTA_CHz, x=theta_ch4, colour = theta_ch4)) + 
            geom_point(alpha = 1/8) +
            geom_smooth(method = "lm") +    
            scale_x_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3)) +
            scale_y_continuous(breaks=seq(-3, 3, .5), limits = c(-3, 3))
## Warning: Removed 15 rows containing non-finite values (stat_smooth).

## Warning: Removed 15 rows containing missing values (geom_point).
## Warning: Removed 1 rows containing missing values (geom_smooth).

##### Testes de ajuste do modelo

  ch_fit <- M2(ch_m3pl2)
  ch_itemfit <- itemfit(ch_m3pl2, fit_stats = c("S_X2", "X2", "infit" ))
    ch_fit 
##             M2  df p     RMSEA    RMSEA_5   RMSEA_95      SRMSR       TLI
## stats 12777.97 900 0 0.0104948 0.01033381 0.01065653 0.01143787 0.9867429
##             CFI
## stats 0.9879481
   ch_itemfit 
##    item       X2 df.X2 p.X2    S_X2 df.S_X2 p.S_X2
## 1   ch1  497.502     7    0 136.780      36  0.000
## 2   ch2 2039.428     7    0  43.784      35  0.147
## 3   ch3  398.793     7    0  62.070      36  0.004
## 4   ch4  717.628     7    0  44.340      36  0.160
## 5   ch5  337.234     7    0 103.707      35  0.000
## 6   ch6  579.398     7    0  49.357      37  0.084
## 7   ch7  176.420     7    0  50.869      37  0.064
## 8   ch8  426.919     7    0 140.848      36  0.000
## 9   ch9 2555.050     7    0 337.003      36  0.000
## 10 ch10  291.800     7    0 228.887      36  0.000
## 11 ch11 1234.331     7    0 324.433      38  0.000
## 12 ch12 1323.351     7    0  63.963      36  0.003
## 13 ch13  739.277     7    0  77.131      35  0.000
## 14 ch14  902.405     7    0  74.770      36  0.000
## 15 ch15  331.005     7    0  61.412      36  0.005
## 16 ch16   98.731     7    0  70.525      37  0.001
## 17 ch17  186.851     7    0  69.003      36  0.001
## 18 ch18  487.626     7    0  74.788      37  0.000
## 19 ch19  775.253     7    0  57.454      35  0.010
## 20 ch20   46.872     7    0 107.870      37  0.000
## 21 ch21 2024.368     7    0 321.871      36  0.000
## 22 ch22  346.049     7    0  53.114      37  0.042
## 23 ch23   97.532     7    0  69.512      37  0.001
## 24 ch24  454.470     7    0 280.494      35  0.000
## 25 ch25 1317.571     7    0 163.716      37  0.000
## 26 ch26  233.542     7    0 145.595      37  0.000
## 27 ch27 1036.216     7    0  41.467      35  0.209
## 28 ch28  211.648     7    0  38.062      36  0.376
## 29 ch29 1843.715     7    0 329.915      36  0.000
## 30 ch30  279.211     7    0  46.001      36  0.123
## 31 ch31  182.756     7    0  51.012      37  0.062
## 32 ch32  319.716     7    0  77.767      37  0.000
## 33 ch33  750.164     7    0 287.569      37  0.000
## 34 ch34  170.399     7    0  51.578      37  0.056
## 35 ch35  367.942     7    0 292.504      36  0.000
## 36 ch36  161.450     7    0 106.194      37  0.000
## 37 ch37   81.557     7    0  49.213      37  0.086
## 38 ch38  216.401     7    0  44.286      36  0.162
## 39 ch39  857.427     7    0 209.210      35  0.000
## 40 ch40  103.553     7    0  46.156      38  0.171
## 41 ch41  182.993     7    0  29.494      37  0.805
## 42 ch42 2331.394     7    0  84.147      36  0.000
## 43 ch43  232.512     7    0  38.655      36  0.351
## 44 ch44 1007.336     7    0 107.761      37  0.000
## 45 ch45  285.512     7    0 102.744      37  0.000
  itemfit(ch_m3pl2, group.bins=40, empirical.plot = 9)

  itemfit(ch_m3pl2, group.bins=40, empirical.plot = 11)

  itemfit(ch_m3pl2, group.bins=40, empirical.plot = 21)

  itemfit(ch_m3pl2, group.bins=40, empirical.plot = 29)

  itemfit(ch_m3pl2, group.bins=40, empirical.plot = 41)

  itemfit(ch_m3pl2, group.bins=40, empirical.plot = 40)

##### Testando DIF em relação ao gênero

  • Primeiro vamos testar se há diferenças nas notas entre homens e mulheres
  library(mosaic)
## Loading required package: ggformula
## 
## New to ggformula?  Try the tutorials: 
##  learnr::run_tutorial("introduction", package = "ggformula")
##  learnr::run_tutorial("refining", package = "ggformula")
## Loading required package: mosaicData
## Loading required package: Matrix
## 
## The 'mosaic' package masks several functions from core packages in order to add 
## additional features.  The original behavior of these functions should not be affected by this.
## 
## Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.
## 
## Attaching package: 'mosaic'
## The following object is masked from 'package:Matrix':
## 
##     mean
## The following objects are masked from 'package:dplyr':
## 
##     count, do, tally
## The following objects are masked from 'package:psych':
## 
##     logit, read.file, rescale
## The following objects are masked from 'package:stats':
## 
##     binom.test, cor, cor.test, cov, fivenum, IQR, median,
##     prop.test, quantile, sd, t.test, var
## The following objects are masked from 'package:base':
## 
##     max, mean, min, prod, range, sample, sum
  gf_dens(~theta_ch2 , data = enem_2015, color = ~ as.factor(TP_SEXO))

  t.test(~theta_ch2 | TP_SEXO, data = enem_2015)
## theta_ch2 ~ TP_SEXO
## 
##  Welch Two Sample t-test
## 
## data:  theta_ch2 by TP_SEXO
## t = -50.217, df = 102920, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1919142 -0.1774959
## sample estimates:
## mean in group F mean in group M 
##       0.5147622       0.6994673
  cor(enem_2015$theta_ch2, as.numeric(as.factor(enem_2015$TP_SEXO)), use =  "pair")
## [1] 0.1449739
library(difR)

table(enem_2015$TP_SEXO)

dif_ch <- difLogistic(Data = score_ch, 
                      group = enem_2015$TP_SEXO, 
                      focal.name = "M")

dif_ch2 <- dichoDif(Data=score_ch, 
                    group=enem_2015$TP_SEXO, 
                    focal.name="M", 
                    method=c("MH", "Std", "Lord", "Raju"), 
                    model="1PL", purify=TRUE, nrIter=20)
  dif_ch
## $Logistik
##  [1] 687.8937463   4.6066715  70.8187302 184.7517926  64.4682556
##  [6]  99.9173844  28.0607986  36.1242083 401.3211756 159.6420028
## [11]  70.1062967 204.6175310 452.1480447 172.5950083 147.5415597
## [16]  58.9531628 111.7497923  80.2270536 106.8054199  39.7047487
## [21] 108.5023373  16.0293155 109.5018026 194.4217612  91.6197820
## [26] 485.8829354 417.7531264   0.4424562 274.0619486 340.6120533
## [31] 659.5030667  31.1126802 744.9171892  22.3067908  85.5347065
## [36]  60.2069826 214.6615507 109.6043512  32.2938317  53.0033386
## [41] 100.0387546 733.3292438  57.7843914 176.1384491 584.2717749
## 
## $logitPar
##       (Intercept)      SCORE        GROUP   SCORE:GROUP
##  [1,]  -2.6177738 0.12302258  0.122987647  0.0108286031
##  [2,]  -2.5386497 0.18193856  0.000000000  0.0000000000
##  [3,]  -3.2032076 0.14655526  0.166584407 -0.0125841011
##  [4,]  -1.7712136 0.12728756  0.496846083 -0.0203300890
##  [5,]  -5.0565113 0.17004176  0.243164569 -0.0148745388
##  [6,]  -2.8516014 0.12605362 -0.029938453 -0.0048752998
##  [7,]  -3.0864427 0.08997327 -0.169792873  0.0045341115
##  [8,]  -2.4504448 0.12155318  0.096502071 -0.0010702296
##  [9,]  -1.3157188 0.14176181  0.115566804 -0.0223466925
## [10,]  -3.3958936 0.08983932  0.044424001  0.0068331288
## [11,]  -0.4822236 0.07973361  0.308859251 -0.0124427619
## [12,]  -3.4748237 0.17746999  0.382931938 -0.0107230035
## [13,]  -4.2068523 0.19527382 -0.137556739 -0.0079623906
## [14,]  -2.9230871 0.15186633 -0.035974560 -0.0068822726
## [15,]  -3.4423971 0.13336186 -0.033777602  0.0092536700
## [16,]  -2.6678056 0.07375614  0.242485478 -0.0069966152
## [17,]  -1.4734929 0.08594657 -0.400670509  0.0170853708
## [18,]  -1.8174740 0.08667087  0.128029056 -0.0009249320
## [19,]  -2.8486060 0.15896201  0.209167667 -0.0041012282
## [20,]  -2.8220663 0.05649091  0.193297455 -0.0121781829
## [21,]  -1.1965372 0.11617757  0.442581410 -0.0209722397
## [22,]  -2.8116361 0.11904167  0.007338503  0.0021594295
## [23,]  -2.0417852 0.04300257 -0.467376358  0.0209978511
## [24,]  -4.4074782 0.14328987 -0.131420805  0.0148990588
## [25,]  -2.4877554 0.13229279  0.278555991 -0.0178991181
## [26,]  -0.7066440 0.05363425 -0.104160555  0.0187858698
## [27,]  -3.2929825 0.17118484  0.054318769  0.0114960863
## [28,]  -3.1991584 0.11736152  0.000000000  0.0000000000
## [29,]  -3.1558900 0.17841562  0.198381374 -0.0209388146
## [30,]  -2.9784034 0.09471286  0.166683239  0.0041418730
## [31,]  -2.0702845 0.07394783  0.022047026  0.0144886732
## [32,]  -2.1204968 0.08174531  0.082206021 -0.0005998082
## [33,]  -1.5307903 0.08042058  0.046119492 -0.0184965291
## [34,]  -2.5833934 0.10152615 -0.014026198 -0.0022650245
## [35,]  -3.9423402 0.11929278  0.034074728  0.0048935074
## [36,]  -1.7080292 0.06589876 -0.222108907  0.0133358304
## [37,]  -1.5089342 0.06906010 -0.118519587 -0.0030725984
## [38,]  -2.5398098 0.10563321 -0.410078273  0.0216580408
## [39,]  -3.9789227 0.16478661  0.197088320 -0.0115385939
## [40,]  -1.5510960 0.03537444 -0.265116739  0.0098172119
## [41,]  -2.4782209 0.09328286 -0.315175019  0.0098160640
## [42,]  -1.9140741 0.16790595 -0.219097945 -0.0096712077
## [43,]  -2.5014173 0.11082439 -0.161888986  0.0033649986
## [44,]  -1.2790010 0.11468368 -0.072516214 -0.0057325099
## [45,]  -1.6354360 0.07389130 -0.149074281 -0.0074331404
## 
## $logitSe
##       (Intercept)       SCORE      GROUP SCORE:GROUP
##  [1,]  0.02760459 0.001424478 0.04357762 0.002186193
##  [2,]  0.02412591 0.001382200 0.00000000 0.000000000
##  [3,]  0.02967710 0.001514261 0.04579529 0.002220094
##  [4,]  0.02753360 0.001551461 0.04286061 0.002297794
##  [5,]  0.04101658 0.001809333 0.06247460 0.002638787
##  [6,]  0.02830312 0.001435989 0.04434114 0.002127118
##  [7,]  0.03115145 0.001470964 0.04928863 0.002194475
##  [8,]  0.02722053 0.001423375 0.04259532 0.002129444
##  [9,]  0.03062007 0.001845265 0.04646853 0.002625449
## [10,]  0.03404685 0.001575303 0.05167451 0.002280864
## [11,]  0.02690683 0.001512042 0.04260256 0.002256805
## [12,]  0.03129603 0.001657948 0.04817567 0.002471196
## [13,]  0.03414766 0.001736364 0.05376365 0.002576536
## [14,]  0.02914222 0.001548300 0.04557831 0.002289884
## [15,]  0.03076940 0.001492800 0.04799368 0.002240279
## [16,]  0.02951049 0.001418651 0.04505474 0.002064358
## [17,]  0.02501917 0.001330824 0.04015766 0.002025555
## [18,]  0.02528793 0.001311117 0.03954118 0.001953459
## [19,]  0.02938644 0.001597605 0.04603678 0.002411652
## [20,]  0.03340883 0.001596071 0.05223077 0.002373964
## [21,]  0.02800798 0.001615779 0.04382485 0.002387892
## [22,]  0.02814483 0.001414605 0.04401742 0.002111714
## [23,]  0.02811716 0.001389634 0.04497444 0.002072160
## [24,]  0.03735401 0.001679164 0.05760481 0.002494697
## [25,]  0.02767854 0.001474175 0.04251672 0.002146568
## [26,]  0.02394821 0.001269694 0.03873798 0.001969577
## [27,]  0.03064398 0.001632828 0.04885974 0.002542156
## [28,]  0.02277263 0.001057497 0.00000000 0.000000000
## [29,]  0.03080126 0.001691660 0.04722480 0.002452984
## [30,]  0.02990237 0.001428916 0.04546651 0.002086316
## [31,]  0.02604469 0.001301825 0.04055970 0.001945478
## [32,]  0.02604171 0.001309073 0.04052427 0.001936535
## [33,]  0.02481350 0.001301672 0.03857129 0.001891288
## [34,]  0.02744027 0.001366716 0.04297163 0.002026284
## [35,]  0.03555965 0.001614837 0.05431901 0.002362774
## [36,]  0.02497739 0.001267971 0.03958494 0.001902914
## [37,]  0.02453684 0.001267049 0.03866200 0.001875702
## [38,]  0.02723187 0.001370752 0.04391550 0.002102384
## [39,]  0.03299397 0.001610657 0.05062255 0.002361552
## [40,]  0.02570986 0.001294132 0.04085948 0.001928711
## [41,]  0.02718304 0.001349367 0.04350350 0.002032873
## [42,]  0.03133393 0.001898283 0.04821493 0.002743421
## [43,]  0.02712193 0.001382613 0.04292030 0.002069070
## [44,]  0.02755616 0.001574964 0.04285407 0.002310778
## [45,]  0.02479602 0.001277880 0.03920196 0.001889478
## 
## $parM0
##       (Intercept)      SCORE        GROUP   SCORE:GROUP
##  [1,]  -2.6177738 0.12302258  0.122987647  0.0108286031
##  [2,]  -2.5811301 0.18436007  0.106487091 -0.0058154885
##  [3,]  -3.2032076 0.14655526  0.166584407 -0.0125841011
##  [4,]  -1.7712136 0.12728756  0.496846083 -0.0203300890
##  [5,]  -5.0565113 0.17004176  0.243164569 -0.0148745388
##  [6,]  -2.8516014 0.12605362 -0.029938453 -0.0048752998
##  [7,]  -3.0864427 0.08997327 -0.169792873  0.0045341115
##  [8,]  -2.4504448 0.12155318  0.096502071 -0.0010702296
##  [9,]  -1.3157188 0.14176181  0.115566804 -0.0223466925
## [10,]  -3.3958936 0.08983932  0.044424001  0.0068331288
## [11,]  -0.4822236 0.07973361  0.308859251 -0.0124427619
## [12,]  -3.4748237 0.17746999  0.382931938 -0.0107230035
## [13,]  -4.2068523 0.19527382 -0.137556739 -0.0079623906
## [14,]  -2.9230871 0.15186633 -0.035974560 -0.0068822726
## [15,]  -3.4423971 0.13336186 -0.033777602  0.0092536700
## [16,]  -2.6678056 0.07375614  0.242485478 -0.0069966152
## [17,]  -1.4734929 0.08594657 -0.400670509  0.0170853708
## [18,]  -1.8174740 0.08667087  0.128029056 -0.0009249320
## [19,]  -2.8486060 0.15896201  0.209167667 -0.0041012282
## [20,]  -2.8220663 0.05649091  0.193297455 -0.0121781829
## [21,]  -1.1965372 0.11617757  0.442581410 -0.0209722397
## [22,]  -2.8116361 0.11904167  0.007338503  0.0021594295
## [23,]  -2.0417852 0.04300257 -0.467376358  0.0209978511
## [24,]  -4.4074782 0.14328987 -0.131420805  0.0148990588
## [25,]  -2.4877554 0.13229279  0.278555991 -0.0178991181
## [26,]  -0.7066440 0.05363425 -0.104160555  0.0187858698
## [27,]  -3.2929825 0.17118484  0.054318769  0.0114960863
## [28,]  -3.2104945 0.11800593  0.024367170 -0.0013313708
## [29,]  -3.1558900 0.17841562  0.198381374 -0.0209388146
## [30,]  -2.9784034 0.09471286  0.166683239  0.0041418730
## [31,]  -2.0702845 0.07394783  0.022047026  0.0144886732
## [32,]  -2.1204968 0.08174531  0.082206021 -0.0005998082
## [33,]  -1.5307903 0.08042058  0.046119492 -0.0184965291
## [34,]  -2.5833934 0.10152615 -0.014026198 -0.0022650245
## [35,]  -3.9423402 0.11929278  0.034074728  0.0048935074
## [36,]  -1.7080292 0.06589876 -0.222108907  0.0133358304
## [37,]  -1.5089342 0.06906010 -0.118519587 -0.0030725984
## [38,]  -2.5398098 0.10563321 -0.410078273  0.0216580408
## [39,]  -3.9789227 0.16478661  0.197088320 -0.0115385939
## [40,]  -1.5510960 0.03537444 -0.265116739  0.0098172119
## [41,]  -2.4782209 0.09328286 -0.315175019  0.0098160640
## [42,]  -1.9140741 0.16790595 -0.219097945 -0.0096712077
## [43,]  -2.5014173 0.11082439 -0.161888986  0.0033649986
## [44,]  -1.2790010 0.11468368 -0.072516214 -0.0057325099
## [45,]  -1.6354360 0.07389130 -0.149074281 -0.0074331404
## 
## $seM0
##       (Intercept)       SCORE      GROUP SCORE:GROUP
##  [1,]  0.02760459 0.001424478 0.04357762 0.002186193
##  [2,]  0.03138575 0.001850609 0.04958891 0.002804420
##  [3,]  0.02967710 0.001514261 0.04579529 0.002220094
##  [4,]  0.02753360 0.001551461 0.04286061 0.002297794
##  [5,]  0.04101658 0.001809333 0.06247460 0.002638787
##  [6,]  0.02830312 0.001435989 0.04434114 0.002127118
##  [7,]  0.03115145 0.001470964 0.04928863 0.002194475
##  [8,]  0.02722053 0.001423375 0.04259532 0.002129444
##  [9,]  0.03062007 0.001845265 0.04646853 0.002625449
## [10,]  0.03404685 0.001575303 0.05167451 0.002280864
## [11,]  0.02690683 0.001512042 0.04260256 0.002256805
## [12,]  0.03129603 0.001657948 0.04817567 0.002471196
## [13,]  0.03414766 0.001736364 0.05376365 0.002576536
## [14,]  0.02914222 0.001548300 0.04557831 0.002289884
## [15,]  0.03076940 0.001492800 0.04799368 0.002240279
## [16,]  0.02951049 0.001418651 0.04505474 0.002064358
## [17,]  0.02501917 0.001330824 0.04015766 0.002025555
## [18,]  0.02528793 0.001311117 0.03954118 0.001953459
## [19,]  0.02938644 0.001597605 0.04603678 0.002411652
## [20,]  0.03340883 0.001596071 0.05223077 0.002373964
## [21,]  0.02800798 0.001615779 0.04382485 0.002387892
## [22,]  0.02814483 0.001414605 0.04401742 0.002111714
## [23,]  0.02811716 0.001389634 0.04497444 0.002072160
## [24,]  0.03735401 0.001679164 0.05760481 0.002494697
## [25,]  0.02767854 0.001474175 0.04251672 0.002146568
## [26,]  0.02394821 0.001269694 0.03873798 0.001969577
## [27,]  0.03064398 0.001632828 0.04885974 0.002542156
## [28,]  0.03000991 0.001450027 0.04668540 0.002146554
## [29,]  0.03080126 0.001691660 0.04722480 0.002452984
## [30,]  0.02990237 0.001428916 0.04546651 0.002086316
## [31,]  0.02604469 0.001301825 0.04055970 0.001945478
## [32,]  0.02604171 0.001309073 0.04052427 0.001936535
## [33,]  0.02481350 0.001301672 0.03857129 0.001891288
## [34,]  0.02744027 0.001366716 0.04297163 0.002026284
## [35,]  0.03555965 0.001614837 0.05431901 0.002362774
## [36,]  0.02497739 0.001267971 0.03958494 0.001902914
## [37,]  0.02453684 0.001267049 0.03866200 0.001875702
## [38,]  0.02723187 0.001370752 0.04391550 0.002102384
## [39,]  0.03299397 0.001610657 0.05062255 0.002361552
## [40,]  0.02570986 0.001294132 0.04085948 0.001928711
## [41,]  0.02718304 0.001349367 0.04350350 0.002032873
## [42,]  0.03133393 0.001898283 0.04821493 0.002743421
## [43,]  0.02712193 0.001382613 0.04292030 0.002069070
## [44,]  0.02755616 0.001574964 0.04285407 0.002310778
## [45,]  0.02479602 0.001277880 0.03920196 0.001889478
## 
## $cov.M0
## NULL
## 
## $cov.M1
## NULL
## 
## $deltaR2
##  [1] 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
## [36] 0 0 0 0 0 0 0 0 0 0
## 
## $alpha
## [1] 0.05
## 
## $thr
## [1] 5.991465
## 
## $DIFitems
##  [1]  1  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
## [24] 25 26 27 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
## 
## $member.type
## [1] "group"
## 
## $match
## [1] "score"
## 
## $type
## [1] "both"
## 
## $p.adjust.method
## NULL
## 
## $adjusted.p
## NULL
## 
## $purification
## [1] FALSE
## 
## $names
##  [1] "ch1"  "ch2"  "ch3"  "ch4"  "ch5"  "ch6"  "ch7"  "ch8"  "ch9"  "ch10"
## [11] "ch11" "ch12" "ch13" "ch14" "ch15" "ch16" "ch17" "ch18" "ch19" "ch20"
## [21] "ch21" "ch22" "ch23" "ch24" "ch25" "ch26" "ch27" "ch28" "ch29" "ch30"
## [31] "ch31" "ch32" "ch33" "ch34" "ch35" "ch36" "ch37" "ch38" "ch39" "ch40"
## [41] "ch41" "ch42" "ch43" "ch44" "ch45"
## 
## $anchor.names
## NULL
## 
## $criterion
## [1] "LRT"
## 
## $save.output
## [1] FALSE
## 
## $output
## [1] "out"     "default"
## 
## attr(,"class")
## [1] "Logistic"
  dif_ch2
## $DIF
##      M-H     Stand.  Lord    Raju   
## ch1  "DIF"   "NoDIF" "DIF"   "DIF"  
## ch2  "NoDIF" "NoDIF" "DIF"   "DIF"  
## ch3  "DIF"   "NoDIF" "DIF"   "DIF"  
## ch4  "DIF"   "NoDIF" "DIF"   "DIF"  
## ch5  "DIF"   "NoDIF" "NoDIF" "NoDIF"
## ch6  "DIF"   "NoDIF" "DIF"   "DIF"  
## ch7  "DIF"   "NoDIF" "DIF"   "DIF"  
## ch8  "DIF"   "NoDIF" "DIF"   "DIF"  
## ch9  "DIF"   "NoDIF" "DIF"   "DIF"  
## ch10 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch11 "NoDIF" "NoDIF" "NoDIF" "NoDIF"
## ch12 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch13 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch14 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch15 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch16 "NoDIF" "NoDIF" "NoDIF" "NoDIF"
## ch17 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch18 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch19 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch20 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch21 "NoDIF" "NoDIF" "DIF"   "DIF"  
## ch22 "NoDIF" "NoDIF" "DIF"   "DIF"  
## ch23 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch24 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch25 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch26 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch27 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch28 "DIF"   "NoDIF" "NoDIF" "NoDIF"
## ch29 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch30 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch31 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch32 "NoDIF" "NoDIF" "NoDIF" "NoDIF"
## ch33 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch34 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch35 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch36 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch37 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch38 "NoDIF" "NoDIF" "NoDIF" "NoDIF"
## ch39 "DIF"   "NoDIF" "NoDIF" "NoDIF"
## ch40 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch41 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch42 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch43 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch44 "DIF"   "NoDIF" "DIF"   "DIF"  
## ch45 "DIF"   "NoDIF" "DIF"   "DIF"  
## 
## $props
## NULL
## 
## $thrTID
## [1] 1.5
## 
## $correct
## [1] TRUE
## 
## $exact
## [1] FALSE
## 
## $alpha
## [1] 0.05
## 
## $MHstat
## [1] "MHChisq"
## 
## $stdWeight
## [1] "focal"
## 
## $thrSTD
## [1] 0.1
## 
## $BDstat
## [1] "BD"
## 
## $member.type
## [1] "group"
## 
## $match
## [1] "score"
## 
## $type
## [1] "both"
## 
## $criterion
## [1] "LRT"
## 
## $model
## [1] "1PL"
## 
## $c
## NULL
## 
## $engine
## [1] "ltm"
## 
## $discr
## [1] 1
## 
## $irtParam
## NULL
## 
## $same.scale
## [1] TRUE
## 
## $signed
## [1] FALSE
## 
## $purification
## [1] TRUE
## 
## $nrPur
## [1] 4 0 3 3
## 
## $convergence
## [1] TRUE TRUE TRUE TRUE
## 
## $anchor.names
## NULL
## 
## $p.adjust.method
## NULL
## 
## $save.output
## [1] FALSE
## 
## $output
## [1] "out"     "default"
## 
## attr(,"class")
## [1] "dichoDif"
  # plot(dif_ch)
Resolvendo DIF
  # 11, 16, 32 , 38
  ch_m3pl_dif <- multipleGroup(
      data = score_ch, model =  m3pl, 
      group = enem_2015$TP_SEXO, 
      invariance = c( ch_itens[c(2, 5, 11, 16, 21, 22, 28, 32, 38, 39)], 
        'free_means', 'free_var'),
      itemtype="3PL",
       TOL = .001
                )

  ch_m3pl_pars_dif <- coef(ch_m3pl_dif, simplify=TRUE, IRTpars=TRUE)
  ch_m3pl_pars_dif
## $F
## $items
##          a      b     g u
## ch1  1.431  1.116 0.234 1
## ch2  1.400 -0.209 0.184 1
## ch3  2.106  1.030 0.218 1
## ch4  0.971  0.111 0.263 1
## ch5  2.102  1.621 0.066 1
## ch6  1.108  1.066 0.139 1
## ch7  2.034  2.026 0.154 1
## ch8  1.540  1.094 0.278 1
## ch9  0.836 -1.281 0.106 1
## ch10 1.546  2.317 0.106 1
## ch11 0.419 -1.751 0.156 1
## ch12 1.490  0.506 0.119 1
## ch13 2.431  0.801 0.150 1
## ch14 1.212  0.552 0.142 1
## ch15 1.952  1.377 0.166 1
## ch16 0.949  2.727 0.149 1
## ch17 2.261  1.465 0.453 1
## ch18 0.571  1.192 0.149 1
## ch19 1.519  0.539 0.224 1
## ch20 1.166  3.371 0.119 1
## ch21 0.644 -1.109 0.117 1
## ch22 1.378  1.262 0.191 1
## ch23 1.464  3.151 0.206 1
## ch24 1.982  1.681 0.082 1
## ch25 0.895  0.409 0.099 1
## ch26 1.106  2.345 0.515 1
## ch27 1.634  0.602 0.180 1
## ch28 2.168  1.546 0.189 1
## ch29 1.350  0.230 0.121 1
## ch30 0.880  2.217 0.101 1
## ch31 1.313  2.140 0.262 1
## ch32 0.644  1.784 0.141 1
## ch33 0.463  0.739 0.112 1
## ch34 1.656  1.595 0.234 1
## ch35 1.603  1.944 0.085 1
## ch36 2.127  1.940 0.336 1
## ch37 1.149  1.988 0.353 1
## ch38 2.434  1.373 0.272 1
## ch39 1.488  1.079 0.083 1
## ch40 0.465  6.686 0.255 1
## ch41 1.196  1.790 0.206 1
## ch42 1.020 -0.896 0.112 1
## ch43 1.527  1.348 0.254 1
## ch44 0.645 -0.781 0.155 1
## ch45 0.489  1.590 0.160 1
## 
## $means
## th_ch 
##     0 
## 
## $cov
##       th_ch
## th_ch     1
## 
## 
## $M
## $items
##          a      b     g u
## ch1  1.312  0.646 0.198 1
## ch2  1.400 -0.209 0.184 1
## ch3  2.086  1.181 0.235 1
## ch4  0.809 -0.228 0.211 1
## ch5  2.102  1.621 0.066 1
## ch6  1.088  1.100 0.102 1
## ch7  2.235  2.018 0.156 1
## ch8  1.859  1.114 0.326 1
## ch9  0.831 -0.857 0.113 1
## ch10 1.334  2.202 0.111 1
## ch11 0.419 -1.751 0.156 1
## ch12 1.463  0.391 0.112 1
## ch13 2.564  0.998 0.144 1
## ch14 1.355  0.721 0.140 1
## ch15 1.708  1.194 0.148 1
## ch16 0.949  2.727 0.149 1
## ch17 2.199  1.296 0.417 1
## ch18 0.692  1.002 0.184 1
## ch19 1.634  0.523 0.255 1
## ch20 1.450  3.403 0.133 1
## ch21 0.644 -1.109 0.117 1
## ch22 1.378  1.262 0.191 1
## ch23 1.108  2.821 0.166 1
## ch24 2.087  1.486 0.088 1
## ch25 0.869  0.504 0.092 1
## ch26 0.494 -0.171 0.200 1
## ch27 1.694  0.348 0.150 1
## ch28 2.168  1.546 0.189 1
## ch29 1.261  0.347 0.075 1
## ch30 0.950  1.751 0.110 1
## ch31 0.907  1.480 0.210 1
## ch32 0.644  1.784 0.141 1
## ch33 0.425  1.734 0.129 1
## ch34 1.582  1.659 0.231 1
## ch35 1.642  1.804 0.095 1
## ch36 1.732  1.784 0.325 1
## ch37 1.274  2.092 0.336 1
## ch38 2.434  1.373 0.272 1
## ch39 1.488  1.079 0.083 1
## ch40 0.506  4.401 0.194 1
## ch41 1.326  1.655 0.177 1
## ch42 1.171 -0.334 0.121 1
## ch43 1.583  1.341 0.235 1
## ch44 0.768 -0.322 0.168 1
## ch45 0.856  2.295 0.259 1
## 
## $means
## th_ch 
## 0.354 
## 
## $cov
##       th_ch
## th_ch 0.829
  describe(ch_m3pl_pars_dif$F$items)
##   vars  n mean   sd median trimmed  mad   min  max range skew kurtosis
## a    1 45 1.35 0.56   1.38    1.34 0.60  0.42 2.43  2.02 0.14    -0.92
## b    2 45 1.25 1.39   1.35    1.23 0.95 -1.75 6.69  8.44 0.86     3.68
## g    3 45 0.19 0.09   0.16    0.17 0.07  0.07 0.52  0.45 1.47     2.37
## u    4 45 1.00 0.00   1.00    1.00 0.00  1.00 1.00  0.00  NaN      NaN
##     se
## a 0.08
## b 0.21
## g 0.01
## u 0.00
  describe(ch_m3pl_pars_dif$M$items)
##   vars  n mean   sd median trimmed  mad   min  max range skew kurtosis
## a    1 45 1.34 0.57   1.33    1.33 0.59  0.42 2.56  2.14 0.24    -0.85
## b    2 45 1.15 1.16   1.26    1.15 0.80 -1.75 4.40  6.15 0.00     0.63
## g    3 45 0.18 0.08   0.16    0.17 0.06  0.07 0.42  0.35 1.03     0.85
## u    4 45 1.00 0.00   1.00    1.00 0.00  1.00 1.00  0.00  NaN      NaN
##     se
## a 0.08
## b 0.17
## g 0.01
## u 0.00
  gf_point(ch_m3pl_pars_dif$F$items[ , 2] ~ ch_m3pl_pars_dif$M$items[ , 2])

  theta_ch5 = fscores(ch_m3pl_dif , method = "EAP", full.scores.SE = TRUE,
                      mean = c(M, M), cov = c(DP**2, DP**2))

  theta_ch5 = fscores(ch_m3pl_dif , method = "WLE")

  enem_2015 <- cbind(enem_2015[, 1:172], theta_ch5 = theta_ch5[ , 1])
  names(enem_2015)                           
  gf_dens(~theta_ch5 , data = enem_2015, color = ~ as.factor(TP_SEXO))

  t.test(~theta_ch5 | TP_SEXO, data = enem_2015)
## theta_ch5 ~ TP_SEXO
## 
##  Welch Two Sample t-test
## 
## data:  theta_ch5 by TP_SEXO
## t = -52.752, df = 103870, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.2227422 -0.2067833
## sample estimates:
## mean in group F mean in group M 
##       0.2367979       0.4515606
  cor(enem_2015$theta_ch5, as.numeric(as.factor(enem_2015$TP_SEXO)), use =  "pair")
## [1] 0.1517769

Exercício 5