| get.response.from.data | R Documentation |
Parses human-readable forced-choice data strings into integer pattern indices. This is the generic converter used by FCGGUM, FCMIRT, and FCGDINA. Each data cell is matched against the full set of permutation/observation patterns for that block, and the resulting row index is stored in the response matrix.
get.response.from.data(data, block.items, fc.type = "RANK")
data |
An |
block.items |
A list of length |
fc.type |
Character vector of length |
An N \times B integer matrix. Each entry is a 1-based
pattern index (row number in the block's pattern matrix). Column
names are "block.1", ..., "block.B".
The conversion first generates all possible observation patterns for each block via the internal permutation helper:
RANK (K items): all K! full rankings,
ordered lexicographically by within-block position.
MOLE: K(K-1) most-least observation patterns.
PICK: K best-only patterns.
Each data cell string is parsed into an integer vector of global item indices, which is then matched (as an ordered sequence) against the pattern matrix. The 1-based row index of the match becomes the response value. Pattern ordering is deterministic and reproducible.
A non-missing cell that cannot be matched to a valid pattern is returned as
NA_integer_. This is useful for data-screening workflows: after
conversion, check anyNA(response) before passing the response matrix
to a fitting function.
get.data.from.response for the reverse conversion.
generate_fc_permutation_patterns for pattern generation
details.
get.response.from.data.TIRT for the TIRT-specific
converter.
# 2 persons, 2 RANK blocks.
items <- list(1:2, 3:5)
dat <- data.frame(
block.1 = c("1>2", "2>1"),
block.2 = c("3>4>5", "5>4>3"),
stringsAsFactors = FALSE
)
resp <- get.response.from.data(dat, items, fc.type = "RANK")
resp
get.data.from.response(resp, items, fc.type = "RANK")
# Mixed block formats: most-least plus pick.
dat.mixed <- data.frame(
mole = c("1>3", "3>2"),
pick = c("4", "6"),
stringsAsFactors = FALSE
)
mixed.items <- list(1:3, 4:6)
get.response.from.data(
dat.mixed, mixed.items, fc.type = c("MOLE", "PICK")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.