% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ctt.R
\name{rack_data}
\alias{rack_data}
\alias{stack_data}
\title{Reshape repeated measurements for racked or stacked analysis}
\usage{
rack_data(data, person, time, items)

stack_data(data, person, time, items)
}
\arguments{
\item{data}{A long data frame with one measurement per row.}

\item{person, time}{Names of the person and time-point columns.}

\item{items}{Character vector naming the item columns.}
}
\value{
\code{rack_data}: a wide data frame with one row per person and
  \code{length(items) * n_times} item columns. \code{stack_data}: a data
  frame with one row per person-time (\code{id} column), the original
  item columns, and \code{time} as a factor column for DIF analysis.
}
\description{
Repeated measurements (the same persons and items at two or more time
points) enter a Rasch analysis in one of two designs (Andrich & Marais
2019, ch. 26). \emph{Racking} keeps one row per person and duplicates
the items per time point (columns \code{item@time}), so change over time
shows in the item estimates. \emph{Stacking} keeps one column per item
and duplicates the persons per time point (rows \code{person@time}), so
change shows in the person estimates and DIF of items over time can be
examined with \code{time} as a person factor.
}
\examples{
d <- data.frame(pid = rep(1:100, 2), t = rep(1:2, each = 100),
                Q1 = rbinom(200, 1, 0.6), Q2 = rbinom(200, 1, 0.5))
racked <- rack_data(d, person = "pid", time = "t", items = c("Q1", "Q2"))
names(racked)
stacked <- stack_data(d, person = "pid", time = "t", items = c("Q1", "Q2"))
head(stacked)
}
