\n",
+ " "
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Sampling 2 chains for 1_000 tune and 1_000 draw iterations (2_000 + 2_000 draws total) took 3 seconds.\n"
+ ]
+ }
+ ],
+ "source": [
+ "priors = {\n",
+ " \"h0\": bmb.Prior(\"Lognormal\", mu=0, sigma=0.2),\n",
+ " \"h0:treatment\": bmb.Prior(\"Normal\", mu=0, sd=0.5),\n",
+ " \"sigma\": bmb.Prior(\"Exponential\", lam=1),\n",
+ "}\n",
+ "model_6_8 = bmb.Model(\"h1 ~ 0 + h0 + h0:treatment\", d, priors=priors)\n",
+ "results_6_8 = model_6_8.fit()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Code 7.25"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "Computed from 2000 by 100 log-likelihood matrix\n",
+ "\n",
+ " Estimate SE\n",
+ "deviance_waic 321.09 12.22\n",
+ "p_waic 3.73 -\n",
+ "\n",
+ "There has been a warning during the calculation. Please check the results."
+ ]
+ },
+ "execution_count": 29,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "az.waic(results_6_7, scale = \"deviance\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Code 7.26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:146: UserWarning: The default method used to estimate the weights for each model,has changed from BB-pseudo-BMA to stacking\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
rank
\n",
+ "
waic
\n",
+ "
p_waic
\n",
+ "
d_waic
\n",
+ "
weight
\n",
+ "
se
\n",
+ "
dse
\n",
+ "
warning
\n",
+ "
waic_scale
\n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
model_6_7
\n",
+ "
0
\n",
+ "
321.094660
\n",
+ "
3.733966
\n",
+ "
0.000000
\n",
+ "
1.000000e+00
\n",
+ "
12.218020
\n",
+ "
0.000000
\n",
+ "
True
\n",
+ "
deviance
\n",
+ "
\n",
+ "
\n",
+ "
model_6_8
\n",
+ "
1
\n",
+ "
376.411366
\n",
+ "
3.221266
\n",
+ "
55.316706
\n",
+ "
0.000000e+00
\n",
+ "
14.339417
\n",
+ "
11.273896
\n",
+ "
True
\n",
+ "
deviance
\n",
+ "
\n",
+ "
\n",
+ "
model_6_6
\n",
+ "
2
\n",
+ "
384.832482
\n",
+ "
2.265256
\n",
+ "
63.737822
\n",
+ "
8.302248e-13
\n",
+ "
15.524433
\n",
+ "
13.298590
\n",
+ "
True
\n",
+ "
deviance
\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " rank waic p_waic d_waic weight se \\\n",
+ "model_6_7 0 321.094660 3.733966 0.000000 1.000000e+00 12.218020 \n",
+ "model_6_8 1 376.411366 3.221266 55.316706 0.000000e+00 14.339417 \n",
+ "model_6_6 2 384.832482 2.265256 63.737822 8.302248e-13 15.524433 \n",
+ "\n",
+ " dse warning waic_scale \n",
+ "model_6_7 0.000000 True deviance \n",
+ "model_6_8 11.273896 True deviance \n",
+ "model_6_6 13.298590 True deviance "
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "compare_df = az.compare(\n",
+ " {\n",
+ " \"model_6_6\": results_6_6,\n",
+ " \"model_6_7\": results_6_7,\n",
+ " \"model_6_8\": results_6_8,\n",
+ " },\n",
+ " ic=\"waic\",\n",
+ " scale=\"deviance\",\n",
+ ")\n",
+ "compare_df"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Code 7.27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 31,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "array(11.27389615)"
+ ]
+ },
+ "execution_count": 31,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "waic_m_6_7 = az.waic(results_6_7, pointwise=True, scale=\"deviance\")\n",
+ "waic_m_6_8 = az.waic(results_6_8, pointwise=True, scale=\"deviance\")\n",
+ "\n",
+ "# pointwise values are stored in the waic_i attribute.\n",
+ "diff_m_6_7_m_6_8 = waic_m_6_7.waic_i - waic_m_6_8.waic_i\n",
+ "\n",
+ "n = len(diff_m_6_7_m_6_8)\n",
+ "\n",
+ "np.sqrt(n * np.var(diff_m_6_7_m_6_8)).values"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Code 7.28\n",
+ "\n",
+ "We use the values from our models, 11.27 for the standard error and 55.35 for the difference between the WAIC of the two models."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "array([26.018, 84.622])"
+ ]
+ },
+ "execution_count": 32,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "55.32 + np.array([-1, 1]) * 11.27 * 2.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAmMAAAE3CAYAAADmP0YBAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAzKElEQVR4nO3deVSV5d7/8Q/IoMYog6Z1UCl24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3r17W7dfuHChwnm9vLwkSRkZGWrSpMkV+93d3eXg4KAnn3xSffr0uWK/v79/hR8TQM2gGQNQ7+Tm5mrevHkKCAhQSEiIHBwc9M4776hx48bW6cHSNGjQQHfddZfWrVsnV1dXeXh4qFevXlc9/tKo1qVRLkn67bfftGPHjgqv3+rUqZMaNmyo1atXa+rUqVfsb9y4sTp27KiDBw/qySefrNC1AZiLZgxAnVZUVKSdO3dKks6ePas9e/bovffe0/nz57V06VI1aNBAPXv2VGhoqMaMGaOHH35YN910k86cOaOffvpJ+fn5evrpp63XGzBggJYvX653331X/fv3L9FoXa5169Zq1qyZXn75ZUVHR+vs2bNasGBBpUapPDw89Pjjj+uf//ynCgoK1Lt3b128eFGff/65nnzySTVt2lSTJ0/W6NGj5ejoqDvvvFPXXXedjh8/rk2bNumpp55Sq1atKvy4AKofzRiAOi0vL08jRoyQg4OD3Nzc9Je//EWDBg1SZGSkdf2Vg4ODXn/9dS1atEj/+te/dPz4cXl6euqWW25RVFRUiet16dJF119/vY4fP66BAweW+dguLi5KSEjQ7NmzNWHCBDVr1kyPPfaYvv32W/38888V/l4effRReXp6atmyZfqf//kfeXp6qmvXrrruuuskSV27dtWKFSu0YMECPfPMMyouLlbz5s3Vq1cv+fr6VvjxANQM7sAPAABgIm5tAQAAYCKaMQAAABPRjAEAAJiIZgwAAMBENGMAAAAmohkDAAAwEc0YAACAiWjGAAAATEQzBgAAYCKaMQAAABPRjAEAAJjo/wEmHrfFwM5pcwAAAABJRU5ErkJggg==\n",
+ "text/plain": [
+ "
"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "az.plot_compare(compare_df);"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Code 7.30"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 34,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "array(6.39613523)"
+ ]
+ },
+ "execution_count": 34,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "waic_m_6_6 = az.waic(results_6_6, pointwise=True, scale=\"deviance\")\n",
+ "diff_m6_6_m6_8 = waic_m_6_6.waic_i - waic_m_6_8.waic_i\n",
+ "n = len(diff_m6_6_m6_8)\n",
+ "np.sqrt(n * np.var(diff_m6_6_m6_8)).values"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Code 7.31\n",
+ "\n",
+ "dSE is calculated by compare above, but rethinking produces a pairwise comparison. This is not implemented in arviz, but we can hack it together:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 35,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:146: UserWarning: The default method used to estimate the weights for each model,has changed from BB-pseudo-BMA to stacking\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:146: UserWarning: The default method used to estimate the weights for each model,has changed from BB-pseudo-BMA to stacking\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n",
+ "/home/tomas/anaconda3/envs/bmb/lib/python3.8/site-packages/arviz/stats/stats.py:1406: UserWarning: For one or more samples the posterior variance of the log predictive densities exceeds 0.4. This could be indication of WAIC starting to fail. \n",
+ "See http://arxiv.org/abs/1507.04544 for details\n",
+ " warnings.warn(\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
\n",
+ "
model_6_7
\n",
+ "
model_6_8
\n",
+ "
\n",
+ " \n",
+ " \n",
+ "
\n",
+ "
model_6_8
\n",
+ "
11.273896
\n",
+ "
0.000000
\n",
+ "
\n",
+ "
\n",
+ "
model_6_6
\n",
+ "
13.298590
\n",
+ "
6.396135
\n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " model_6_7 model_6_8\n",
+ "model_6_8 11.273896 0.000000\n",
+ "model_6_6 13.298590 6.396135"
+ ]
+ },
+ "execution_count": 35,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "dataset_dict = {\"model_6_6\": results_6_6, \"model_6_7\": results_6_7, \"model_6_8\": results_6_8}\n",
+ "\n",
+ "# compare all models\n",
+ "s0 = az.compare(dataset_dict, ic=\"waic\", scale=\"deviance\")[\"dse\"]\n",
+ "# the output compares each model to the 'best' model - i.e. two models are compared to one.\n",
+ "# to complete a pair-wise comparison we need to compare the remaining two models.\n",
+ "\n",
+ "# to do this, remove the 'best' model from the input data\n",
+ "del dataset_dict[s0.index[0]]\n",
+ "\n",
+ "# re-run compare with the remaining two models\n",
+ "s1 = az.compare(dataset_dict, ic=\"waic\", scale=\"deviance\")[\"dse\"]\n",
+ "\n",
+ "# s0 compares two models to one model, and s1 compares the remaining two models to each other\n",
+ "# now we just nee to wrangle them together!\n",
+ "\n",
+ "# convert them both to dataframes, setting the name to the 'best' model in each `compare` output.\n",
+ "# (i.e. the name is the model that others are compared to)\n",
+ "df_0 = s0.to_frame(name=s0.index[0])\n",
+ "df_1 = s1.to_frame(name=s1.index[0])\n",
+ "\n",
+ "# merge these dataframes to create a pairwise comparison\n",
+ "pd.merge(df_0, df_1, left_index=True, right_index=True)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "#### Code 7.32"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 36,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def standardize(x):\n",
+ " return (x - np.mean(x)) / np.std(x)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 37,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "d = pd.read_csv(\"data/WaffleDivorce.csv\")\n",
+ "d[\"A\"] = standardize(d[\"MedianAgeMarriage\"])\n",
+ "d[\"D\"] = standardize(d[\"Divorce\"])\n",
+ "d[\"M\"] = standardize(d[\"Marriage\"])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 38,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "Auto-assigning NUTS sampler...\n",
+ "Initializing NUTS using jitter+adapt_diag...\n",
+ "Multiprocess sampling (2 chains in 2 jobs)\n",
+ "NUTS: [D_sigma, A, Intercept]\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ "