Skip to content

Commit

Permalink
started Ch 11 EOC, includes easy problems
Browse files Browse the repository at this point in the history
  • Loading branch information
benslack19 committed Jan 6, 2022
1 parent f0299b1 commit ac9a95b
Show file tree
Hide file tree
Showing 2 changed files with 377 additions and 58 deletions.
378 changes: 321 additions & 57 deletions Rethinking_2/Chp_11.ipynb

Large diffs are not rendered by default.

57 changes: 56 additions & 1 deletion Rethinking_2/End_of_chapter_problems/Chapter_11.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"For 11E1-E3, see page 337 of 2nd edition, Overthinking box.\n",
"\n",
"## 11E1. \n",
"\n",
"**If an event has probability 0.35, what are the log-odds of this event?**\n",
"\n",
"### Answer \n",
"For 11E1 and 11E2, see page 337 of 2nd edition, Overthinking box.\n",
"\n",
"\n",
"```\n",
"odds = p / (1 - p)\n",
Expand Down Expand Up @@ -128,6 +130,59 @@
"np.exp(3.2) / (1 + np.exp(3.2))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 11E3.\n",
"\n",
"**Suppose that a coefficient in a logistic regression has value 1.7. What does this imply about the proportional change in odds of the outcome?**\n",
"\n",
"### Answer\n",
"\n",
"After exponentiating the coefficient, this value represents the factor to multiply by the odds by when a 1 unit increase in the predictor variable occurs. In this problem, a coefficient of 1.7 means that the proportional odds with a 1 unit change leads to multiplying the odds by $\\text{exp}(1.7) \\approx 5.474$. It is important to emphasize that this is relative number.\n",
"\n",
"Standardizing the feature (if continuous) facilitiates interpretation; a 1 unit change in this case means 1 standard deviation change. If the variable is categorical and dummy-encoded, then 1 unit change represents the shift from the class assigned 0 to the class assigned 1."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"5.4739473917272"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.exp(1.7)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 11E4.\n",
"\n",
"**Why do Poisson regressions sometimes require the use of an offset? Provide an example.**\n",
"\n",
"### Answer\n",
"See 2nd edition, page 357, section 11.2.3.\n",
"\n",
"In Poisson regression, $\\lambda$ can be interpreted as the expected value of counts and as a rate with regards to time or distance. When seen as a rate, the unit for which the number of events are counted (the exposure) can vary.\n",
"\n",
"The book supposes two different monasteries, one tracking manuscripts over days while another is done over weeks. The log link helps us account for the differences in exposure.\n",
"\n",
"The monstary example involved an exposure involving time. Distance might be another exposure. Imagine two cars traveling down a road that are counting out-of-state license plates. One car might tabulate the number of cars every mile, while the other might keep track every kilometer. The use of an offset would be applicable in this case as well."
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down

0 comments on commit ac9a95b

Please sign in to comment.