## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
library(meow)

## ----eval = FALSE-------------------------------------------------------------
# data_existing <- function(resp_path, pers_path, item_path) {
#   list(
#     resp = utils::read.csv(resp_path),
#     pers_tru = utils::read.csv(pers_path),
#     item_tru = utils::read.csv(item_path)
#   )
# }

## ----eval = FALSE-------------------------------------------------------------
# data_simple_1pl <- function(N_persons = 100, N_items = 50, data_seed = 242424) {
#   set.seed(data_seed)
#   pers_tru <- data.frame(id = 1:N_persons, theta = stats::rnorm(N_persons))
#   item_tru <- data.frame(item = 1:N_items, b = stats::rnorm(N_items), a = 1)
# 
#   theta_mat <- matrix(pers_tru$theta, N_persons, N_items)
#   diff_mat  <- matrix(item_tru$b, N_persons, N_items, byrow = TRUE)
#   p <- stats::plogis(theta_mat - diff_mat)
#   resp_mat <- matrix(stats::rbinom(length(p), 1, p), N_persons, N_items)
# 
#   resp <- data.frame(
#     id = rep(seq_len(N_persons), each = N_items),
#     item = rep(seq_len(N_items), times = N_persons),
#     resp = as.vector(t(resp_mat))
#   )
#   set.seed(NULL)
#   list(resp = resp, pers_tru = pers_tru, item_tru = item_tru)
# }

## -----------------------------------------------------------------------------
data <- data_simple_1pl(N_persons = 6, N_items = 4)
str(data, max.level = 1)
head(data$resp)

