{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Games–Howell in Python with statsmodels 0.15\n", "A reproducible notebook for the Salar Cafe step-by-step guide.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Setup\n", "Install packages with `python -m pip install -r requirements.txt` and place the CSV beside this notebook.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import math\n", "from pathlib import Path\n", "import numpy as np\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "from scipy import stats\n", "from statsmodels import __version__ as statsmodels_version\n", "from statsmodels.stats.oneway import anova_oneway\n", "from statsmodels.stats.multicomp import pairwise_tukeyhsd\n", "print(statsmodels_version)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Load and validate the data\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "order = ['Control','Video','Interactive','Tutoring']\n", "df = pd.read_csv('posthoc_training_scores.csv')\n", "df['group'] = pd.Categorical(df['group'], categories=order, ordered=True)\n", "display(df.head())\n", "display(df.groupby('group', observed=True)['score'].agg(['count','mean','std','median','min','max']))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. Variance diagnostic\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "arrays = [df.loc[df['group']==g, 'score'].to_numpy() for g in order]\n", "stats.levene(*arrays, center='median')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4. Standard and Welch ANOVA\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "classic = anova_oneway(df['score'], df['group'], use_var='equal')\n", "welch = anova_oneway(df['score'], df['group'], use_var='unequal')\n", "classic, welch\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 5. Tukey HSD and Games–Howell\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "tukey = pairwise_tukeyhsd(df['score'], df['group'], alpha=.05, use_var='equal')\n", "games_howell = pairwise_tukeyhsd(df['score'], df['group'], alpha=.05, use_var='unequal')\n", "display(tukey.summary_frame())\n", "display(games_howell.summary_frame())\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 6. Read the decision reversals\n", "In the supplied data, Control vs Video changes from Tukey non-significant to Games–Howell significant, while Video vs Interactive changes in the opposite direction.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 7. Continue with the full script\n", "The bundled `.py` file adds effect sizes, transparent Games–Howell verification, CSV exports, and all four figures used in the article.\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3" } }, "nbformat": 4, "nbformat_minor": 5 }