Treat unsure and blank answers as missing information, not choices
- engine.js / analyze.py: one MISSING set ("Unknown", "Unsure",
"Unsure/unknown", "Multiple", "(not recorded)", "(not asked)", ...).
Factor tables compare only runs that answered each question and report how
many were left out; models are complete-case for every choice variable;
route rankings group only fully known routes; the route flow skips
missing steps.
- "I've lost count" now counts as a later attempt.
- The chase goal keeps its "not asked" stratum as an adjustment only; it is
no longer displayed as a finding.
- Page: no unknown levels in charts, tables or filters; factor explorer notes
how many runs were left out; Methods explains the rule.
JS/Python parity still exact.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UCzTd31GphpMXDhQqWrCMQ
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
de80e99c74
commit
1b0ef9a2c1
+10
-9
@@ -220,10 +220,10 @@
|
||||
$$(".tchip[data-t]").forEach((b) => b.addEventListener("click", () => { state.target = b.dataset.t; $("#best-routes").innerHTML = ""; renderTargets(); renderMap(); }));
|
||||
}
|
||||
const ORDER = {
|
||||
company: ["Alone", "1 Squadmate", "2 Squadmates", "Unknown"],
|
||||
direction: ["East", "Center", "West", "Multiple", "Unknown"],
|
||||
first_sighting: ["Red", "Orange", "Brown", "Green", "Unsure", "Unknown"],
|
||||
post_path: ["Forest", "West", "East", "(no fork)", "Unknown"],
|
||||
company: ["Alone", "1 Squadmate", "2 Squadmates"],
|
||||
direction: ["East", "Center", "West"],
|
||||
first_sighting: ["Red", "Orange", "Brown", "Green"],
|
||||
post_path: ["Forest", "West", "East", "(no fork)"],
|
||||
hour: ["Climb the tree", "Valley centre"],
|
||||
encounter: ["Tree: Red below", "Tree: two Greens", "Tree: shadow → Blue/Black", "Valley: bond the Red", "Meadow: Orange", "Meadow: Brown", "Meadow: Orange/Brown", "Meadow: Blue", "Meadow (no attempt recorded)"],
|
||||
end: ["Bonded Red", "Bonded Green", "Bonded Orange", "Bonded Brown", "Bonded Blue", "Bonded Black", "Incinerated", "Died before the hour"],
|
||||
@@ -487,10 +487,10 @@
|
||||
const blueCol = dragonColor("Blue"), blackCol = dragonColor("Black");
|
||||
const strataRows = (c, col) => [{ label: "All rows", ...c.overall, color: cssVar("--ink") }].concat(
|
||||
STRATUM_ORDER.filter((s) => c.by_stratum[s]).map((s) => ({ label: s, ...c.by_stratum[s], color: col })),
|
||||
Object.entries(c.by_attempt).filter(([k]) => k !== "Unknown/lost count").map(([k, w]) => ({ label: k, ...w, color: cssVar("--accent") })));
|
||||
Object.entries(c.by_attempt).filter(([k]) => !E.isMissing(k)).map(([k, w]) => ({ label: k, ...w, color: cssVar("--accent") })));
|
||||
ciBars($("#ch-blue-strata"), strataRows(r.chance.blue_meadow, blueCol), { labelW: 180 });
|
||||
ciBars($("#ch-shadow-strata"), strataRows(r.chance.shadow, blackCol), { labelW: 180 });
|
||||
const termsOf = (m, skip = []) => (m ? m.terms.filter((t) => t.n >= 5 && !skip.includes(t.factor)).map((t) => ({ label: `${labelFactor(t.factor)}: ${t.level}`, or: t.or, lo: t.lo, hi: t.hi, p: t.p, n: t.n })) : []);
|
||||
const termsOf = (m, skip = []) => (m ? m.terms.filter((t) => t.n >= 5 && !skip.includes(t.factor) && !E.isMissing(t.level)) /* the "goal not asked" stratum stays in the model as an adjustment, but is not a finding */.map((t) => ({ label: `${labelFactor(t.factor)}: ${t.level}`, or: t.or, lo: t.lo, hi: t.hi, p: t.p, n: t.n })) : []);
|
||||
const mb = r.models.blue_meadow, ms = r.models.shadow;
|
||||
forest($("#ch-model-blue"), termsOf(mb));
|
||||
forest($("#ch-model-shadow"), termsOf(ms));
|
||||
@@ -563,9 +563,10 @@
|
||||
$("#green-rescue").innerHTML = `<p class="small muted">${g.green_encounters} tree runs that descended slowly to the two Greens. A wrong answer sometimes brings an Orange or Brown swooping in to bond you instead.</p>
|
||||
<div style="display:flex;height:16px;border-radius:3px;overflow:hidden;border:1px solid var(--line)">${parts.map(([, n, c]) => `<span style="width:${(100 * n) / tot}%;background:${c}"></span>`).join("")}</div>
|
||||
<div class="tbl-wrap"><table><tbody>${parts.map(([l, n, c]) => { const w = E.wilson(n, g.green_encounters); return `<tr><td><span style="display:inline-block;width:10px;height:10px;border-radius:2px;background:${c};margin-right:6px"></span>${l}</td><td class="num">${n}</td><td class="num">${pct(w.p)}</td><td class="num">${ci(w)}</td></tr>`; }).join("")}</tbody></table></div>`;
|
||||
const cols = ["Red", "Orange", "Brown", "Green", "Unsure", "Unknown"];
|
||||
// "Unsure" / blank first sightings are missing information, not a colour: left out of the table and its totals
|
||||
const cols = ["Red", "Orange", "Brown", "Green"];
|
||||
const POOL = { "Alone|East": ["Red", "Orange"], "Alone|West": ["Red", "Brown", "Green"], "Alone|Center": ["Red", "Brown"], "1 Squadmate|East": ["Green", "Orange", "Red"], "1 Squadmate|West": ["Red", "Brown", "Green"], "1 Squadmate|Center": ["Red", "Brown"], "2 Squadmates|East": ["Red", "Orange"], "2 Squadmates|West": ["Green", "Brown", "Red"], "2 Squadmates|Center": ["Red", "Brown"] };
|
||||
$("#tbl-first").innerHTML = `<table><thead><tr><th>Company · direction</th>${cols.map((c) => `<th class="num">${c}</th>`).join("")}<th class="num">Runs</th></tr></thead><tbody>${r.first_sighting.filter((x) => x.n >= 3).map((x) => `<tr><td>${esc(x.key.replace("|", " · "))}</td>${cols.map((c) => { const n = x.colors[c] || 0; const off = n && POOL[x.key] && !["Unsure", "Unknown"].includes(c) && !POOL[x.key].includes(c); return `<td class="num" style="${off ? "color:var(--warn);font-weight:600" : n ? "" : "color:var(--faint)"}" title="${off ? "Outside the documented pool" : ""}">${n ? `${n}<span class="muted"> · ${pct(n / x.n, 0)}</span>` : "·"}</td>`; }).join("")}<td class="num">${x.n}</td></tr>`).join("")}</tbody></table>`;
|
||||
$("#tbl-first").innerHTML = `<table><thead><tr><th>Company · direction</th>${cols.map((c) => `<th class="num">${c}</th>`).join("")}<th class="num">Runs</th></tr></thead><tbody>${r.first_sighting.map((x) => ({ ...x, n: cols.reduce((t, c) => t + (x.colors[c] || 0), 0), gap: (x.colors.Unsure || 0) + (x.colors.Unknown || 0) })).filter((x) => x.n >= 3).map((x) => `<tr><td>${esc(x.key.replace("|", " · "))}</td>${cols.map((c) => { const n = x.colors[c] || 0; const off = n && POOL[x.key] && !POOL[x.key].includes(c); return `<td class="num" style="${off ? "color:var(--warn);font-weight:600" : n ? "" : "color:var(--faint)"}" title="${off ? "Outside the documented pool" : ""}">${n ? `${n}<span class="muted"> · ${pct(n / x.n, 0)}</span>` : "·"}</td>`; }).join("")}<td class="num">${x.n}${x.gap ? `<span class="muted" title="Riders who were not sure which dragon they saw, left out"> +${x.gap} unsure</span>` : ""}</td></tr>`).join("")}</tbody></table>`;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------ route table
|
||||
@@ -601,7 +602,7 @@
|
||||
$("#tbl-factors").innerHTML = `<table><thead><tr><th>${esc(labelFactor(state.fxFactor))}</th><th class="num">Hits/runs</th><th class="num">Rate</th><th class="num">95% CI</th><th class="num">OR vs rest</th><th class="num">p</th><th class="num">q</th></tr></thead><tbody>
|
||||
<tr><td><i>All</i></td><td class="num">${kn(ft.overall)}</td><td class="num">${pct(ft.overall.p)}</td><td class="num">${ci(ft.overall)}</td><td></td><td></td><td></td></tr>
|
||||
${rows.map((r) => `<tr class="${r.q < 0.05 ? "sig" : ""}${r.or === undefined ? " thin" : ""}"><td>${esc(r.level)}</td><td class="num">${kn(r)}</td><td class="num">${pct(r.p)}</td><td class="num">${ci(r)}</td><td class="num">${r.or !== undefined ? `${fmtOR(r.or)} <span class="muted">(${fmtOR(r.or_lo)}–${fmtOR(r.or_hi)})</span>` : "too few"}</td><td class="num">${fmtP(r.fisher_p)}</td><td class="num">${r.q !== undefined ? `<span class="qbadge${r.q < 0.05 ? " s" : ""}">${fmtP(r.q)}</span>` : ""}</td></tr>`).join("")}
|
||||
</tbody></table>`;
|
||||
</tbody></table>${ft.missing && ft.missing[state.fxFactor] ? `<p class="small muted">${ft.missing[state.fxFactor].toLocaleString()} runs with no usable answer to this question ("unsure", blank, or not asked on that version of the form) are left out of these comparisons rather than treated as a choice.</p>` : ""}`;
|
||||
forest($("#ch-factor"), rows.filter((r) => r.or !== undefined).map((r) => ({ label: r.level, or: r.or, lo: r.or_lo, hi: r.or_hi, q: r.q, p: undefined, n: r.n })), { labelW: 220 });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user