-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path_sec_hers_lm_diagnostics_lm2.qmd
More file actions
56 lines (44 loc) · 1.34 KB
/
Copy path_sec_hers_lm_diagnostics_lm2.qmd
File metadata and controls
56 lines (44 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
::: notes
We repeat the same checks for the interaction model
(`hers_lm2`, @eq-hers-interact, fitted in @tbl-hers-lm2).
:::
#### Residuals vs fitted for `hers_lm2`
:::{#fig-hers-resid-fitted-lm2}
```{r}
#| code-fold: true
hers_diag2 <- hers_lm_data |>
dplyr::mutate(
.fitted = fitted(hers_lm2),
.resid = residuals(hers_lm2)
)
ggplot(hers_diag2, aes(x = .fitted, y = .resid)) +
geom_point(alpha = 0.3) +
geom_hline(yintercept = 0, linetype = "dashed") +
facet_wrap(~statins, labeller = label_both) +
xlab("Fitted values") +
ylab("Residuals") +
theme_bw()
```
Residuals vs fitted values for `hers_lm2` (interaction model)
:::
#### QQ plot for `hers_lm2`
:::{#fig-hers-qq-lm2}
```{r}
#| code-fold: true
ggplot(hers_diag2, aes(sample = .resid)) +
stat_qq() +
stat_qq_line() +
facet_wrap(~statins, labeller = label_both) +
theme_bw()
```
QQ plot of residuals for `hers_lm2` (interaction model)
:::
::: notes
The residual and QQ plots for the interaction model
(@fig-hers-resid-fitted-lm2, @fig-hers-qq-lm2)
look essentially identical to those for the parallel-planes model:
adding the age-BMI interaction barely changes the residual structure.
This similarity previews the model-selection result ---
the likelihood ratio test (@tbl-hers-lrt) shows the interaction
does not improve the fit enough to justify the extra parameter.
:::