$npx -y skills add scdenney/open-science-skills --skill conjoint-cleaningClean and reshape Qualtrics conjoint exports to analysis-ready long format.
| 1 | # Conjoint Data Cleaning Expert |
| 2 | |
| 3 | ## Instructions |
| 4 | |
| 5 | ### 1. Qualtrics Export Settings and Metadata |
| 6 | |
| 7 | **Export format:** The right Qualtrics export choice depends on the pipeline. `cjoint::read.qualtrics()` (Method A) hard-errors when the choice-response columns contain text — export **"Use numeric values"** for it. `projoint::reshape_projoint()` parses the chosen profile from a label at the end of the outcome string (default `A`/`B`), and manual reshaping benefits from readable attribute labels — **"Use choice text"** works for those. When unsure, export both versions; they differ only in response coding. If working with non-Latin scripts (Chinese, Korean, Arabic), export as XLSX rather than CSV to avoid UTF-8/ANSI encoding issues. On Windows with East Asian locales, `read.csv()` may still require `Sys.setlocale()` to match the file encoding before import (see `?cjoint::read.qualtrics` East Asian Language Support). |
| 8 | |
| 9 | **Metadata rows:** Current Qualtrics CSV exports include **3 header rows** before respondent data: (1) variable identifiers, (2) question text/descriptions, (3) ImportId JSON. Legacy exports have 2 rows. The `cjoint::read.qualtrics()` parameter `new.format = TRUE` (set explicitly; default is `FALSE`) handles the 3-row format. For manual import via `readxl::read_excel()` or `readr::read_csv()`, skip the appropriate number of metadata rows after reading headers. |
| 10 | |
| 11 | **Randomization order columns:** If "Export viewing order data" is enabled, Qualtrics adds `_DO_` columns (e.g., `Block1_DO`) containing pipe-separated integers showing element display order. These are useful for task-order robustness checks but are not needed for the core reshape. |
| 12 | |
| 13 | ### 2. Qualtrics Conjoint Implementation Methods |
| 14 | |
| 15 | Qualtrics conjoint experiments use one of three implementation methods, each producing different column naming conventions: |
| 16 | |
| 17 | **Method A — Conjoint Survey Design Tool (Strezhnev):** Generates JavaScript that Qualtrics executes to randomize profiles. Column naming follows `F-{task}-{profile}-{attribute}` for attribute levels and `F-{task}-{attribute}` for attribute names. The `cjoint` R package's `read.qualtrics()` function is purpose-built for this format. |
| 18 | |
| 19 | **Method B — Custom JavaScript + Embedded Data:** Researchers write JavaScript to randomize attributes and store values in Qualtrics embedded data fields. Column naming is researcher-defined. Two common conventions: (i) `C{x}-F-{task}-{idx}` for attribute names and `C{x}-F-{task}-{profile}-{idx}` for profile values; (ii) the Graham (2020) convention, `choice{task}_{attr}{profile}` with fixed attribute order (e.g., `choice1_bread1`) or `c{task}_attrib{pos}_name` / `c{task}_attrib{pos}_sand{profile}` when attribute order is also randomized. Requires manual reshaping (Section 4). |
| 20 | |
| 21 | **Method C — Loop & Merge:** Each loop iteration represents one conjoint task. Embedded data fields are referenced via `${e://Field/variable_name}` and displayed with `${lm://Field/N}`. Column names reflect the embedded data field structure. Requires manual reshaping. |
| 22 | |
| 23 | **Before writing any cleaning code:** Inspect the actual column headers, the QSF survey definition file, or any JavaScript in the survey to determine which method was used. Do not assume a column naming convention. |
| 24 | |
| 25 | ### 3. Existing R Packages for Conjoint Data Import |
| 26 | |
| 27 | Before writing custom reshaping code, check whether an existing package handles the data format: |
| 28 | |
| 29 | **`cjoint::read.qualtrics()`** — Purpose-built for Conjoint SDT exports (Method A). Reads Qualtrics CSV directly, handles metadata rows, outputs one row per profile with a `selected` column. Parameters: `responses` (choice column names), `covariates` (respondent-level variables), `respondentID`, `new.format` (TRUE for 3-row headers), `ranks` (for rank/rating/top-L designs). Supports binary forced choice, profile ranks, per-profile ratings, and top-L choices; see `?cjoint::read.qualtrics` Details for the four response types. Requires PHP/JS output from the Conjoint Survey Design Tool. |
| 30 | |
| 31 | **`cjdata::reshape_conjoint()`** — Lightweight alternative. Functions: `read_Qualtrics()` + `reshape_conjoint()`. Handles basic wide-to-long conversion. Requires the **terminal character** of each outcome string to be {"1","2"} or {"A","B"} (so "Candidate A" works; Japanese zenkaku digits supported). Respondent covariates merged separately. |
| 32 | |
| 33 | **`projoint::reshape_projoint()`** — For measurement-error-corrected analysis per Clayton, Horiuchi, Kaufman, King, and Komisarchik (2023). Built-in support for repeated tasks (IRR estimation), missing-agreement imputation (`.fill = TRUE`), and bias-corrected AMCEs. Outcome column names must contain task-ID digits, and the repeated-task outcome must be the **last** element of `.outcomes`. Expects wide columns named `K-{task}-{attribute}` and `K-{task}-{profile}-{attribute}` by default (`.alphabet = "K"`); selected profile is pa |