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). Racking keeps one row per person and duplicates
the items per time point (columns item@time), so change over time
shows in the item estimates. Stacking keeps one column per item
and duplicates the persons per time point (rows), so
change shows in the person estimates and DIF of items over time can be
examined with time as a within-person factor. The returned
id is the original person identifier and therefore repeats across
occasions; row_id uniquely identifies each person-occasion row.
Value
rack_data: a wide data frame with one row per person and
length(items) * n_times item columns. stack_data: a data
frame with one row per person-time, the repeated original id, a
unique row_id, the original item columns, and time as a
factor column for repeated-measures DIF analysis.
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)
#> [1] "id" "Q1@1" "Q2@1" "Q1@2" "Q2@2"
stacked <- stack_data(d, person = "pid", time = "t", items = c("Q1", "Q2"))
head(stacked)
#> id row_id time Q1 Q2
#> 1 1 1@1 1 0 1
#> 2 2 2@1 1 0 0
#> 3 3 3@1 1 1 0
#> 4 4 4@1 1 0 1
#> 5 5 5@1 1 1 0
#> 6 6 6@1 1 1 1
# the follow-up analysis assigns every reshaped column a role: the
# repeated person id, time as a within-person factor, and the items
fit <- rasch(stacked, id = "id", factors = "time",
items = c("Q1", "Q2"))