{ "cells": [ { "cell_type": "markdown", "id": "c91ffc89", "metadata": {}, "source": [ "# Tutorial Exercises\n", "\n", "We will be using the statsmodels package in Python, so we will need to import this along with the other Python packages we have been using.\n", "\n", "\n", "### Set up Python libraries\n", "\n", "As usual, run the code cell below to import the relevant Python libraries\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "1b642f8d", "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": "b6aa98d9", "metadata": {}, "source": [ "## Life satisfaction full dataset\n", "\n", "Let's import the full dataset for life satisfaction vs GDP" ] }, { "cell_type": "code", "execution_count": 19, "id": "4ee32dde", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Country | \n", "LifeSat | \n", "GDPpc | \n", "
---|---|---|---|
0 | \n", "Afghanistan | \n", "2.40 | \n", "1.97 | \n", "
1 | \n", "Albania | \n", "5.20 | \n", "13.19 | \n", "
2 | \n", "Algeria | \n", "5.12 | \n", "10.74 | \n", "
3 | \n", "American Samoa | \n", "NaN | \n", "0.00 | \n", "
4 | \n", "Andorra | \n", "NaN | \n", "0.00 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "
233 | \n", "Western Sahara | \n", "NaN | \n", "0.00 | \n", "
234 | \n", "World | \n", "NaN | \n", "16.19 | \n", "
235 | \n", "Yemen | \n", "4.20 | \n", "0.00 | \n", "
236 | \n", "Zambia | \n", "3.76 | \n", "3.28 | \n", "
237 | \n", "Zimbabwe | \n", "3.00 | \n", "3.35 | \n", "
238 rows × 3 columns
\n", "