Skip to contents

This function is used to recode character missings in datasets that were prepared using the eatPrep package to 0 or NA. Additionally, all variables are converted to numeric. It should be called to recode the missing values prior to passing datasets on to eatModel.

Usage

collapseMissings(dat, missing.rule = list(mvi = 0, mnr = 0, mci = NA,
mbd = NA, mir = 0, mbi = 0), items = NULL, standard = TRUE)

Arguments

dat

A data frame containing character missings (e.g., mbd - missing by design). See ‘Details’ for supported character missing values.

missing.rule

A named list with definitions how to recode the different types of missings in the dataset. The names correspond to the character missings and the list elements correspond to their recode values.

items

A character vector containing the column names of the data frame for the which character missings should be recoded.

standard

Logical. Whether it is used in the eatPrep standard case (recoding to 0 or NA) or not.

Details

One main idea of the eatPrep package is that different types of missing values should remain distinguishable during data preparation, thus allowing the user to flexibly recode them to different values during the IRT scaling process. collapseMissings facilitates recoding of the different types of character missings before IRT analysis or when exporting the data to other software packages (e.g., SPSS).

The eatPrep package currently suggests six different types of missings, namely

mvi (text volume insufficient): used in writing tasks if a person wrote to little to evaluate whether they met a specific criterion.

mnr (missing not reached): used whenever a person did not reach the respective task in his or her test booklet. All consecutive missing values clustered at the end of a test session can be coded mnr, e.g., by the function mnrCoding from package eatPrep.

mci (missing coding impossible): used whenever a response cannot be coded due to technical problems (e.g., problems in digitalizing the booklets)

mbd (missing by design): used whenever an item was not administered to a specific person.

mir (missing invalid response): used whenever a person attempted to answer an item but this answer cannot be classified in the existing coding scheme. Can also be used for multiple choice-items when the respondent selected more than one option.

mbi (missing by intention): used whenever a person was expected to answer an item but did not provide a response.

The default recode values for these missing types are: text volume insufficient = 0, missing not reached = 0, missing coding impossible = NA, missing by design = NA, missing invalid response = 0, missing by intention = 0

Value

A data frame with all missing values coded as 0 or NA according to the specification in the argument missing.rule.

References

OECD (2005). PISA 2003 Technical Report. OECD Publishing.

Author

Nicole Mahler, Karoline Sachse, Martin Hecht

Examples

data(inputDat)
data(inputList)

dat1 <- inputDat[[1]]  # get first dataset from inputDat
datRec <- recodeData(dat1, inputList$values, inputList$subunits, verbose = TRUE)
#> 
#> Found no recode information for variable(s): 
#> ID, hisei. 
#> This/These variable(s) will not be recoded.
#> 
#> Variables... I01, I02, I03, I04, I05, I06, I07, I08, I09, I10, I11, I12a, I12b, I12c, I13, I14, I15, I16, I17, I18, I19, I20, I21
#> ...have been recoded.
str(datRec)
#> 'data.frame':	100 obs. of  25 variables:
#>  $ ID   : chr  "person100" "person101" "person102" "person103" ...
#>  $ hisei: chr  "49" NA "57" "32" ...
#>  $ I01R : chr  "0" "mbi" "1" "0" ...
#>  $ I02R : chr  "0" "0" "0" "0" ...
#>  $ I03R : chr  "0" "1" "1" "0" ...
#>  $ I04R : chr  "1" "1" "0" "0" ...
#>  $ I05R : chr  "0" "0" "0" "1" ...
#>  $ I06R : chr  "0" "mbi" "0" "1" ...
#>  $ I07R : chr  "0" "0" "0" "0" ...
#>  $ I08R : chr  "0" "1" "0" "0" ...
#>  $ I09R : chr  "0" "0" "0" "0" ...
#>  $ I10R : chr  "1" "0" "0" "0" ...
#>  $ I11R : chr  "0" "0" "1" "0" ...
#>  $ I12aR: chr  "1" "0" "1" "0" ...
#>  $ I12bR: chr  "0" "mbi" "0" "1" ...
#>  $ I12cR: chr  "1" "0" "0" "1" ...
#>  $ I13R : chr  "mbi" "0" "mbi" "0" ...
#>  $ I14R : chr  "mbi" "0" "mbi" "0" ...
#>  $ I15R : chr  "mbi" "0" "mbi" "1" ...
#>  $ I16R : chr  "mbi" "0" "mbi" "0" ...
#>  $ I17R : chr  "mbi" "0" "mbi" "0" ...
#>  $ I18R : chr  "mbi" "1" "mbi" "1" ...
#>  $ I19R : chr  "mbi" "1" "mbi" "0" ...
#>  $ I20R : chr  "mbi" "0" "mbi" "0" ...
#>  $ I21R : chr  "mbi" "0" "mbi" "1" ...
datColMis <- collapseMissings(datRec)
str(datColMis)
#> 'data.frame':	100 obs. of  25 variables:
#>  $ ID   : chr  "person100" "person101" "person102" "person103" ...
#>  $ hisei: chr  "49" NA "57" "32" ...
#>  $ I01R : chr  "0" "0" "1" "0" ...
#>  $ I02R : chr  "0" "0" "0" "0" ...
#>  $ I03R : chr  "0" "1" "1" "0" ...
#>  $ I04R : chr  "1" "1" "0" "0" ...
#>  $ I05R : chr  "0" "0" "0" "1" ...
#>  $ I06R : chr  "0" "0" "0" "1" ...
#>  $ I07R : chr  "0" "0" "0" "0" ...
#>  $ I08R : chr  "0" "1" "0" "0" ...
#>  $ I09R : chr  "0" "0" "0" "0" ...
#>  $ I10R : chr  "1" "0" "0" "0" ...
#>  $ I11R : chr  "0" "0" "1" "0" ...
#>  $ I12aR: chr  "1" "0" "1" "0" ...
#>  $ I12bR: chr  "0" "0" "0" "1" ...
#>  $ I12cR: chr  "1" "0" "0" "1" ...
#>  $ I13R : chr  "0" "0" "0" "0" ...
#>  $ I14R : chr  "0" "0" "0" "0" ...
#>  $ I15R : chr  "0" "0" "0" "1" ...
#>  $ I16R : chr  "0" "0" "0" "0" ...
#>  $ I17R : chr  "0" "0" "0" "0" ...
#>  $ I18R : chr  "0" "1" "0" "1" ...
#>  $ I19R : chr  "0" "1" "0" "0" ...
#>  $ I20R : chr  "0" "0" "0" "0" ...
#>  $ I21R : chr  "0" "0" "0" "1" ...