{ "cells": [ { "cell_type": "markdown", "id": "627c4901", "metadata": {}, "source": [ "# ANOVA and Kruskal-Wallis in Python\n", "\n", "We’ll use the data from the chimps examples to demonstrate the python code. First, as usual, we’ll import the relevant packages and import the data as a `.csv` file. \n", "\n", "### Set up Python libraries\n", "\n", "As usual, run the code cell below to import the relevant Python libraries" ] }, { "cell_type": "code", "execution_count": 2, "id": "1f55cac1", "metadata": {}, "outputs": [], "source": [ "# Set-up Python libraries - you need to run this but you don't need to change it\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import scipy.stats as stats\n", "import pandas \n", "import seaborn as sns\n", "import statsmodels.api as sm\n", "import statsmodels.formula.api as smf" ] }, { "cell_type": "markdown", "id": "a311658a", "metadata": {}, "source": [ "### Import and view the data" ] }, { "cell_type": "code", "execution_count": 3, "id": "36563533", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | chimp | \n", "group | \n", "yawns | \n", "age3 | \n", "
---|---|---|---|---|
0 | \n", "13 | \n", "Baboons | \n", "2 | \n", "young | \n", "
1 | \n", "12 | \n", "Baboons | \n", "1 | \n", "young | \n", "
2 | \n", "14 | \n", "Baboons | \n", "1 | \n", "young | \n", "
3 | \n", "10 | \n", "Baboons | \n", "2 | \n", "middle | \n", "
4 | \n", "11 | \n", "Baboons | \n", "0 | \n", "old | \n", "
5 | \n", "15 | \n", "Control (human, no yawn) | \n", "0 | \n", "young | \n", "
6 | \n", "16 | \n", "Control (human, no yawn) | \n", "2 | \n", "young | \n", "
7 | \n", "19 | \n", "Control (human, no yawn) | \n", "1 | \n", "middle | \n", "
8 | \n", "18 | \n", "Control (human, no yawn) | \n", "0 | \n", "old | \n", "
9 | \n", "17 | \n", "Control (human, no yawn) | \n", "1 | \n", "old | \n", "
10 | \n", "4 | \n", "Familiar humans | \n", "5 | \n", "young | \n", "
11 | \n", "5 | \n", "Familiar humans | \n", "3 | \n", "middle | \n", "
12 | \n", "2 | \n", "Familiar humans | \n", "4 | \n", "middle | \n", "
13 | \n", "3 | \n", "Familiar humans | \n", "2 | \n", "old | \n", "
14 | \n", "1 | \n", "Familiar humans | \n", "3 | \n", "old | \n", "
15 | \n", "7 | \n", "Unfamiliar humans | \n", "3 | \n", "young | \n", "
16 | \n", "9 | \n", "Unfamiliar humans | \n", "5 | \n", "middle | \n", "
17 | \n", "6 | \n", "Unfamiliar humans | \n", "4 | \n", "middle | \n", "
18 | \n", "8 | \n", "Unfamiliar humans | \n", "3 | \n", "old | \n", "