get.response.from.data.FCDCM: Convert FCDCM Data Strings to a Binary Response Matrix

View source: R/tools-data.R

get.response.from.data.FCDCMR Documentation

Convert FCDCM Data Strings to a Binary Response Matrix

Description

Parses FCDCM preference strings ("a>b" / "b>a") into a 0/1 binary response matrix. Each block compares exactly two items.

Usage

get.response.from.data.FCDCM(data, block.items)

Arguments

data

An N \times B character matrix or data frame. Each cell must be of the form "a>b" or "b>a" where a and b are the two item indices for that block.

block.items

A list of length B. Each element is an integer vector of length 2 giving the two global statement indices compared in that block, in the order used for the 0/1 coding.

Details

For each block, only two strings are valid: "a>b" and "b>a", where a = block.items[[b]][1] and b = block.items[[b]][2]. Leading and trailing whitespace is ignored. Missing values or strings that do not match the block-specific item pair produce an error, because FCDCM fitting requires a complete binary response matrix.

If block.items was obtained from get.block.items.from.data.FCDCM, the pair is sorted in ascending order. In that common workflow, response value 1 means the smaller item index was preferred and response value 0 means the larger item index was preferred.

Value

A named list with component response, an N \times B integer matrix coded 0/1.

Response Coding

The output uses 0/1 coding: 1 indicates preference for the first-named item in block.items[[b]]; 0 indicates preference for the second-named item. This coding is the native format expected by the FCDCM model estimation functions.

See Also

get.data.from.response.FCDCM for the reverse conversion.

get.response.from.data for the generic multi-item converter.

Examples

items <- list(c(1L, 3L), c(2L, 4L))
dat <- data.frame(
  b1 = c("1>3", "3>1", "1>3"),
  b2 = c("2>4", "2>4", "4>2"),
  stringsAsFactors = FALSE
)
get.response.from.data.FCDCM(dat, items)
get.data.from.response.FCDCM(
  get.response.from.data.FCDCM(dat, items)$response, items
)

ForceChoice documentation built on Sept. 13, 2026, 1:06 a.m.