Skip to contents

The mirt package's estimation setup requires that all item responses have spaces equal to 1 (e.g., a Likert scale scored from 1 through 5). In the event that categories are missing the categories must be re-coded. This function is automatically called by the package estimation functions (e.g., mirt), however for convince this function has been extracted for users to better understand the remapping consequences.

Usage

remap.distance(data, message = TRUE)

Arguments

data

the response data to remap as a data.frame or matrix

message

logical; print message information pertaining to which items were remapped?

References

Chalmers, R., P. (2012). mirt: A Multidimensional Item Response Theory Package for the R Environment. Journal of Statistical Software, 48(6), 1-29. doi:10.18637/jss.v048.i06

Author

Phil Chalmers rphilip.chalmers@gmail.com

Examples


# category 2 for item 1 missing
dat <- Science
dat[,1] <- ifelse(Science[,1] == 2, 1, Science[,1])
apply(dat, 2, table)
#> $Comfort
#> 
#>   1   3   4 
#>  37 266  89 
#> 
#> $Work
#> 
#>   1   2   3   4 
#>  33  98 206  55 
#> 
#> $Future
#> 
#>   1   2   3   4 
#>  14  72 210  96 
#> 
#> $Benefit
#> 
#>   1   2   3   4 
#>  21 100 193  78 
#> 

# mirt() automatically remaps categories
mod <- mirt(dat, 1)
#> "Comfort" re-mapped to ensure all categories have a distance of 1
#> 
Iteration: 1, Log-Lik: -1614.807, Max-Change: 0.40351
Iteration: 2, Log-Lik: -1603.657, Max-Change: 0.23414
Iteration: 3, Log-Lik: -1599.256, Max-Change: 0.19589
Iteration: 4, Log-Lik: -1596.125, Max-Change: 0.06372
Iteration: 5, Log-Lik: -1595.799, Max-Change: 0.06841
Iteration: 6, Log-Lik: -1595.611, Max-Change: 0.06323
Iteration: 7, Log-Lik: -1595.135, Max-Change: 0.02986
Iteration: 8, Log-Lik: -1595.122, Max-Change: 0.01730
Iteration: 9, Log-Lik: -1595.116, Max-Change: 0.01053
Iteration: 10, Log-Lik: -1595.112, Max-Change: 0.02062
Iteration: 11, Log-Lik: -1595.109, Max-Change: 0.00770
Iteration: 12, Log-Lik: -1595.107, Max-Change: 0.00676
Iteration: 13, Log-Lik: -1595.103, Max-Change: 0.00260
Iteration: 14, Log-Lik: -1595.103, Max-Change: 0.00029
Iteration: 15, Log-Lik: -1595.103, Max-Change: 0.00494
Iteration: 16, Log-Lik: -1595.102, Max-Change: 0.00098
Iteration: 17, Log-Lik: -1595.102, Max-Change: 0.00033
Iteration: 18, Log-Lik: -1595.102, Max-Change: 0.00109
Iteration: 19, Log-Lik: -1595.102, Max-Change: 0.00020
Iteration: 20, Log-Lik: -1595.102, Max-Change: 0.00359
Iteration: 21, Log-Lik: -1595.102, Max-Change: 0.00022
Iteration: 22, Log-Lik: -1595.102, Max-Change: 0.00022
Iteration: 23, Log-Lik: -1595.102, Max-Change: 0.00075
Iteration: 24, Log-Lik: -1595.102, Max-Change: 0.00065
Iteration: 25, Log-Lik: -1595.102, Max-Change: 0.00023
Iteration: 26, Log-Lik: -1595.102, Max-Change: 0.00067
Iteration: 27, Log-Lik: -1595.102, Max-Change: 0.00013
Iteration: 28, Log-Lik: -1595.102, Max-Change: 0.00013
Iteration: 29, Log-Lik: -1595.102, Max-Change: 0.00060
Iteration: 30, Log-Lik: -1595.102, Max-Change: 0.00014
Iteration: 31, Log-Lik: -1595.102, Max-Change: 0.00063
Iteration: 32, Log-Lik: -1595.102, Max-Change: 0.00013
Iteration: 33, Log-Lik: -1595.102, Max-Change: 0.00055
Iteration: 34, Log-Lik: -1595.102, Max-Change: 0.00019
Iteration: 35, Log-Lik: -1595.102, Max-Change: 0.00055
Iteration: 36, Log-Lik: -1595.102, Max-Change: 0.00011
Iteration: 37, Log-Lik: -1595.102, Max-Change: 0.00011
Iteration: 38, Log-Lik: -1595.102, Max-Change: 0.00049
Iteration: 39, Log-Lik: -1595.102, Max-Change: 0.00012
Iteration: 40, Log-Lik: -1595.102, Max-Change: 0.00011
Iteration: 41, Log-Lik: -1595.102, Max-Change: 0.00043
Iteration: 42, Log-Lik: -1595.102, Max-Change: 0.00045
Iteration: 43, Log-Lik: -1595.102, Max-Change: 0.00015
Iteration: 44, Log-Lik: -1595.102, Max-Change: 0.00043
Iteration: 45, Log-Lik: -1595.102, Max-Change: 0.00009
coef(mod, simplify=TRUE)
#> $items
#>            a1    d1     d2     d3
#> Comfort 0.995 2.626 -1.447     NA
#> Work    1.231 2.928  0.903 -2.271
#> Future  2.338 5.293  2.245 -1.989
#> Benefit 1.079 3.333  0.988 -1.681
#> 
#> $means
#> F1 
#>  0 
#> 
#> $cov
#>    F1
#> F1  1
#> 

# this is the transformed data used by mirt()
remap_dat <- remap.distance(dat)
#> "Comfort" re-mapped to ensure all categories have a distance of 1
apply(remap_dat, 2, table)
#> $Comfort
#> 
#>   1   2   3 
#>  37 266  89 
#> 
#> $Work
#> 
#>   1   2   3   4 
#>  33  98 206  55 
#> 
#> $Future
#> 
#>   1   2   3   4 
#>  14  72 210  96 
#> 
#> $Benefit
#> 
#>   1   2   3   4 
#>  21 100 193  78 
#>