Skip to content

Commit

Permalink
fix duncan-av-infl plot
Browse files Browse the repository at this point in the history
  • Loading branch information
friendly committed Jul 20, 2024
1 parent 52b2b1c commit d0f765d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions R/Duncan/Duncan-reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ avPlots(duncan.mod2,
duncan.mod2 <- update(duncan.mod,
subset = - whichNames(c("minister", "conductor"), Duncan))

duncan.mod2 <- update(duncan.mod, subset = -c(6, 16))

par(mar = c(4, 5, 4, 1)+.1,
mfrow = c(1,2))
res <- avPlot(duncan.mod, "income",
Expand Down
12 changes: 9 additions & 3 deletions child/06-leverage.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,16 @@ with(info, {
})
# line w/o the unusual points
duncan.mod2 <- update(duncan.mod,
subset = - whichNames(c("minister", "conductor"), Duncan))
duncan.mod2 <- update(duncan.mod, subset = -c(6, 16))
bs <- coef(duncan.mod2)["income"]
abline(a=0, b=bs, col = "red", lwd=2)
```

Duncan's hypothesis that the slopes for income and education were equal thus fails when these
two observations are deleted. The slope for income then becomes 2.6 times that of education.
```{r}
#| label: duncan.mod2
duncan.mod2 <- update(duncan.mod, subset = -c(6, 16))
coef(duncan.mod2)
```

2 changes: 1 addition & 1 deletion docs/03-multivariate_plots.html
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ <h1 class="title"><span id="sec-multivariate_plots" class="quarto-section-identi
<span><span class="fu"><a href="https://rdrr.io/r/graphics/lines.html">lines</a></span><span class="op">(</span><span class="va">axes.x</span>, <span class="va">axes.y</span>, col <span class="op">=</span> <span class="st">"grey"</span><span class="op">)</span></span>
<span><span class="fu"><a href="http://friendly.github.io/matlib/reference/vectors.html">vectors</a></span><span class="op">(</span><span class="va">P2</span>, labels <span class="op">=</span> <span class="va">labs</span>, cex.lab <span class="op">=</span> <span class="fl">1.8</span>, lwd <span class="op">=</span> <span class="fl">3</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/par.html">par</a></span><span class="op">(</span><span class="va">op</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details><div class="cell quarto-layout-panel" data-layout-align="center" data-layout-ncol="2">
</details><div class="cell quarto-layout-panel" data-layout-ncol="2" data-layout-align="center">

</div>
<div class="cell" data-layout-align="center">
Expand Down
10 changes: 7 additions & 3 deletions docs/06-linear_models-plots.html
Original file line number Diff line number Diff line change
Expand Up @@ -2124,13 +2124,17 @@ <h1 class="title"><span id="sec-linear-models-plots" class="quarto-section-ident
<span> <span class="op">}</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># line w/o the unusual points</span></span>
<span><span class="va">duncan.mod2</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/update.html">update</a></span><span class="op">(</span><span class="va">duncan.mod</span>, </span>
<span> subset <span class="op">=</span> <span class="op">-</span> <span class="fu"><a href="https://rdrr.io/pkg/car/man/which.names.html">whichNames</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="st">"minister"</span>, <span class="st">"conductor"</span><span class="op">)</span>, <span class="va">Duncan</span><span class="op">)</span><span class="op">)</span></span>
<span></span>
<span><span class="va">duncan.mod2</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/update.html">update</a></span><span class="op">(</span><span class="va">duncan.mod</span>, subset <span class="op">=</span> <span class="op">-</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">6</span>, <span class="fl">16</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="va">bs</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/coef.html">coef</a></span><span class="op">(</span><span class="va">duncan.mod2</span><span class="op">)</span><span class="op">[</span><span class="st">"income"</span><span class="op">]</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/graphics/abline.html">abline</a></span><span class="op">(</span>a<span class="op">=</span><span class="fl">0</span>, b<span class="op">=</span><span class="va">bs</span>, col <span class="op">=</span> <span class="st">"red"</span>, lwd<span class="op">=</span><span class="fl">2</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<p>Duncan’s hypothesis that the slopes for income and education were equal thus fails when these two observations are deleted. The slope for income then becomes 2.6 times that of education. ::: {.cell layout-align=“center”}</p>
<div class="sourceCode" id="cb59" data-code-line-numbers=""><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">duncan.mod2</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/update.html">update</a></span><span class="op">(</span><span class="va">duncan.mod</span>, subset <span class="op">=</span> <span class="op">-</span><span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span><span class="fl">6</span>, <span class="fl">16</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/stats/coef.html">coef</a></span><span class="op">(</span><span class="va">duncan.mod2</span><span class="op">)</span></span>
<span><span class="co">#&gt; (Intercept) income education </span></span>
<span><span class="co">#&gt; -6.409 0.867 0.332</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>:::</p>
<p><strong>Package summary</strong></p>
<div class="cell" data-layout-align="center">
<pre data-code-line-numbers=""><code>#&gt; Writing packages to C:/R/Projects/Vis-MLM-book/bib/pkgs.txt
Expand Down
2 changes: 1 addition & 1 deletion docs/search.json

Large diffs are not rendered by default.

0 comments on commit d0f765d

Please sign in to comment.