Conditional Lag-CRP

Compute Lag-CRP while selectively excluding transitions via a tabulation mask.

The conditional Lag-CRP extends the standard Lag-CRP by adding a _should_tabulate mask that controls which transitions are counted. When the mask is False for a recall event, the tabulator still updates internal state (availability, previous positions) but does not increment lag tallies. This is useful for excluding specific transitions (e.g., intrusions) while preserving correct availability tracking.

Workflow

Code
import os
import matplotlib.pyplot as plt
import warnings
from jaxcmr.analyses.conditional_crp import plot_crp
from jaxcmr.helpers import find_project_root, generate_trial_mask, load_data, save_figure

warnings.filterwarnings("ignore")
Code
data_path = "data/HealeyKahana2014.h5"
figure_dir = "results/figures"
figure_str = ""
ylim = None
trial_query = "data['listtype'] == -1"
Code
project_root = find_project_root()
figure_dir = os.path.join(project_root, figure_dir)
data_path = os.path.join(project_root, data_path)
data = load_data(data_path)
data["_should_tabulate"] = data["recalls"] > 0
trial_mask = generate_trial_mask(data, trial_query)
Code
plot_crp(data, trial_mask)
if ylim is not None:
    for ax in plt.gcf().axes:
        ax.set_ylim(ylim)
save_figure(figure_dir, figure_str)

Interpretation

Axes and patterns are identical to the standard Lag-CRP, but transitions where the mask is False are excluded from tallies.

  • Contiguity effect: peaks near lags \(\pm 1\).
  • Compare with standard CRP to assess how excluded transitions affect the shape.

API Details

Notebook parameters

  • data_path — path to an HDF5 file containing a RecallDataset.
  • figure_dir — directory for saving figures.
  • figure_str — base filename for the saved figure. Leave empty to display without saving.
  • ylim — y-axis limits as a tuple, or None for automatic scaling.
  • trial_query — a Python expression evaluated against the dataset to select trials.

The _should_tabulate mask is constructed in the load cell as data["recalls"] > 0 (excludes intrusions). Modify this expression to change which transitions are excluded.