{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Bootstrap Tutorial\n", "\n", "This notebook contains a tutorial on how to use the bootstrap functionality provided by estimagic. We start with the simplest possible example of calculating standard errors and confidence intervals for an OLS estimator without as well as with clustering. Then we progress to more advanced examples.\n", "\n", "In the example here, we will work with the \"exercise\" example dataset taken from the seaborn library.\n", "\n", "The working example will be a linear regression to investigate the effects of exercise time on pulse." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import estimagic as em\n", "import numpy as np\n", "import pandas as pd\n", "import seaborn as sns\n", "import statsmodels.api as sm" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Prepare the dataset" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | id | \n", "diet | \n", "pulse | \n", "time | \n", "kind | \n", "constant | \n", "
---|---|---|---|---|---|---|
0 | \n", "1 | \n", "low fat | \n", "85 | \n", "1 | \n", "rest | \n", "1 | \n", "
1 | \n", "1 | \n", "low fat | \n", "85 | \n", "15 | \n", "rest | \n", "1 | \n", "
2 | \n", "1 | \n", "low fat | \n", "88 | \n", "30 | \n", "rest | \n", "1 | \n", "
3 | \n", "2 | \n", "low fat | \n", "90 | \n", "1 | \n", "rest | \n", "1 | \n", "
4 | \n", "2 | \n", "low fat | \n", "92 | \n", "15 | \n", "rest | \n", "1 | \n", "
\n", " | id | \n", "diet | \n", "pulse | \n", "time | \n", "kind | \n", "constant | \n", "
---|---|---|---|---|---|---|
88 | \n", "30 | \n", "no fat | \n", "111 | \n", "15 | \n", "running | \n", "1 | \n", "
87 | \n", "30 | \n", "no fat | \n", "99 | \n", "1 | \n", "running | \n", "1 | \n", "
88 | \n", "30 | \n", "no fat | \n", "111 | \n", "15 | \n", "running | \n", "1 | \n", "
34 | \n", "12 | \n", "low fat | \n", "103 | \n", "15 | \n", "walking | \n", "1 | \n", "
15 | \n", "6 | \n", "no fat | \n", "83 | \n", "1 | \n", "rest | \n", "1 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
78 | \n", "27 | \n", "no fat | \n", "100 | \n", "1 | \n", "running | \n", "1 | \n", "
77 | \n", "26 | \n", "no fat | \n", "143 | \n", "30 | \n", "running | \n", "1 | \n", "
87 | \n", "30 | \n", "no fat | \n", "99 | \n", "1 | \n", "running | \n", "1 | \n", "
29 | \n", "10 | \n", "no fat | \n", "100 | \n", "30 | \n", "rest | \n", "1 | \n", "
75 | \n", "26 | \n", "no fat | \n", "95 | \n", "1 | \n", "running | \n", "1 | \n", "
90 rows × 6 columns
\n", "