irtree_recode: Recode data into pseudoitems

Description Usage Arguments Value Examples

View source: R/generate-data.R

Description

This function takes a data set with polytomous items and an irtree_model and returns the recoded items, the so-called pseudoitems.

Usage

1
irtree_recode(object = NULL, data = NULL, keep = FALSE, mapping_matrix = NULL)

Arguments

object

Object of class irtree_model. See irtree_model for more information.

data

Data frame containing containing one row per respondent and one column per variable. The variable names must correspond to those used in object.

keep

Logical indicating whether to append the original items to the data frame of the generated pseudoitems

mapping_matrix

Matrix of so-called pseudo-items, optional and overwritten by object if present. The observed response categories must appear in the first column. The other columns contain the pseudo-items and each entry may be either 1, 0, or NA. The first column name must be categ, and the other names (related to the pseudo-items) are used to construct the names of the returned data frame.

Value

Data frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
m1 <- "
IRT:
t BY x1;
e BY x1;
m BY x1;
Equations:
1 = (1-m)*(1-t)*e
2 = (1-m)*(1-t)*(1-e)
3 = m
4 = (1-m)*t*(1-e)
5 = (1-m)*t*e
Class:
Tree
"
model1 <- irtree_model(m1)
dat <- data.frame(x1 = 1:5)
irtree_recode(model1, dat, keep = TRUE)

irtree_recode(data = dat,
              mapping_matrix = cbind(categ = 1:5,
                                     m = c(0, 0, 1, 0, 0),
                                     t = c(1, 1, NA, 0, 0),
                                     e = c(1, 0, NA, 0, 1)))

hplieninger/ItemResponseTrees documentation built on Nov. 13, 2020, 12:17 p.m.