Bibliotecas
  library(tidyverse)
  library(sjmisc)
 
  library(TAM)
  library(psych)
  library(readxl)
  library(knitr)
  library(RColorBrewer)
  #library(xlsx)

 source("http://www.labape.com.br/rprimi/R/utils_construct_maps.R")
1. Lê/importa banco
# Abre direto da internet (con é um endereço do arquivo) 
 con<-url("http://www.labape.com.br/rprimi/TRI/2019_slides_exerc/senna_v1_54_ex3.RDS") 
 sennav1 <-  readRDS(con) 

 con<-url("http://www.labape.com.br/rprimi/TRI/2019_slides_exerc/senna_v1_54_ex3_dic.RDS") 
 dic <-  readRDS(con)
2. Examina base e seleciona os itens
names(sennav1)
##  [1] "i03.NV.NV.10"         "i04.A.Cmp.10"         "i05.O.Img.10"        
##  [4] "i06.C.Ord.10"         "i07.N.Vol.00"         "i09.A.Cmp.10"        
##  [7] "i10.O.Img.10"         "i11.C.Ord.10"         "i12.N.Vol.00"        
## [10] "i13.NV.NV.10"         "i14.A.Tru.10"         "i17.N.Anx.00"        
## [13] "i24.O.Aes.10"         "i25.A.Cmp.10"         "i27.N.Dep.00"        
## [16] "i29.A.Cmp.10"         "i30.O.Int.10"         "i32.N.Vol.00"        
## [19] "i33.NV.NV.10"         "i34.A.Tru.10"         "i36.C.Conc.00"       
## [22] "i37.N.Anx.10"         "i39.A.Cmp.10"         "i40.O.Aes.10"        
## [25] "i42.N.Anx.00"         "i44.A.Pol.00"         "i46.C.Conc.00"       
## [28] "i48.NV.NV.10"         "i49.A.Cmp.10"         "i51.C.Ord.00"        
## [31] "i52.NV.NV.10"         "i53.A.Pol.00"         "i54.O.Int.10"        
## [34] "i55.E.Act.10"         "i56.NV.NV.10"         "i60.NV.NV.00"        
## [37] "i63.E.Act.10"         "i66.O.Int.10"         "i67.E.Soc.00"        
## [40] "i70.O.Img.11"         "i71.E.Soc.10"         "i73.E.Soc.00"        
## [43] "i74.NV.NV.10"         "i75.E.Soc.10"         "i76.E.Act.10"        
## [46] "i77.C.SD.11"          "i79.N.Vol.11"         "i82.N.Vol.11"        
## [49] "i83.C.Conc.11"        "i84.E.Soc.11"         "i87.E.Soc.11"        
## [52] "i88.N.Dep.11"         "i89.C.Achv.11"        "i91.C.SD.11"         
## [55] "missR"                "admiss_missR"         "acq_avr"             
## [58] "acq_sd"               "num_items"            "Caderno"             
## [61] "age2"                 "grade"                "atrasado"            
## [64] "atrasado2"            "VL_PROFICIENCIA_LP"   "VL_PROFICIENCIA_MT"  
## [67] "vign_consist"         "vign_consist_count"   "F1.Cons"             
## [70] "F2.Extr"              "F3.EmSt"              "F4.Agre"             
## [73] "F5.Opns"              "F6.NVLoc"             "gender"              
## [76] "rwn_id"               "NM_REGIONAL_ESCOLA"   "grade2"              
## [79] "grade_5"              "grade_9"              "grade_10"            
## [82] "freq"                 "cd_esc_grade"         "rwn_id2"             
## [85] "VL_PROFICIENCIA_LP_r" "VL_PROFICIENCIA_MT_r"
dt <- sennav1[ , c(34, 37, 39, 41, 42, 44, 45, 50, 51)]
 
  dic_e <- dic %>% filter(factor == "E")
  vars_e <- dic_e$coditem
  labels_e <- dic_e$text
  
  dt <- sennav1[ , vars_e]
3. Análise psicométrica classica
   alpha(dt, check.keys = TRUE)
## 
## Reliability analysis   
## Call: alpha(x = dt, check.keys = TRUE)
## 
##   raw_alpha std.alpha G6(smc) average_r S/N    ase mean   sd median_r
##        0.7       0.7     0.7      0.21 2.4 0.0043  3.5 0.65      0.2
## 
##  lower alpha upper     95% confidence boundaries
## 0.69 0.7 0.7 
## 
##  Reliability if an item is dropped:
##               raw_alpha std.alpha G6(smc) average_r S/N alpha se  var.r
## i67.E.Soc.00-      0.69      0.69    0.68      0.22 2.3   0.0044 0.0097
## i73.E.Soc.00-      0.69      0.70    0.69      0.23 2.3   0.0044 0.0083
## i55.E.Act.10       0.64      0.65    0.64      0.19 1.8   0.0051 0.0075
## i63.E.Act.10       0.67      0.67    0.67      0.20 2.0   0.0048 0.0112
## i76.E.Act.10       0.67      0.67    0.67      0.20 2.1   0.0048 0.0111
## i71.E.Soc.10       0.65      0.66    0.65      0.19 1.9   0.0050 0.0094
## i75.E.Soc.10       0.66      0.67    0.67      0.20 2.0   0.0048 0.0101
## i84.E.Soc.11       0.67      0.68    0.67      0.21 2.1   0.0047 0.0103
## i87.E.Soc.11       0.69      0.70    0.69      0.22 2.3   0.0044 0.0108
##               med.r
## i67.E.Soc.00-  0.24
## i73.E.Soc.00-  0.24
## i55.E.Act.10   0.20
## i63.E.Act.10   0.20
## i76.E.Act.10   0.19
## i71.E.Soc.10   0.19
## i75.E.Soc.10   0.20
## i84.E.Soc.11   0.19
## i87.E.Soc.11   0.24
## 
##  Item statistics 
##                   n raw.r std.r r.cor r.drop mean  sd
## i67.E.Soc.00- 10664  0.50  0.47  0.36   0.29  3.2 1.3
## i73.E.Soc.00- 10658  0.46  0.44  0.32   0.26  3.6 1.2
## i55.E.Act.10  10591  0.66  0.67  0.63   0.52  4.0 1.1
## i63.E.Act.10  10714  0.56  0.57  0.48   0.40  3.7 1.1
## i76.E.Act.10  10686  0.58  0.56  0.47   0.39  3.1 1.3
## i71.E.Soc.10  10683  0.62  0.63  0.58   0.47  3.8 1.1
## i75.E.Soc.10  10763  0.57  0.57  0.49   0.40  3.7 1.1
## i84.E.Soc.11  10709  0.52  0.54  0.45   0.37  3.8 1.0
## i87.E.Soc.11  10732  0.46  0.45  0.32   0.26  2.6 1.2
## 
## Non missing response frequency for each item
##                 1    2    3    4    5 miss
## i67.E.Soc.00 0.19 0.26 0.25 0.16 0.14 0.05
## i73.E.Soc.00 0.30 0.27 0.24 0.11 0.08 0.05
## i55.E.Act.10 0.03 0.08 0.19 0.30 0.40 0.06
## i63.E.Act.10 0.04 0.12 0.24 0.30 0.31 0.05
## i76.E.Act.10 0.14 0.20 0.28 0.23 0.16 0.05
## i71.E.Soc.10 0.03 0.11 0.19 0.33 0.34 0.05
## i75.E.Soc.10 0.05 0.12 0.20 0.34 0.29 0.04
## i84.E.Soc.11 0.03 0.10 0.21 0.41 0.26 0.05
## i87.E.Soc.11 0.21 0.29 0.28 0.16 0.07 0.05
4. Inverte itens negativos e transforma de 1-5 para 0-4
 names(dt)
## [1] "i67.E.Soc.00" "i73.E.Soc.00" "i55.E.Act.10" "i63.E.Act.10"
## [5] "i76.E.Act.10" "i71.E.Soc.10" "i75.E.Soc.10" "i84.E.Soc.11"
## [9] "i87.E.Soc.11"
  dt$i67.E.Soc.00 <- 6 - dt$i67.E.Soc.00
  dt$i73.E.Soc.00 <- 6 - dt$i73.E.Soc.00
  
  dt <- map_df(dt, ~.-1)
5. Calibra modelo de créditos parciais
  tri_e  <- tam.mml(resp = dt, irtmodel = "PCM")
## ....................................................
## Processing Data      2019-10-29 22:26:11 
##     * Response Data: 11249 Persons and  9 Items 
##     * Numerical integration with 21 nodes
##     * Created Design Matrices   ( 2019-10-29 22:26:11 )
##     * Calculated Sufficient Statistics   ( 2019-10-29 22:26:11 )
## ....................................................
## Iteration 1     2019-10-29 22:26:11
## E Step
## M Step Intercepts   |----
##   Deviance = 288147.189
##   Maximum item intercept parameter change: 0.792313
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.148833
## ....................................................
## Iteration 2     2019-10-29 22:26:11
## E Step
## M Step Intercepts   |----
##   Deviance = 278114.5414 | Absolute change: 10032.65 | Relative change: 0.0360738
##   Maximum item intercept parameter change: 0.691731
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.264888
## ....................................................
## Iteration 3     2019-10-29 22:26:11
## E Step
## M Step Intercepts   |----
##   Deviance = 274784.8535 | Absolute change: 3329.688 | Relative change: 0.01211744
##   Maximum item intercept parameter change: 0.455792
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.144836
## ....................................................
## Iteration 4     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 273731.664 | Absolute change: 1053.189 | Relative change: 0.00384753
##   Maximum item intercept parameter change: 0.120218
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.073083
## ....................................................
## Iteration 5     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 273318.4954 | Absolute change: 413.1686 | Relative change: 0.00151167
##   Maximum item intercept parameter change: 0.067482
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.040658
## ....................................................
## Iteration 6     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 273126.1855 | Absolute change: 192.3099 | Relative change: 0.00070411
##   Maximum item intercept parameter change: 0.048367
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.024802
## ....................................................
## Iteration 7     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 273030.5008 | Absolute change: 95.6847 | Relative change: 0.00035045
##   Maximum item intercept parameter change: 0.027411
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.015654
## ....................................................
## Iteration 8     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272978.555 | Absolute change: 51.9458 | Relative change: 0.00019029
##   Maximum item intercept parameter change: 0.021065
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.010643
## ....................................................
## Iteration 9     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272949.6206 | Absolute change: 28.9344 | Relative change: 0.00010601
##   Maximum item intercept parameter change: 0.016621
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.007406
## ....................................................
## Iteration 10     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272932.8589 | Absolute change: 16.7618 | Relative change: 6.141e-05
##   Maximum item intercept parameter change: 0.012857
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.005361
## ....................................................
## Iteration 11     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272923.0411 | Absolute change: 9.8178 | Relative change: 3.597e-05
##   Maximum item intercept parameter change: 0.009803
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.003929
## ....................................................
## Iteration 12     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272917.2518 | Absolute change: 5.7893 | Relative change: 2.121e-05
##   Maximum item intercept parameter change: 0.007517
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.002939
## ....................................................
## Iteration 13     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272913.8353 | Absolute change: 3.4165 | Relative change: 1.252e-05
##   Maximum item intercept parameter change: 0.005706
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.002223
## ....................................................
## Iteration 14     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272911.8278 | Absolute change: 2.0075 | Relative change: 7.36e-06
##   Maximum item intercept parameter change: 0.004342
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.001684
## ....................................................
## Iteration 15     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272910.6518 | Absolute change: 1.176 | Relative change: 4.31e-06
##   Maximum item intercept parameter change: 0.003315
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.001287
## ....................................................
## Iteration 16     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.9638 | Absolute change: 0.688 | Relative change: 2.52e-06
##   Maximum item intercept parameter change: 0.002533
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.000982
## ....................................................
## Iteration 17     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.561 | Absolute change: 0.4028 | Relative change: 1.48e-06
##   Maximum item intercept parameter change: 0.001934
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.000754
## ....................................................
## Iteration 18     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.326 | Absolute change: 0.235 | Relative change: 8.6e-07
##   Maximum item intercept parameter change: 0.001478
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.000576
## ....................................................
## Iteration 19     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.1887 | Absolute change: 0.1373 | Relative change: 5e-07
##   Maximum item intercept parameter change: 0.001128
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.000442
## ....................................................
## Iteration 20     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.1086 | Absolute change: 0.0801 | Relative change: 2.9e-07
##   Maximum item intercept parameter change: 0.000862
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.000338
## ....................................................
## Iteration 21     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.0618 | Absolute change: 0.0468 | Relative change: 1.7e-07
##   Maximum item intercept parameter change: 0.000658
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.000259
## ....................................................
## Iteration 22     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.0346 | Absolute change: 0.0272 | Relative change: 1e-07
##   Maximum item intercept parameter change: 0.000503
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.000198
## ....................................................
## Iteration 23     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.0187 | Absolute change: 0.0159 | Relative change: 6e-08
##   Maximum item intercept parameter change: 0.000383
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.000152
## ....................................................
## Iteration 24     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.0094 | Absolute change: 0.0092 | Relative change: 3e-08
##   Maximum item intercept parameter change: 0.000293
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 0.000116
## ....................................................
## Iteration 25     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.004 | Absolute change: 0.0054 | Relative change: 2e-08
##   Maximum item intercept parameter change: 0.000223
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 8.9e-05
## ....................................................
## Iteration 26     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272909.0009 | Absolute change: 0.0031 | Relative change: 1e-08
##   Maximum item intercept parameter change: 0.000171
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 6.8e-05
## ....................................................
## Iteration 27     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272908.9991 | Absolute change: 0.0018 | Relative change: 1e-08
##   Maximum item intercept parameter change: 0.00013
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 5.2e-05
## ....................................................
## Iteration 28     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272908.998 | Absolute change: 0.0011 | Relative change: 0
##   Maximum item intercept parameter change: 9.9e-05
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 4e-05
## ....................................................
## Iteration 29     2019-10-29 22:26:12
## E Step
## M Step Intercepts   |----
##   Deviance = 272908.9974 | Absolute change: 6e-04 | Relative change: 0
##   Maximum item intercept parameter change: 7.6e-05
##   Maximum item slope parameter change: 0
##   Maximum regression parameter change: 0
##   Maximum variance parameter change: 3e-05
## ....................................................
## Item Parameters
##    xsi.index         xsi.label     est
## 1          1 i67.E.Soc.00_Cat1 -0.5005
## 2          2 i67.E.Soc.00_Cat2 -0.5667
## 3          3 i67.E.Soc.00_Cat3  0.0477
## 4          4 i67.E.Soc.00_Cat4  0.5423
## 5          5 i73.E.Soc.00_Cat1 -0.7215
## 6          6 i73.E.Soc.00_Cat2 -1.0372
## 7          7 i73.E.Soc.00_Cat3 -0.1123
## 8          8 i73.E.Soc.00_Cat4  0.0366
## 9          9 i55.E.Act.10_Cat1 -1.5272
## 10        10 i55.E.Act.10_Cat2 -1.0890
## 11        11 i55.E.Act.10_Cat3 -0.5477
## 12        12 i55.E.Act.10_Cat4 -0.1983
## 13        13 i63.E.Act.10_Cat1 -1.4770
## 14        14 i63.E.Act.10_Cat2 -0.9577
## 15        15 i63.E.Act.10_Cat3 -0.2868
## 16        16 i63.E.Act.10_Cat4  0.1424
## 17        17 i76.E.Act.10_Cat1 -0.6444
## 18        18 i76.E.Act.10_Cat2 -0.4508
## 19        19 i76.E.Act.10_Cat3  0.2612
## 20        20 i76.E.Act.10_Cat4  0.6711
## 21        21 i71.E.Soc.10_Cat1 -1.6387
## 22        22 i71.E.Soc.10_Cat2 -0.8036
## 23        23 i71.E.Soc.10_Cat3 -0.5952
## 24        24 i71.E.Soc.10_Cat4  0.0993
## 25        25 i75.E.Soc.10_Cat1 -1.2643
## 26        26 i75.E.Soc.10_Cat2 -0.7856
## 27        27 i75.E.Soc.10_Cat3 -0.5702
## 28        28 i75.E.Soc.10_Cat4  0.3148
## 29        29 i84.E.Soc.11_Cat1 -1.6196
## 30        30 i84.E.Soc.11_Cat2 -1.0294
## 31        31 i84.E.Soc.11_Cat3 -0.7284
## 32        32 i84.E.Soc.11_Cat4  0.6084
## 33        33 i87.E.Soc.11_Cat1 -0.5033
## 34        34 i87.E.Soc.11_Cat2  0.0121
## 35        35 i87.E.Soc.11_Cat3  0.7613
## 36        36 i87.E.Soc.11_Cat4  1.2079
## ...................................
## Regression Coefficients
##      [,1]
## [1,]    0
## 
## Variance:
##        [,1]
## [1,] 0.2477
## 
## 
## EAP Reliability:
## [1] 0.678
## 
## -----------------------------
## Start:  2019-10-29 22:26:11
## End:  2019-10-29 22:26:12 
## Time difference of 0.6891789 secs
6. Examina ajuste dos itens
  fit <- tam.fit(tri_e)
## Item fit calculation based on 5 simulations
## |**********|
## |----------|
  summary(fit)
## ------------------------------------------------------------
## TAM 3.1-45 (2019-03-18 16:53:26) 
## R version 3.5.1 (2018-07-02) x86_64, darwin15.6.0 | nodename=MacBookPro2018 | login=rprimi 
## 
## Date of Analysis: 2019-10-29 22:26:13 
## Time difference of 0.543447 secs
## Computation time: 0.543447 
## 
## Item fit statitics (Function 'tam.fit')
## Call:
## tam.fit(tamobj = tri_e)
## 
##            parameter Outfit Outfit_t Outfit_p Infit Infit_t Infit_p
## 1  i67.E.Soc.00_Cat1  1.396   18.645    0.000 1.054   2.836   0.005
## 2  i67.E.Soc.00_Cat2  1.103    9.516    0.000 1.064   6.010   0.000
## 3  i67.E.Soc.00_Cat3  1.141   17.240    0.000 1.080   9.935   0.000
## 4  i67.E.Soc.00_Cat4  1.240   15.106    0.000 0.996  -0.241   0.809
## 5  i73.E.Soc.00_Cat1  1.875   25.055    0.000 1.062   2.176   0.030
## 6  i73.E.Soc.00_Cat2  1.227   13.837    0.000 1.073   4.645   0.000
## 7  i73.E.Soc.00_Cat3  1.124   15.098    0.000 1.092  11.303   0.000
## 8  i73.E.Soc.00_Cat4  1.156   15.450    0.000 1.032   3.275   0.001
## 9  i55.E.Act.10_Cat1  1.060    1.161    0.246 0.956  -0.874   0.382
## 10 i55.E.Act.10_Cat2  0.795  -10.124    0.000 0.924  -3.565   0.000
## 11 i55.E.Act.10_Cat3  0.844  -16.059    0.000 0.908  -9.276   0.000
## 12 i55.E.Act.10_Cat4  0.907  -13.425    0.000 0.923 -11.113   0.000
## 13 i63.E.Act.10_Cat1  0.990   -0.252    0.801 0.982  -0.416   0.677
## 14 i63.E.Act.10_Cat2  1.011    0.644    0.520 0.989  -0.643   0.520
## 15 i63.E.Act.10_Cat3  0.971   -3.612    0.000 0.981  -2.377   0.017
## 16 i63.E.Act.10_Cat4  0.983   -1.805    0.071 0.978  -2.355   0.019
## 17 i76.E.Act.10_Cat1  1.215   10.773    0.000 1.023   1.203   0.229
## 18 i76.E.Act.10_Cat2  1.016    1.708    0.088 1.007   0.702   0.483
## 19 i76.E.Act.10_Cat3  0.975   -2.995    0.003 0.972  -3.329   0.001
## 20 i76.E.Act.10_Cat4  1.063    3.539    0.000 0.974  -1.499   0.134
## 21 i71.E.Soc.10_Cat1  1.164    3.224    0.001 0.968  -0.674   0.500
## 22 i71.E.Soc.10_Cat2  0.908   -5.191    0.000 0.958  -2.312   0.021
## 23 i71.E.Soc.10_Cat3  0.895  -11.666    0.000 0.932  -7.511   0.000
## 24 i71.E.Soc.10_Cat4  0.922   -9.519    0.000 0.941  -7.144   0.000
## 25 i75.E.Soc.10_Cat1  1.326    7.966    0.000 1.010   0.281   0.778
## 26 i75.E.Soc.10_Cat2  0.993   -0.440    0.660 0.996  -0.234   0.815
## 27 i75.E.Soc.10_Cat3  0.950   -5.914    0.000 0.968  -3.743   0.000
## 28 i75.E.Soc.10_Cat4  0.983   -1.740    0.082 0.977  -2.329   0.020
## 29 i84.E.Soc.11_Cat1  2.097   14.956    0.000 1.003   0.067   0.946
## 30 i84.E.Soc.11_Cat2  1.035    1.659    0.097 0.999  -0.032   0.974
## 31 i84.E.Soc.11_Cat3  0.961   -4.421    0.000 0.980  -2.257   0.024
## 32 i84.E.Soc.11_Cat4  1.012    1.065    0.287 0.978  -1.996   0.046
## 33 i87.E.Soc.11_Cat1  1.238   16.728    0.000 1.073   5.376   0.000
## 34 i87.E.Soc.11_Cat2  1.092   12.507    0.000 1.072   9.794   0.000
## 35 i87.E.Soc.11_Cat3  1.106    7.736    0.000 1.016   1.195   0.232
## 36 i87.E.Soc.11_Cat4  1.677   18.421    0.000 1.006   0.198   0.843
 plot(tri_e, ngroups = 24)
## Iteration in WLE/MLE estimation  1   | Maximal change  1.8773 
## Iteration in WLE/MLE estimation  2   | Maximal change  1.2791 
## Iteration in WLE/MLE estimation  3   | Maximal change  0.6499 
## Iteration in WLE/MLE estimation  4   | Maximal change  0.3254 
## Iteration in WLE/MLE estimation  5   | Maximal change  0.1171 
## Iteration in WLE/MLE estimation  6   | Maximal change  0.0478 
## Iteration in WLE/MLE estimation  7   | Maximal change  0.0184 
## Iteration in WLE/MLE estimation  8   | Maximal change  0.0072 
## Iteration in WLE/MLE estimation  9   | Maximal change  0.0028 
## Iteration in WLE/MLE estimation  10   | Maximal change  0.0011 
## Iteration in WLE/MLE estimation  11   | Maximal change  4e-04 
## Iteration in WLE/MLE estimation  12   | Maximal change  2e-04 
## Iteration in WLE/MLE estimation  13   | Maximal change  1e-04 
## ----
##  WLE Reliability= 0.658

## ....................................................
##  Plots exported in png format into folder:
##  /Users/rprimi/Dropbox (Personal)/TRI/2019_slides_exerc/Plots
7. Examina curva dos itens
summary(tri_e)
## ------------------------------------------------------------
## TAM 3.1-45 (2019-03-18 16:53:26) 
## R version 3.5.1 (2018-07-02) x86_64, darwin15.6.0 | nodename=MacBookPro2018 | login=rprimi 
## 
## Date of Analysis: 2019-10-29 22:26:12 
## Time difference of 0.6891789 secs
## Computation time: 0.6891789 
## 
## Multidimensional Item Response Model in TAM 
## 
## IRT Model: PCM
## Call:
## tam.mml(resp = dt, irtmodel = "PCM")
## 
## ------------------------------------------------------------
## Number of iterations = 29 
## Numeric integration with 21 integration points
## 
## Deviance = 272909 
## Log likelihood = -136454.5 
## Number of persons = 11249 
## Number of persons used = 11082 
## Number of items = 9 
## Number of estimated parameters = 37 
##     Item threshold parameters = 36 
##     Item slope parameters = 0 
##     Regression parameters = 0 
##     Variance/covariance parameters = 1 
## 
## AIC = 272983  | penalty = 74    | AIC=-2*LL + 2*p 
## AIC3 = 273020  | penalty = 111    | AIC3=-2*LL + 3*p 
## BIC = 273254  | penalty = 344.58    | BIC=-2*LL + log(n)*p 
## aBIC = 273136  | penalty = 226.99    | aBIC=-2*LL + log((n-2)/24)*p  (adjusted BIC) 
## CAIC = 273291  | penalty = 381.58    | CAIC=-2*LL + [log(n)+1]*p  (consistent AIC) 
## AICc = 272983  | penalty = 74.25    | AICc=-2*LL + 2*p + 2*p*(p+1)/(n-p-1)  (bias corrected AIC) 
## 
## ------------------------------------------------------------
## EAP Reliability
## [1] 0.678
## ------------------------------------------------------------
## Covariances and Variances
##       [,1]
## [1,] 0.248
## ------------------------------------------------------------
## Correlations and Standard Deviations (in the diagonal)
##       [,1]
## [1,] 0.498
## ------------------------------------------------------------
## Regression Coefficients
##      [,1]
## [1,]    0
## ------------------------------------------------------------
## Item Parameters -A*Xsi
##                      item     N     M xsi.item AXsi_.Cat1 AXsi_.Cat2
## i67.E.Soc.00 i67.E.Soc.00 10664 2.200   -0.119     -0.501     -1.067
## i73.E.Soc.00 i73.E.Soc.00 10658 2.616   -0.459     -0.722     -1.759
## i55.E.Act.10 i55.E.Act.10 10591 2.957   -0.841     -1.527     -2.616
## i63.E.Act.10 i63.E.Act.10 10714 2.718   -0.645     -1.477     -2.435
## i76.E.Act.10 i76.E.Act.10 10686 2.070   -0.041     -0.644     -1.095
## i71.E.Soc.10 i71.E.Soc.10 10683 2.825   -0.735     -1.639     -2.442
## i75.E.Soc.10 i75.E.Soc.10 10763 2.707   -0.576     -1.264     -2.050
## i84.E.Soc.11 i84.E.Soc.11 10709 2.770   -0.692     -1.620     -2.649
## i87.E.Soc.11 i87.E.Soc.11 10732 1.580    0.369     -0.503     -0.491
##              AXsi_.Cat3 AXsi_.Cat4 B.Cat1.Dim1 B.Cat2.Dim1 B.Cat3.Dim1
## i67.E.Soc.00     -1.020     -0.477           1           2           3
## i73.E.Soc.00     -1.871     -1.834           1           2           3
## i55.E.Act.10     -3.164     -3.362           1           2           3
## i63.E.Act.10     -2.722     -2.579           1           2           3
## i76.E.Act.10     -0.834     -0.163           1           2           3
## i71.E.Soc.10     -3.038     -2.938           1           2           3
## i75.E.Soc.10     -2.620     -2.305           1           2           3
## i84.E.Soc.11     -3.378     -2.769           1           2           3
## i87.E.Soc.11      0.270      1.478           1           2           3
##              B.Cat4.Dim1
## i67.E.Soc.00           4
## i73.E.Soc.00           4
## i55.E.Act.10           4
## i63.E.Act.10           4
## i76.E.Act.10           4
## i71.E.Soc.10           4
## i75.E.Soc.10           4
## i84.E.Soc.11           4
## i87.E.Soc.11           4
## 
## Item Parameters Xsi
##                      xsi se.xsi
## i67.E.Soc.00_Cat1 -0.500  0.030
## i67.E.Soc.00_Cat2 -0.567  0.023
## i67.E.Soc.00_Cat3  0.048  0.021
## i67.E.Soc.00_Cat4  0.542  0.026
## i73.E.Soc.00_Cat1 -0.721  0.038
## i73.E.Soc.00_Cat2 -1.037  0.027
## i73.E.Soc.00_Cat3 -0.112  0.021
## i73.E.Soc.00_Cat4  0.037  0.023
## i55.E.Act.10_Cat1 -1.527  0.060
## i55.E.Act.10_Cat2 -1.089  0.033
## i55.E.Act.10_Cat3 -0.548  0.023
## i55.E.Act.10_Cat4 -0.198  0.021
## i63.E.Act.10_Cat1 -1.477  0.051
## i63.E.Act.10_Cat2 -0.958  0.028
## i63.E.Act.10_Cat3 -0.287  0.021
## i63.E.Act.10_Cat4  0.142  0.022
## i76.E.Act.10_Cat1 -0.644  0.030
## i76.E.Act.10_Cat2 -0.451  0.022
## i76.E.Act.10_Cat3  0.261  0.022
## i76.E.Act.10_Cat4  0.671  0.028
## i71.E.Soc.10_Cat1 -1.639  0.056
## i71.E.Soc.10_Cat2 -0.804  0.029
## i71.E.Soc.10_Cat3 -0.595  0.022
## i71.E.Soc.10_Cat4  0.099  0.022
## i75.E.Soc.10_Cat1 -1.264  0.046
## i75.E.Soc.10_Cat2 -0.786  0.028
## i75.E.Soc.10_Cat3 -0.570  0.022
## i75.E.Soc.10_Cat4  0.315  0.023
## i84.E.Soc.11_Cat1 -1.620  0.059
## i84.E.Soc.11_Cat2 -1.029  0.031
## i84.E.Soc.11_Cat3 -0.728  0.022
## i84.E.Soc.11_Cat4  0.608  0.023
## i87.E.Soc.11_Cat1 -0.503  0.025
## i87.E.Soc.11_Cat2  0.012  0.021
## i87.E.Soc.11_Cat3  0.761  0.025
## i87.E.Soc.11_Cat4  1.208  0.040
## 
## Item Parameters in IRT parameterization
##           item alpha   beta tau.Cat1 tau.Cat2 tau.Cat3 tau.Cat4
## 1 i67.E.Soc.00     1 -0.119   -0.381   -0.447    0.167    0.662
## 2 i73.E.Soc.00     1 -0.459   -0.263   -0.579    0.346    0.495
## 3 i55.E.Act.10     1 -0.841   -0.687   -0.248    0.293    0.642
## 4 i63.E.Act.10     1 -0.645   -0.832   -0.313    0.358    0.787
## 5 i76.E.Act.10     1 -0.041   -0.604   -0.410    0.302    0.712
## 6 i71.E.Soc.10     1 -0.735   -0.904   -0.069    0.139    0.834
## 7 i75.E.Soc.10     1 -0.576   -0.688   -0.209    0.006    0.891
## 8 i84.E.Soc.11     1 -0.692   -0.927   -0.337   -0.036    1.301
## 9 i87.E.Soc.11     1  0.369   -0.873   -0.357    0.392    0.838
  plot(tri_e, type = "items")
## Iteration in WLE/MLE estimation  1   | Maximal change  1.8773 
## Iteration in WLE/MLE estimation  2   | Maximal change  1.2791 
## Iteration in WLE/MLE estimation  3   | Maximal change  0.6499 
## Iteration in WLE/MLE estimation  4   | Maximal change  0.3254 
## Iteration in WLE/MLE estimation  5   | Maximal change  0.1171 
## Iteration in WLE/MLE estimation  6   | Maximal change  0.0478 
## Iteration in WLE/MLE estimation  7   | Maximal change  0.0184 
## Iteration in WLE/MLE estimation  8   | Maximal change  0.0072 
## Iteration in WLE/MLE estimation  9   | Maximal change  0.0028 
## Iteration in WLE/MLE estimation  10   | Maximal change  0.0011 
## Iteration in WLE/MLE estimation  11   | Maximal change  4e-04 
## Iteration in WLE/MLE estimation  12   | Maximal change  2e-04 
## Iteration in WLE/MLE estimation  13   | Maximal change  1e-04 
## ----
##  WLE Reliability= 0.658

## ....................................................
##  Plots exported in png format into folder:
##  /Users/rprimi/Dropbox (Personal)/TRI/2019_slides_exerc/Plots
7. Mapa de construto: tentativa 3
person_item_map_v2( 
  item_tresh =  tam.threshold(tri_e),
  coditem = names(dt),
  item_text = dic_e$text,
  pole = c(1,1,0, 1, 0, 1, 1,1,1),
  theta = tri_e$person$EAP
  )

describe_likert5_items(
  data = dt,
  item_tresh =  tam.threshold(tri_e),
  coditem = names(dt),
  item_text = names(dt),
  pole = c(1,1,0, 1, 0, 1, 1,1,1)
)

##### 8. Mapa de construto: tentativa 4

person_item_map_v3( size_bar = 4,
  size_categ_label = 3,
  item_text_max = 32,
  item_tresh =  tam.threshold(tri_e),
  coditem = dic_e$coditem,
  item_text = dic_e$text,
  pole = dic_e$pole,
  theta = tri_e$person$EAP
    )