{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Analyze Murdock (1962) Free Recall Data\n\nThis example demonstrates analyzing the classic Murdock (1962) free recall dataset,\nwhich established the serial position effect as a fundamental phenomenon in memory\nresearch. The dataset contains 90 subjects (15 per condition) across 6 experimental\nconditions varying in list length (10, 15, 20, 30, or 40 items) and presentation\nrate (1 or 2 sec/item). Each subject completed 80 lists.\n\nConditions:\n- LL10-2s: 10 items, 2 sec/item (15 subjects, 80 lists each)\n- LL15-2s: 15 items, 2 sec/item (15 subjects, 80 lists each)\n- LL20-1s: 20 items, 1 sec/item (15 subjects, 80 lists each)\n- LL20-2s: 20 items, 2 sec/item (15 subjects, 80 lists each)\n- LL30-1s: 30 items, 1 sec/item (15 subjects, 80 lists each)\n- LL40-1s: 40 items, 1 sec/item (15 subjects, 80 lists each)\n\nWe'll analyze recall performance using:\n1. Probability of First Recall (PFR) - probability of recalling each position first\n2. Lag-CRP - conditional recall probability by temporal lag\n3. Serial Position Curve (SPC) - recall probability by encoding position\n\nReference:\nMurdock, B. B. (1962). The serial position effect of free recall. Journal of\nExperimental Psychology, 64(5), 482-488. https://doi.org/10.1037/h0045106\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Code source: Contextual Dynamics Laboratory\n# License: MIT\n\nimport quail\nimport matplotlib.pyplot as plt\nimport warnings\n\n# Suppress RuntimeWarnings about empty slices\nwarnings.filterwarnings('ignore', category=RuntimeWarning)\n\n# Load the Murdock 1962 dataset\negg = quail.load_example_data('murd62')\n\nprint(f\"Loaded Murdock 1962 data: {egg.n_subjects} subjects, {egg.n_lists} lists per subject\")\n\n# Define conditions\nconditions = ['LL10-2s', 'LL15-2s', 'LL20-1s', 'LL20-2s', 'LL30-1s', 'LL40-1s']\n\n# Build subjgroup: map each subject index to its condition name\nsubjgroup = []\nfor subj_idx in range(egg.n_subjects):\n try:\n sample = egg.pres.loc[(subj_idx, 0)][0]\n if sample and 'condition' in sample:\n subjgroup.append(sample['condition'])\n else:\n subjgroup.append('Unknown')\n except (KeyError, IndexError, TypeError):\n subjgroup.append('Unknown')\n\nprint(f\"Subject conditions: {len(set(subjgroup))} unique conditions\")\n\n# Create listgroup for averaging across lists within each subject\nlistgroup = ['average'] * egg.n_lists\n\n# Create figure with 3 subplots in order: PFR, Lag-CRP, SPC\nfig, axes = plt.subplots(1, 3, figsize=(15, 5))\n\n# 1. Probability of First Recall - use quail's built-in plot with error bars\npfr = egg.analyze('pfr', listgroup=listgroup)\npfr.plot(ax=axes[0], subjgroup=subjgroup, plot_type='subject', legend=True)\n\n# 2. Lag-CRP - use quail's built-in plot with error bars (legend=False)\nlagcrp = egg.analyze('lagcrp', listgroup=listgroup)\nlagcrp.plot(ax=axes[1], subjgroup=subjgroup, plot_type='subject', legend=False)\n\n# 3. Serial Position Curve - use quail's built-in plot with error bars (legend=False)\nspc = egg.analyze('spc', listgroup=listgroup)\nspc.plot(ax=axes[2], subjgroup=subjgroup, plot_type='subject', legend=False)\n\n# Configure PFR plot\naxes[0].set_title('Probability of First Recall')\naxes[0].set_xlabel('Serial Position')\naxes[0].set_ylabel('Probability')\naxes[0].set_ylim([0, 0.6])\n\n# Configure Lag-CRP plot\naxes[1].set_title('Lag-CRP')\naxes[1].set_xlabel('Lag')\naxes[1].set_ylabel('Conditional Recall Probability')\naxes[1].set_xlim([-10, 10])\naxes[1].set_ylim([0, 0.5])\naxes[1].axvline(x=0, color='gray', linestyle='--', alpha=0.5)\n\n# Configure SPC plot\naxes[2].set_title('Serial Position Curve')\naxes[2].set_xlabel('Serial Position')\naxes[2].set_ylabel('Recall Probability')\naxes[2].set_ylim([0, 1])\n\nplt.tight_layout()\nplt.suptitle('Murdock (1962) Free Recall Data', y=1.02, fontsize=14)\nplt.savefig('murdock_analysis.png', dpi=150, bbox_inches='tight')\nplt.show()\n\nprint(\"\\nAnalysis complete! Saved plot to murdock_analysis.png\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.2" } }, "nbformat": 4, "nbformat_minor": 0 }