Spaces:
Running
Anchor the simulated k range to the pilot instead of guessing it
Browse filesThe recovery numbers are a statement about the assumed parameter range as much
as about the design, and the range was guessed: k in 1..5, which implies people
work on about 80% of trials. The nine complete pilot sessions actually chose
work on 66% of SELF and 58% of OTHER trials, so real k is higher than that.
The difference is not cosmetic. Under the guessed range, k*E^2 cannot come near
the 8-credit gap between the top reward and rest, so two thirds of the design
sits at ceiling, k_self recovers at +0.25 over 24 trials and the self/other gap
at +0.09 -- which would read as "the design cannot measure the thing it exists
to measure". Under k_self 6 / k_other 9 / beta 0.6, which reproduces the pilot
choice rates (0.68 / 0.59 against 0.66 / 0.58), the R=6 trials become
informative and only R=10 stays near ceiling.
K_MAX moves 10 -> 20 to leave the squash room above k_other, with gradients
checked at the new values. The notebook now prints information per design cell
so where the R=10 trials stand is visible rather than inferred.
Files changed (2)
86 unmodified lines878889909192939 unmodified lines10310410510610710815 unmodified lines12412512612712812986 unmodified linesprint(f"{N_SUBJECTS} simulated participants; trial counts {TRIAL_COUNTS}")""")md("""## 1. Is the design informative before any fitting?Two things can make recovery fail for reasons that have nothing to do with the9 unmodified lines**Choice balance.** Information in a binary choice is $p(1-p)$, maximal at$p=0.5$ and vanishing at the extremes. A design that pins everyone at 0.02 or0.98 cannot recover anything, however many trials it has.""")code("""15 unmodified linesb = M.choice_balance(spec, true_demo, nt, np.random.default_rng(1))print(f"{nt:3d} trials mean P(work) {b['mean_p_work']:.2f} "f"range {b['min']:.2f}-{b['max']:.2f} saturated {b['frac_saturated']:.0%}")""")code("""86 unmodified lines878889909192939 unmodified lines10310410510610710810911011111211311411511611711815 unmodified lines13413513613713813914014114214314414514614714814915015115215315415515686 unmodified linesprint(f"{N_SUBJECTS} simulated participants; trial counts {TRIAL_COUNTS}")""")md(r"""## 1. Is the design informative before any fitting?Two things can make recovery fail for reasons that have nothing to do with the9 unmodified lines**Choice balance.** Information in a binary choice is $p(1-p)$, maximal at$p=0.5$ and vanishing at the extremes. A design that pins everyone at 0.02 or0.98 cannot recover anything, however many trials it has.**The assumed $k$ is anchored to the pilot, not guessed.** Every number below isa statement about the assumed parameter range as much as about the design, sothe range is pinned to data: the nine complete pilot sessions chose work on 66%of SELF and 58% of OTHER trials, and $k_{self}=6$, $k_{other}=9$, $\beta=0.6$reproduces that. An earlier version of this notebook guessed $k \in [1,5]$,which implies working on ~80% of trials — well above what the pilot shows — andunder that guess two-thirds of the design sits at ceiling and 24-trial recoverylooks hopeless. The per-cell information table below shows where the realdesign actually stands.""")code("""15 unmodified linesb = M.choice_balance(spec, true_demo, nt, np.random.default_rng(1))print(f"{nt:3d} trials mean P(work) {b['mean_p_work']:.2f} "f"range {b['min']:.2f}-{b['max']:.2f} saturated {b['frac_saturated']:.0%}")# Where the information actually is, cell by cell. p(1-p) is the Fisher# information of a binary choice, so a cell near 0 contributes nothing however# many times it is repeated.print("\ninformation per trial, p(1-p), at the median simulated participant:")ks, ko, bt = (float(np.median(true_demo[:, 0])), float(np.median(true_demo[:, 1])),float(np.median(true_demo[:, 2])))info_tbl = []for rew in M.REWARDS:for e in M.EFFORT_FRACS:for lbl, kk in (("SELF", ks), ("OTHER", ko)):p = 1 / (1 + np.exp(-bt * (rew - kk * e ** 2 - M.REST_CREDIT)))info_tbl.append({"reward": rew, "effort": e, "who": lbl,"p_work": p, "info": p * (1 - p)})info_df = pd.DataFrame(info_tbl)print(info_df.pivot_table(index=["reward", "effort"], columns="who",values="info").round(3).to_string())""")code("""
41 unmodified lines424344454647484950515290 unmodified lines1431441451461471481491502 unmodified lines15315415515615715841 unmodified lines#: Squash ranges. k * E**2 must be able to both undercut and overtake the#: reward-minus-rest gap (1 to 8 credits) or choices carry no information about#: k; with E**2 in 0.12..0.64, k up to 10 spans that comfortably. beta is on a#: value scale of a few credits, so 3 is already very deterministic.K_MAX = 10.0BETA_MAX = 3.0#: The eight models, as (n_k, n_beta, exponent).MODELS = {f"{nk}k{nb}b_{'par' if p == 2 else 'lin'}": (nk, nb, p)90 unmodified lines# --- true parameters for simulation -----------------------------------------def draw_true(spec, n_subjects, rng, k_lo=1.0, k_hi=5.0, b_lo=0.5, b_hi=1.5,k_gap=1.5):"""Plausible true parameters.SELF and OTHER k are drawn with OTHER shifted up by `k_gap` on average --2 unmodified linesall would make the 2k models unidentifiable by construction and the modelrecovery meaningless."""nk, nb, _ = speccols = []k_self = rng.uniform(k_lo, k_hi, n_subjects)41 unmodified lines42434445464748495051525354555657585960616263646590 unmodified lines1561571581591601611621632 unmodified lines16616716816917017117217317417517617741 unmodified lines#: Squash ranges. k * E**2 must be able to both undercut and overtake the#: reward-minus-rest gap (1 to 8 credits) or choices carry no information about#: k. With E**2 in 0.12..0.64 that needs k well above 10, so the ceiling is 20.K_MAX = 20.0BETA_MAX = 3.0#: Default true-parameter range, ANCHORED TO THE PILOT rather than guessed.#: The nine complete pilot sessions chose work on 66% of SELF and 58% of OTHER#: trials. k_self 6 / k_other 9 / beta 0.6 reproduces that (0.68 / 0.59).#:#: This matters more than it looks. An earlier version of this file guessed k in#: 1..5, which implies people work on ~80% of trials -- well above what the#: pilot actually shows. Under that guess two thirds of the design sits at#: ceiling and 24-trial recovery looks hopeless; under the pilot-anchored range#: only the R=10 trials do. The recovery numbers are a statement about the#: assumed k as much as about the design, so the assumption is pinned to data.K_LO, K_HI = 3.0, 9.0K_GAP = 3.0BETA_LO, BETA_HI = 0.4, 0.9#: The eight models, as (n_k, n_beta, exponent).MODELS = {f"{nk}k{nb}b_{'par' if p == 2 else 'lin'}": (nk, nb, p)90 unmodified lines# --- true parameters for simulation -----------------------------------------def draw_true(spec, n_subjects, rng, k_lo=None, k_hi=None, b_lo=None, b_hi=None,k_gap=None):"""Plausible true parameters.SELF and OTHER k are drawn with OTHER shifted up by `k_gap` on average --2 unmodified linesall would make the 2k models unidentifiable by construction and the modelrecovery meaningless."""k_lo = K_LO if k_lo is None else k_lok_hi = K_HI if k_hi is None else k_hib_lo = BETA_LO if b_lo is None else b_lob_hi = BETA_HI if b_hi is None else b_hik_gap = K_GAP if k_gap is None else k_gapnk, nb, _ = speccols = []k_self = rng.uniform(k_lo, k_hi, n_subjects)