Skip to content

Commit

Permalink
2201 fixed errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanrongen committed Jan 22, 2024
1 parent a99589d commit 0e6b1c5
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 24 deletions.

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions _site/materials/glm-practical-logistic-binary.html
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ <h1 class="title">
<div class="cell">
<div class="cell-output-display">
<div>
<figure class="figure"><p><img src="images/dgplots/2024_01_22-11-16-01_AM_dgplots.png" class="img-fluid figure-img" width="804"></p>
<figure class="figure"><p><img src="images/dgplots/2024_01_22-03-59-55_PM_dgplots.png" class="img-fluid figure-img" width="805"></p>
</figure>
</div>
</div>
Expand Down Expand Up @@ -749,7 +749,7 @@ <h1 class="title">
Link Function: Logit Scale: 1.0000
Method: IRLS Log-Likelihood: -4.5939
Date: Mon, 22 Jan 2024 Deviance: 9.1879
Time: 11:16:02 Pearson chi2: 15.1
Time: 15:59:56 Pearson chi2: 15.1
No. Iterations: 8 Pseudo R-squ. (CS): 0.7093
Covariance Type: nonrobust
==============================================================================
Expand Down Expand Up @@ -1212,7 +1212,7 @@ <h1 class="title">
Link Function: Logit Scale: 1.0000
Method: IRLS Log-Likelihood: -376.10
Date: Mon, 22 Jan 2024 Deviance: 752.20
Time: 11:16:06 Pearson chi2: 713.
Time: 16:00:00 Pearson chi2: 713.
No. Iterations: 4 Pseudo R-squ. (CS): 0.2238
Covariance Type: nonrobust
==============================================================================
Expand All @@ -1239,23 +1239,23 @@ <h1 class="title">
<div class="tab-content" data-group="language">
<div id="tabset-21-1" class="tab-pane active" role="tabpanel" aria-labelledby="tabset-21-1-tab">
<div class="cell">
<div class="sourceCode" id="cb51"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/Log.html">exp</a></span><span class="op">(</span><span class="op">-</span><span class="fl">5.61</span> <span class="op">+</span> <span class="fl">0.04</span> <span class="op">*</span> <span class="fl">150</span><span class="op">)</span> <span class="op">/</span> <span class="op">(</span><span class="fl">1</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/base/Log.html">exp</a></span><span class="op">(</span><span class="op">-</span><span class="fl">5.61</span> <span class="op">+</span> <span class="fl">0.04</span> <span class="op">*</span> <span class="fl">145</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="sourceCode" id="cb51"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/Log.html">exp</a></span><span class="op">(</span><span class="op">-</span><span class="fl">5.61</span> <span class="op">+</span> <span class="fl">0.04</span> <span class="op">*</span> <span class="fl">150</span><span class="op">)</span> <span class="op">/</span> <span class="op">(</span><span class="fl">1</span> <span class="op">+</span> <span class="fu"><a href="https://rdrr.io/r/base/Log.html">exp</a></span><span class="op">(</span><span class="op">-</span><span class="fl">5.61</span> <span class="op">+</span> <span class="fl">0.04</span> <span class="op">*</span> <span class="fl">150</span><span class="op">)</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 0.6685441</code></pre>
<pre><code>[1] 0.5962827</code></pre>
</div>
</div>
</div>
<div id="tabset-21-2" class="tab-pane" role="tabpanel" aria-labelledby="tabset-21-2-tab">
<div class="cell">
<div class="sourceCode cell-code" id="cb53"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb53-1"><a href="#cb53-1" aria-hidden="true" tabindex="-1"></a>math.exp(<span class="op">-</span><span class="fl">5.61</span> <span class="op">+</span> <span class="fl">0.04</span> <span class="op">*</span> <span class="dv">150</span>) <span class="op">/</span> (<span class="dv">1</span> <span class="op">+</span> math.exp(<span class="op">-</span><span class="fl">5.61</span> <span class="op">+</span> <span class="fl">0.04</span> <span class="op">*</span> <span class="dv">145</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="sourceCode cell-code" id="cb53"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb53-1"><a href="#cb53-1" aria-hidden="true" tabindex="-1"></a>math.exp(<span class="op">-</span><span class="fl">5.61</span> <span class="op">+</span> <span class="fl">0.04</span> <span class="op">*</span> <span class="dv">150</span>) <span class="op">/</span> (<span class="dv">1</span> <span class="op">+</span> math.exp(<span class="op">-</span><span class="fl">5.61</span> <span class="op">+</span> <span class="fl">0.04</span> <span class="op">*</span> <span class="dv">150</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>0.6685441044999503</code></pre>
<pre><code>0.5962826992967878</code></pre>
</div>
</div>
</div>
</div>
</div>
<p>This tells us that the probability of having a positive diabetes test result, given a glucose tolerance level of 150 is around 67%.</p>
<p>This tells us that the probability of having a positive diabetes test result, given a glucose tolerance level of 150 is around 60 %.</p>
</section>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions _site/search.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions materials/glm-practical-logistic-binary.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -747,17 +747,17 @@ Using the formula above, we can now calculate the probability of having a positi
## R

```{r}
exp(-5.61 + 0.04 * 150) / (1 + exp(-5.61 + 0.04 * 145))
exp(-5.61 + 0.04 * 150) / (1 + exp(-5.61 + 0.04 * 150))
```

## Python

```{python}
math.exp(-5.61 + 0.04 * 150) / (1 + math.exp(-5.61 + 0.04 * 145))
math.exp(-5.61 + 0.04 * 150) / (1 + math.exp(-5.61 + 0.04 * 150))
```
:::

This tells us that the probability of having a positive diabetes test result, given a glucose tolerance level of 150 is around 67%.
This tells us that the probability of having a positive diabetes test result, given a glucose tolerance level of 150 is around `r round(exp(-5.61 + 0.04 * 150) / (1 + exp(-5.61 + 0.04 * 150)) * 100)` %.

:::
:::
Expand Down
2 changes: 1 addition & 1 deletion materials/glm-practical-logistic-proportion.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Before we can make any firm conclusions, though, we need to check our model:
1- pchisq(12.633,20)
```

We get quite a high score (around 0.9) for this, which tells us that our goodness of fit is pretty good – our points are quite close to our curve, overall.
We get quite a high score (around 0.9) for this, which tells us that our goodness of fit is pretty rubbish – our points are not very close to our curve, overall.

Is the model any better than the null though?

Expand Down
5 changes: 4 additions & 1 deletion materials/glm-practical-poisson.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ To assess if the model is any good we’ll again use the residual deviance and t

:::

This gives a probability of `0.60`. This suggests that this model is actually a good one and that the data are pretty well supported by the model. For Poisson models this has an extra interpretation. This can be used to assess whether we have significant over-dispersion in our data.
This gives a probability of `0.60`. This suggests that this model is actually a reasonably decent one and that the data are pretty well supported by the model. For Poisson models this has an extra interpretation. This can be used to assess whether we have significant over-dispersion in our data.

For a Poisson model to be appropriate we need that the variance of the data to be exactly the same as the mean of the data. Visually, this would correspond to the data spreading out more for higher predicted values of `species.` However, we don’t want the data to spread out too much. If that happens then a Poisson model wouldn’t be appropriate.

Expand Down Expand Up @@ -317,6 +317,7 @@ Is the model well-specified?
1 - pchisq(850.41, 190)
```

This value indicates that the model is actually pretty good. Remember, it is between $[0, 1]$ and the closer to zero, the better the model.
:::

How about the overall fit?
Expand All @@ -328,6 +329,8 @@ How about the overall fit?
1 - pchisq(984.50 - 850.41, 191 - 190)
```

Again, this indicates that the model is markedly better than the null model.

:::

#### Plotting the regression
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0e6b1c5

Please sign in to comment.