Skip to contents

Prepares tidy inputs for MM/AMCE estimation and IRR handling. Called inside pj_estimate() after reshaping to respondent–task–profile.

Usage

organize_data(
  .dataframe,
  .structure,
  .estimand,
  .remove_ties,
  .att_choose,
  .lev_choose,
  .att_notchoose,
  .lev_notchoose
)

Arguments

.dataframe

A tibble/data frame from reshape_projoint(), containing columns like id, task, profile, selected, agree (if repeated), and attribute columns named att1, att2, ... that store level_ids (e.g., "att1:level2").

.structure

Either "profile_level" or "choice_level".

.estimand

Either "mm" or "amce".

.remove_ties

Logical; if TRUE (default) remove tied responses in profile-level setups (keeps tasks where exactly one profile is selected).

.att_choose

Attribute ID for the “chosen” side (e.g., "att3").

.lev_choose

Level ID(s) for the chosen side (e.g., "level2" for profile-level; vector of level IDs for choice-level).

.att_notchoose

Attribute ID for the “not chosen” side (choice-level only).

.lev_notchoose

Level ID(s) for the not-chosen side (choice-level only).

Value

A named list with two tibbles:

  • $data_for_estimand: rows restricted and reshaped to the requested estimand/QOI. For profile-level, one row per respondent–task–profile where the target level is present (ties optionally removed). For choice-level, one row per respondent–task with paired information for profiles 1 and 2, restricted to the requested attribute-level pair(s).

  • $data_for_irr: one row per respondent with columns id, agree (if available), and any detected weight/cluster hints (columns matching "my_weight|my_cluster|^weights?$|^clusters?$").