1 Preparation of R and data

1.1 Load data and NEPSroutines

load("ex1.rda")
resp <- ex1$resp
vars <- ex1$vars

library("NEPSroutines")

1.2 User-defined missing values

table(unlist(resp[resp < 0]))
## 
##  -97  -95  -94  -56 
##  780  254 3826  300
mvs = c(
  OM = -97,
  NV = -95,
  NR = -94,
  NP = -56
)

labels_mvs = c(
  ALL = "total missing items",
  OM = "omitted items",
  NV = "not valid items",
  NR = "not reached items",
  NP = "not participated"
)

1.3 Attributes for socio-demographic variables

# Sex
attributes(resp$sex)$labels <- c(
  female = 0,
  male = 1
)

# Migration
attributes(resp$mig)$labels <- c(
  no_migration_background = 0,
  migration_background = 1
)

# Books
attributes(resp$books)$labels <- c(
  less_than_100 = 0,
  more_than_100 = 1
)

2 Sample and Booklet Descriptives

# Sample size with only valid cases
NEPSroutines::n_valid(resp, valid = "valid")
## There are 1000 valid cases and 10 invalid cases in the dataset.
# Descriptives (mean, sd, etc.) of continuous variables
NEPSroutines::desc_con(resp, desc = "age", valid = "valid")
## 
## Summary statistics of the continuous variables:
##        n  mean    sd median   min   max
## age 1000 4.027 0.883  4.085 2.085 5.836
# Descriptives (attributes, frequency) of nominal socio-demographic variables
NEPSroutines::show_attributes(resp, desc = c("sex", "mig", "books"))
## 
## The attributes for variable sex are:
## female   male 
##      0      1
## 
## The attributes for variable mig are:
## no_migration_background    migration_background 
##                       0                       1
## 
## The attributes for variable books are:
## less_than_100 more_than_100 
##             0             1
NEPSroutines::desc_nom(resp, desc = c("sex", "mig", "books"), valid = "valid")
## 
## Sample size by groups:
##      sex mig books
## 0    493 648   532
## 1    507 162   468
## <NA>   0 190     0
## 
## Frequency of groups including missing values:
##      sex     mig     books  
## [1,] "49.3%" "64.8%" "53.2%"
## [2,] "50.7%" "16.2%" "46.8%"
## [3,] "0%"    "19%"   "0%"
## 
## Frequency of groups excluding missing values:
##      sex     mig   books  
## [1,] "49.3%" "80%" "53.2%"
## [2,] "50.7%" "20%" "46.8%"

3 Missing Responses Analyses

3.1 Missing Responses by Person

NEPSroutines::mv_person(
  resp = resp,
  vars = vars,
  select = "dich",
  valid = "valid",
  mvs = mvs,
  labels_mvs = labels_mvs,
  missing_by_design = -56,
  overwrite = TRUE,
  plots = TRUE,
  save = TRUE,
  print = TRUE,
  return = FALSE,
  path_results = "results",
  path_table = "tables",
  path_plots = "plots/missings_by_person",
  digits = 2,
  warn = TRUE,
  verbose = FALSE
)
## 
## Table with results:
##          OM   NV    NR   ALL
## mean   0.39 0.13  1.91  2.43
## sd     0.62 0.35  2.42  2.48
## median 0.00 0.00  1.00  2.00
## min    0.00 0.00  0.00  0.00
## max    3.00 3.00 13.00 14.00
## 

3.2 Missing Responses by Item

NEPSroutines::mv_item(
  resp = resp,
  vars = vars,
  select = "dich",
  valid = "valid",
  position = "pos",
  mvs = mvs,
  labels_mvs = labels_mvs,
  missing_by_design = -56,
  overwrite = TRUE,
  plots = TRUE,
  save = TRUE,
  print = TRUE,
  return = FALSE,
  path_results = "results",
  path_table = "tables",
  path_plots = "plots/missings_by_item",
  digits = 2,
  warn = TRUE,
  verbose = FALSE
)
## 
## Table 1 shows missing values by item position and missing type.
## All other tables show summary statistics over all items.
## $list
##          item position N_administered N_valid  OM  NV   NR  ALL
## 1  grk10010_c        1           1000     965 2.9 0.6  0.0  3.5
## 2  grk10020_c        2           1000     961 3.0 0.9  0.0  3.9
## 3  grk10030_c        3           1000     964 2.3 0.6  0.7  3.6
## 4  grk10040_c        4           1000     943 4.0 0.9  0.8  5.7
## 5  grk10050_c        5           1000     947 3.1 0.7  1.5  5.3
## 6  grk10060_c        6           1000     939 3.5 0.8  1.8  6.1
## 7  grk10070_c        7           1000     926 3.9 0.9  2.6  7.4
## 8  grk10080_c        8           1000     930 2.0 1.2  3.8  7.0
## 9  grk10090_c        9           1000     895 3.0 1.8  5.7 10.5
## 10 grk10100_c       10           1000     879 2.7 1.2  8.2 12.1
## 11 grk10110_c       11           1000     849 1.9 0.6 12.6 15.1
## 12 grk10120_c       12           1000     773 2.2 0.6 19.9 22.7
## 13 grk10130_c       13           1000     692 2.1 0.4 28.3 30.8
## 14 grk10140_c       14           1000     555 1.5 0.9 42.1 44.5
## 15 grk10150_c       15           1000     352 0.9 0.6 63.3 64.8
## 
## $summary
##                   Mean     SD Median    Min    Max
## N_administered 1000.00   0.00 1000.0 1000.0 1000.0
## N_valid         838.00 177.95  926.0  352.0  965.0
## OM                2.60   0.87    2.7    0.9    4.0
## NV                0.85   0.35    0.8    0.4    1.8
## NR               12.75  18.56    3.8    0.0   63.3
## ALL              16.20  17.79    7.4    3.5   64.8
## 
## Summary for TR
## The proportion of omitted items varied between 0.9% (item grk10150_c) and 4% (item grk10040_c).
## The proportion of not valid items varied between 0.4% (item grk10130_c) and 1.8% (item grk10090_c).
## The proportion of not reached items varied between 0% (items grk10010_c, grk10020_c) and 63.3% (item grk10150_c).
## The proportion of total missing items varied between 3.5% (item grk10010_c) and 64.8% (item grk10150_c).
## 

4 IRT Analyses

NEPSroutines::irt_analysis(
  resp = resp,
  vars = vars,
  select = "dich",
  valid = "valid",
  scoring = "scoring",
  mvs = mvs,
  plots = TRUE,
  save = TRUE,
  print = TRUE,
  return = FALSE,
  path_results = "results",
  path_table = "tables",
  path_plots = "plots",
  overwrite = TRUE,
  digits = 2,
  verbose = FALSE
)
## 
## IRT summary table
##          Item N_administered N_valid correct   xsi   SE WMNSQ     t  rit  aQ3
## 1  grk10010_c           1000     965   18.13  1.84 0.09  1.02  0.32 0.23 0.03
## 2  grk10020_c           1000     961   11.55  2.45 0.11  1.04  0.52 0.16 0.04
## 3  grk10030_c           1000     964   89.32 -2.55 0.11  1.01  0.17 0.19 0.04
## 4  grk10040_c           1000     943    4.98  3.45 0.15  1.04  0.33 0.11 0.03
## 5  grk10050_c           1000     947    7.92  2.91 0.13  1.02  0.21 0.17 0.03
## 6  grk10060_c           1000     939   55.06 -0.25 0.07  0.97 -1.21 0.36 0.02
## 7  grk10070_c           1000     926   47.19  0.14 0.07  0.98 -0.72 0.37 0.04
## 8  grk10080_c           1000     930   20.43  1.67 0.09  1.00  0.09 0.30 0.03
## 9  grk10090_c           1000     895   64.47 -0.75 0.08  0.97 -0.92 0.35 0.02
## 10 grk10100_c           1000     879   60.07 -0.52 0.08  1.00 -0.12 0.34 0.03
## 11 grk10110_c           1000     849   26.62  1.24 0.09  0.99 -0.23 0.32 0.03
## 12 grk10120_c           1000     773   16.69  1.94 0.10  0.97 -0.43 0.33 0.04
## 13 grk10130_c           1000     692   45.38  0.21 0.09  1.02  0.59 0.33 0.03
## 14 grk10140_c           1000     555   31.53  0.93 0.10  1.05  1.07 0.29 0.04
## 15 grk10150_c           1000     352   75.85 -1.38 0.14  0.99 -0.19 0.35 0.04
##    Discr.
## 1    0.95
## 2    0.82
## 3    1.04
## 4    0.73
## 5    0.99
## 6    1.33
## 7    1.21
## 8    1.07
## 9    1.31
## 10   1.12
## 11   1.19
## 12   1.27
## 13   1.01
## 14   0.87
## 15   1.21
## 
## Model fit table
##              N Npars Deviance   AIC   BIC EAPrel WLErel
## 1PL model 1000    16    11932 11964 12043  0.662  0.595
## 2PL model 1000    30    11913 11973 12120  0.668  0.584
## 
## SUMMARY FOR TR
## Percentage correct:
## The percentage of correct responses within dichotomous items varied between 4.98% (item grk10040_c) and 89.32% (item grk10030_c) with an average of 38.35% (SD = 26.33%), and a median of 31.53% correct responses.
## Item difficulties:
## The estimated item difficulties (or location parameters for polytomous variables) varied between -2.55 (item grk10030_c) and 3.45 (item grk10040_c) with an average of 0.76 (SD = 1.68), and a median of 0.93.
## SE of item difficulties:
## The maximum of SEs is 0.15 (item grk10040_c).
## WMNSQ:
## The WMNSQ value varied between 0.97 (items grk10060_c, grk10090_c, grk10120_c) and 1.05 (item grk10140_c) with an average of 1 (SD = 0.03), and a median of 1.
## No item exhibited a WMNSQ of at least 1.15.
## 
## WMNSQ t-value:
## The WMNSQ t-values varied between -1.21 (item grk10060_c) and 1.07 (item grk10140_c) with an average of -0.03 (SD = 0.61), and a median of 0.09.
## No item exhibited a t-value of at least 8.
## 
## Correlation of item scores with total correct score:
## The correlations between the item scores and the total correct scores varied between 0.11 (item grk10040_c) and 0.37 (item grk10070_c) with an average correlation of 0.28 (SD = 0.08), and a median correlation of 0.32.
## Model variance:
## The variance of the model was estimated to be 1.208.
## Test reliability:
## EAP/PV reliability = 0.662
## WLE reliability = 0.595
## Item discrimination:
## The estimated discrimination parameters varied between 0.73 (item grk10040_c) and 1.33 (item grk10060_c) with an average discrimination of 1.07 (SD = 0.18), and a median discrimination of 1.07.
## Thresholds:
## The estimated thresholds varied between -2.55 (item grk10030_c) and 3.45 (item grk10040_c) with an average of 0.76 (SD = 1.68), and a median of 0.93.

5 DIF Analysis

NEPSroutines::dif_analysis(
  resp = resp,
  vars = vars,
  select = "dich",
  valid = "valid",
  mvs = mvs,
  dif_vars = c("sex", "mig"),
  scoring = "scoring",
  overwrite = TRUE,
  verbose = FALSE,
  save = TRUE,
  print = TRUE,
  return = FALSE,
  path_results = "results",
  path_table = "tables"
)
## Warning in warn_excluded_missings(dif_var, mis): 190 missing values were found in the DIF variable mig. The corresponding cases were excluded from the analysis.
## 
## RESULTS FOR THE DIF VARIABLE 'sex':
## 
## Facets and group counts:
##         number counts
## Group 0      0    493
## Group 1      1    507
## 
## Information criteria:
##   DIF.variable       Model    N Deviance Number.of.parameters   AIC   BIC
## 1          sex Main effect 1000    11898                   17 11932 12016
## 2          sex         DIF 1000    11879                   31 11941 12094
## 
## Main effects of DIF model and main effects model:
## Comparison 0-1:
##                Model Unstandardized Standardized
## 1          DIF model         -0.525       -0.489
## 2 Main effects model         -0.494       -0.461
## 
## Items exhibiting problematic DIF (|xsi| >= 0.5):
## 
## Comparison 0-1:
##         item   xsi se.xsi   std   Femp  Fkrit df1 df2     p
## 3 grk10030_c 0.509  0.123 0.474 17.125 63.858   1 998 0.985
## 
## RESULTS FOR THE DIF VARIABLE 'mig':
## 
## Facets and group counts:
##         number counts
## Group 0      0    648
## Group 1      1    162
## 
## Information criteria:
##   DIF.variable       Model   N Deviance Number.of.parameters  AIC  BIC
## 1          mig Main effect 810     9595                   17 9629 9709
## 2          mig         DIF 810     9586                   31 9648 9794
## 
## Main effects of DIF model and main effects model:
## Comparison 0-1:
##                Model Unstandardized Standardized
## 1          DIF model          0.553        0.512
## 2 Main effects model          0.601        0.558
## 
## Items exhibiting problematic DIF (|xsi| >= 0.5):
## 
## Comparison 0-1:
##         item   xsi se.xsi   std   Femp  Fkrit df1 df2    p
## 4 grk10040_c 0.622  0.164 0.576 14.384 54.162   1 808 0.97

6 Distractor Analysis

NEPSroutines::dis_analysis(
  resp = resp,
  vars = vars,
  valid = "valid",
  mvs = mvs,
  select_raw = "raw",
  correct = "correct",
  print = TRUE,
  save = TRUE,
  overwrite = TRUE,
  path_results = "results",
  path_table = "tables"
)
## 
## Item-total correlation for correct response: 
## Min. = 0.123 (grk100402)
## Max. = 0.39 (grk100603)
## Md. = 0.324 (grk101204)
## 
## Item-total correlation for distractor: 
## Min. = -0.23 (grk101002)
## Max. = 0.037 (grk100403)
## Md. = -0.118 (grk101401)
## 
## Items with problematic item-total correlations for correct response (r < 0.2): 
## grk100402, grk100502

7 Dimensionality Analysis

No dimensionality analysis not necessary since no testlet variable exists.

8 Create Scores and SUF

scores <- NEPSroutines::create_scores(
  resp,
  vars,
  score_name = "grk1",
  select = "dich",
  valid = "valid",
  mvs = mvs,
  wle = TRUE,
  sum_score = TRUE,
  sum_select = "dich",
  metap = FALSE,
  return = TRUE,
  save = TRUE,
  overwrite = TRUE,
  path_results = "results"
)

NEPSroutines::create_suf(
  resp,
  vars,
  select = "dich",
  competence = "Grammar",
  scores = scores,
  score_name = "grk1",
  return = FALSE,
  path = "suf"
)
## SUF successfully saved!
rm(scores)

9 Session

sessionInfo()
## R version 4.6.0 (2026-04-24 ucrt)
## Platform: x86_64-w64-mingw32/x64
## Running under: Windows 11 x64 (build 26200)
## 
## Matrix products: default
##   LAPACK version 3.12.1
## 
## locale:
## [1] LC_COLLATE=German_Germany.utf8  LC_CTYPE=German_Germany.utf8   
## [3] LC_MONETARY=German_Germany.utf8 LC_NUMERIC=C                   
## [5] LC_TIME=German_Germany.utf8    
## 
## time zone: Europe/Berlin
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] NEPSroutines_1.2.1
## 
## loaded via a namespace (and not attached):
##  [1] gtable_0.3.6            CDM_8.3-14              xfun_0.57              
##  [4] bslib_0.11.0            ggplot2_4.0.3           lattice_0.22-9         
##  [7] vctrs_0.7.3             tools_4.6.0             generics_0.1.4         
## [10] stats4_4.6.0            parallel_4.6.0          tibble_3.3.1           
## [13] pkgconfig_2.0.3         data.table_1.18.4       RColorBrewer_1.1-3     
## [16] S7_0.2.2                uuid_1.2-2              lifecycle_1.0.5        
## [19] flextable_0.9.12        compiler_4.6.0          farver_2.1.2           
## [22] textshaping_1.0.5       fontquiver_0.2.1        fontLiberation_0.1.0   
## [25] htmltools_0.5.9         sass_0.4.10             WrightMap_1.4          
## [28] yaml_2.3.12             pillar_1.11.1           jquerylib_0.1.4        
## [31] tidyr_1.3.2             MASS_7.3-65             admisc_0.40            
## [34] openssl_2.4.1           cachem_1.1.0            fontBitstreamVera_0.1.1
## [37] polycor_0.8-2           tidyselect_1.2.1        zip_2.3.3              
## [40] digest_0.6.39           mvtnorm_1.4-0           stringi_1.8.7          
## [43] dplyr_1.2.1             purrr_1.2.2             forcats_1.0.1          
## [46] fastmap_1.2.0           grid_4.6.0              colorspace_2.1-2       
## [49] cli_3.6.6               magrittr_2.0.5          TAM_4.3-25             
## [52] withr_3.0.2             gdtools_0.5.1           scales_1.4.0           
## [55] rmarkdown_2.31          officer_0.7.5           otel_0.2.0             
## [58] askpass_1.2.1           ragg_1.5.2              hms_1.1.4              
## [61] openxlsx_4.2.8.1        evaluate_1.0.5          knitr_1.51             
## [64] haven_2.5.5             rlang_1.2.0             Rcpp_1.1.1-1.1         
## [67] glue_1.8.1              xml2_1.5.2              rstudioapi_0.18.0      
## [70] jsonlite_2.0.0          R6_2.6.1                systemfonts_1.3.2