% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/tools-data.R
\name{get.response.from.data.FCDCM}
\alias{get.response.from.data.FCDCM}
\title{Convert FCDCM Data Strings to a Binary Response Matrix}
\usage{
get.response.from.data.FCDCM(data, block.items)
}
\arguments{
\item{data}{An \eqn{N \times B} character matrix or data frame.  Each
cell must be of the form \code{"a>b"} or \code{"b>a"} where
\code{a} and \code{b} are the two item indices for that block.}

\item{block.items}{A list of length \eqn{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.}
}
\value{
A named list with component \code{response}, an \eqn{N \times B}
integer matrix coded 0/1.
}
\description{
Parses FCDCM preference strings (\code{"a>b"} / \code{"b>a"}) into a
0/1 binary response matrix.  Each block compares exactly two items.
}
\details{
For each block, only two strings are valid: \code{"a>b"} and \code{"b>a"},
where \code{a = block.items[[b]][1]} and \code{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 \code{block.items} was obtained from
\code{\link{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.
}
\section{Response Coding}{

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

\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
)
}
\seealso{
\code{\link{get.data.from.response.FCDCM}} for the reverse conversion.

\code{\link{get.response.from.data}} for the generic multi-item
converter.
}
