tam_downcode: Downcoding an Item Response Dataset

View source: R/tam_downcode.R

tam_downcodeR Documentation

Downcoding an Item Response Dataset

Description

Recodes item categories in a data frame such that each item has values 0,1,…,K_i.

Usage

tam_downcode(dat)

Arguments

dat

Data frame containing item responses

Value

List with following entries

dat

Recoded dataset

rec

Recoding table

Examples

#############################################################################
# EXAMPLE 1: Downcoding in a toy example
#############################################################################

#-- simulate some toy data
set.seed(989)
# values to be sampled
vals <- c(NA, 0:6)
# number of persons and items
N <- 10; I <- 5
dat <- as.data.frame(matrix(NA, nrow=N, ncol=I))
colnames(dat) <- paste0("I",1:I)
for (ii in 1L:I){
    dat[,ii] <- sample(vals, size=N, replace=TRUE)
}

#-- apply downcoding
res <- TAM::tam_downcode(dat)
dat <- res$dat   # extract downcoded dataset
rec <- res$rec   # extract recoded table

TAM documentation built on Aug. 29, 2022, 1:05 a.m.