Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
trying to do 3.10.8 and 3.10.6
  • Loading branch information
jeremyteitelbaum committed Apr 12, 2018
1 parent 8b47394 commit f8632e3
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions BDA 3.10.8.ipynb
@@ -0,0 +1,67 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Problem 3.10.8\n",
"\n",
"Analysis of proportions: a survey was done of bicycle and other vehicular traffic in the neighborhood of the campus of the University of California, Berkeley, in the spring of 1993. Sixty city blocks were selected at random; each block was observed for one hour, and the numbers of bicycles and other vehicles traveling along that block were recorded. The sampling was stratified into six types of city blocks: busy, fairly busy, and residential streets, with and without bike routes, with ten blocks measured in each stratum. Table 3.3 displays the number of bicycles and other vehicles recorded in the study. For this problem, restrict your attention to the first four rows of the table: the data on residential streets. \n",
"\n",
"(a) Let $y_1$ , . . . , $y_{10}$ and $z_1$ , . . . , $z_8$ be the observed proportion of traffic that was on bicycles in the residential streets with bike lanes and with no bike lanes, respectively (so $y_1 = 16/(16 + 58)$ and $z_1 = 12/(12 + 113)$, for example). Set up a model so that the $y_i$ ’s are independent and identically distributed given parameters $\\theta_y$ and the $z_i$ ’s are independent and identically distributed given parameters $\\theta_z$ . \n",
"\n",
"(b) Set up a prior distribution that is independent in $\\theta_y$ and $\\theta_z$ . \n",
"\n",
"(c) Determine the posterior distribution for the parameters in your model and draw 1000 simulations from the posterior distribution. (Hint: $\\theta_y$ and $\\theta_z$ are independent in the posterior distribution, so they can be simulated independently.) \n",
"\n",
"(d) Let $\\mu_y = E(y_i |\\theta_y )$ be the mean of the distribution of the $y_i$ ’s; $\\mu_y$ will be a function of $\\theta_y$. Similarly, define $\\mu_z$ . Using your posterior simulations from (c), plot a histogram of the posterior simulations of $\\mu_y-\\mu_z$, the expected difference in proportions in bicycle traffic on residential streets with and without bike lanes. We return to this example in Exercise 5.13.\n",
"\n",
"Gelman, Andrew; Carlin, John B.; Stern, Hal S.; Dunson, David B.; Vehtari, Aki; Rubin, Donald B.. Bayesian Data Analysis, Third Edition (Chapman & Hall/CRC Texts in Statistical Science) (Page 81). CRC Press. Kindle Edition. \n",
"\n",
"#### Data\n",
"|Type |Bike lane? |Counts of Bikes/others|\n",
"|--- |----------|----|\n",
"|Residential |yes |16/58, 9/90, 10/48, 13/57, 19/103, 20/57, 18/86, 17/112, 35/273, 55/64 |\n",
"|Residential |no |12/113, 1/18, 2/14, 4/44, 9/208, 7/67, 9/29, 8/154|\n",
"\n",
"Gelman, Andrew; Carlin, John B.; Stern, Hal S.; Dunson, David B.; Vehtari, Aki; Rubin, Donald B.. Bayesian Data Analysis, Third Edition (Chapman & Hall/CRC Texts in Statistical Science) (Page 81). CRC Press. Kindle Edition. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Probably best to first do 3.10.6\n",
"For that problem see the reference [Raftery, 1988](https://www.stat.washington.edu/raftery/Research/PDF/bka1988.pdf)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.6.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit f8632e3

Please sign in to comment.