Learn R Programming

epmfd (version 1.1.1)

load_epmfd: Load and validate raw data for the epmfd workflow

Description

load_epmfd() prepares raw item-response data for subsequent functions in the epmfd workflow. It validates input, ensures that all item responses fall within the expected range of categories, converts items to ordered factors, and attaches person IDs.

Usage

load_epmfd(data, id_col = NULL, likert_levels = NULL)

Value

An object of class epmfd_raw, a list with elements:

  • data: A data.frame of ordered-factor responses

  • id: Vector of person IDs

  • K: Maximum number of categories per item

Arguments

data

A data.frame or tibble with persons in rows and items in columns. All item responses must be integers in 1:K, possibly with missing values.

id_col

Optional character string giving the column name containing unique person identifiers. If NULL, a simple integer sequence 1:n is used.

likert_levels

Optional integer specifying the maximum category value (K). If NULL, K is inferred automatically as the maximum observed value in the data.

Details

Each column of data is validated to ensure responses are within 1:K. Values outside this range cause an error. Missing values are allowed and reported.

See Also

scale_epmfd(), misfit_epmfd()

Examples

Run this code
# Example: 5 persons × 3 items, responses 1–4
df <- data.frame(
  Pid = paste0("P", 1:5),
  Item1 = c(1, 2, 3, 2, 1),
  Item2 = c(2, 3, 4, 2, 1),
  Item3 = c(3, 4, 1, 2, 2)
)

raw <- load_epmfd(df, id_col = "Pid", likert_levels = 4)
str(raw)


Run the code above in your browser using DataLab