mnrCoding: Recode Missing by Intention to Missing not Reached

Description Usage Arguments Details Value Examples

Description

mnrCoding converts missing responses coded as missing by intention at the end of a block of items to missing not reached.

Usage

1
2
3
mnrCoding (dat, pid, rotation.id, blocks, booklets, breaks, 
    subunits = NULL, nMbi = 2, mbiCode = "mbi", mnrCode = "mnr", 
    invalidCodes = c("mbd", "mir", "mci"), verbose = FALSE)

Arguments

dat

A dataset. Missing by intention needs to be coded mbi.

pid

Name or column number of identifier (ID) variable in dat

rotation.id

A character vector of length 1 indicating the column name of the test booklet identfier in dat.

blocks

A data frame containing the sequence of subunits in each block in long format. The column names need to be subunit, block, subunitBlockPosition.

booklets

A data frame containing the sequence of blocks in each booklet in wide format. The column names need to be booklet, block1, block2, block3 ....

breaks

Number of blocks after which mbi shall be recoded to mnr, e.g., c(1,2) to specify breaks after the first and second block.

subunits

Optional: A data frame with subunit information if a dataset is used that has been recoded with recodeData. This data frame will be used to find the names of recoded subunits in dat.

nMbi

Number of mbi-Codes required at the end of a block to code mnr. Needs to be >=1.

mbiCode

Character indicating mbi (missing by intention) in dataset.

mnrCode

Character to which mnr has to be recoded.

invalidCodes

Character vector indicating missing codes to be ignored.

verbose

logical. If TRUE additional diagnostics are printed.

Details

In order to code mnr, a certain number of subunits at the end of a block need to be coded mbi. This number can be specified with the argument nMbi. The default is 2, i.e. if the last and second to last subitem in a block are coded mbi, both subunits, as well as the preceding subunits coded mbi, will be recoded to mnr. If nMbi is larger than the number of subunits in a given block, no subitem in this block will be recoded. If all subunits in a block are coded mbi, none of them will be recoded to mnr.

If a subunits data frame is specified, recodeMbiToMnr expects to find the recoded subunits in dat.

Examples for data frames booklets, blocks, rotation and subunits can be found via data(inputList)

Value

A data frame with missing not reached coded as mnr. For each person with at least one mnr in the returned dataset the names of recoded variables are given as an attribute to dat.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data(inputDat)
data(inputList)

prepDat <- automateDataPreparation (inputList = inputList, 
    datList = inputDat, readSpss = FALSE, checkData=FALSE, 
    mergeData = TRUE, recodeData=TRUE, aggregateData=FALSE, 
    scoreData= FALSE, writeSpss=FALSE, verbose = TRUE)
		   
prepDat2 <- mergeData("ID", list(prepDat, inputList$rotation))		   
			   
mnrDat <- mnrCoding (dat = prepDat2, pid = "ID", 
    booklets = inputList$booklets, blocks = inputList$blocks, 
    rotation.id = "booklet", breaks = c(1, 2), 
    subunits = inputList$subunits, nMbi = 2, mbiCode = "mbi", 
    mnrCode = "mnr", invalidCodes = c("mbd", "mir", "mci"), 
    verbose = TRUE)

eatPrep documentation built on May 2, 2019, 5:20 p.m.

Related to mnrCoding in eatPrep...