{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ae6ff0cd",
   "metadata": {},
   "source": [
    "# Agresti exercises 11.11 and 11.21\n",
    "\n",
    "Import libraries:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b0736f24",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "import statsmodels.api as sm"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6cca0d6b",
   "metadata": {},
   "source": [
    "## Agresti exercise 11.11\n",
    "\n",
    "Import data (also available for download at the website):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56758c24",
   "metadata": {},
   "outputs": [],
   "source": [
    "crime = pd.read_csv(\"https://asta.math.aau.dk/datasets?file=Crime2.dat\", sep='\\s+')\n",
    "crime = crime[crime['State'] != 'DC']\n",
    "crime.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e9842b3",
   "metadata": {},
   "source": [
    "Start by making relevant plot(s)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a15ad65a",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Write plot command(s) here. "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bc14f552",
   "metadata": {},
   "source": [
    "Then fit the linear model in Python:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e84a117f",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Write commands here."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "621a354f",
   "metadata": {},
   "source": [
    "Now answer questions (a) - (e)\n",
    "\n",
    "For question (d) you can get the correlation matrix from:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2df05955",
   "metadata": {},
   "outputs": [],
   "source": [
    "crime_corr = crime.iloc[:, [1, 3, 5]].corr()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "31e8a20d",
   "metadata": {},
   "source": [
    "## Agresti exercise 11.21\n",
    "\n",
    "Fit the linear model in Python:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "97087a14",
   "metadata": {},
   "outputs": [],
   "source": [
    "## Write commands here"
   ]
  }
 ],
 "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.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
