---
name: ena-analysis
description: >
  Run Epistemic Network Analysis (ENA) on tabular coded data using the
  @qe-mcp/server-ena connector. Use whenever the user references tabular data
  with binary presence/absence codes and asks for analysis, exploration,
  co-occurrence patterns, or group comparison — especially discourse data,
  behavioral coding, learning analytics, or clinical observation data.
  Includes a privacy gate for sensitive datasets: raw data can stay entirely
  on the user's machine.
---

# ENA Analysis

Epistemic Network Analysis models patterns of co-occurrence between coded
events (discourse moves, behaviors, features) within conversations, projecting
each unit of analysis into a low-dimensional space where distances are
interpretable. It reveals structural differences that summary statistics and
regression miss.

This skill drives the **ena** MCP connector (`@qe-mcp/server-ena`). All model
computation runs locally on the user's machine via WebAssembly — only results
(node positions, plots, summary statistics) are returned to Claude.

## Privacy gate — always ask first

Before calling any ENA tool on new data, ask:

> "Is this data sensitive or confidential? If so, give me the file path
> instead of pasting the data — raw data stays on your machine when you use
> a file path."

If the data is sensitive (or the user hasn't answered yet):

1. Call `ena_profile` with only `data_path`. It returns column names, unique
   counts, and binary detection — **no raw row data is ever transmitted**.
2. Use the profile to determine parameters (units, conversations, codes).
3. Call `ena_fit` / `ena_compare_groups` with `data_path`. Only model results
   reach the conversation.

Note: unit labels (values from the unit column, e.g. participant IDs) appear
in model results. If those are themselves sensitive, warn the user before
fitting.

If the data is not sensitive, or is toy/demo data, proceed with `ena_inspect`
directly. Prefer `data_path` over `data_csv` in all cases; use `data_csv`
only for small pasted samples.

## When ENA fits the data

- Rows are utterances, events, or observations
- Columns include binary (0/1) presence/absence codes
- A column identifies who produced each row (unit of analysis)
- A column groups rows into episodes or conversations
- Optionally: two or more conditions/groups to compare

## Workflow

1. **Triage** — `ena_inspect` (or `ena_profile` for sensitive data). Returns
   `ena_recommended`, suggested codes/units/conversations, and a pre-filled
   `next_step` call. If `ena_recommended` is true, propose ENA as the primary
   analysis and briefly explain what it will reveal.
2. **Fit** — `ena_fit` for a single model, or `ena_compare_groups` when two
   groups exist. Both return a `model_id` and an inline network plot.
   Do not generate your own visualization — the plot comes back as an image.
3. **Explore** — `ena_plot` with the cached `model_id` renders additional
   views without refitting:
   - `all` — all units
   - `group` — one group's mean network (`group_value`)
   - `comparison` — two group networks overlaid (`group1`, `group2`)
   - `subtraction` — difference network (`group1`, `group2`)
   - `unit` — a single unit's network (`unit_label`)
4. **Interpret** — strong connections indicate codes that co-occur within
   the stanza window; in subtraction plots, edge color/direction shows which
   group each connection favors. Node positions are fixed across views of the
   same model, so plots are directly comparable.

Each fit/plot response also includes `interactive_plot` — a local HTML file
path with the interactive visualization the user can open in a browser.

Repeated calls with identical parameters return the cached model instantly,
so iterating on views is cheap.
