Skip to content

Commit

Permalink
edits to Ch10
Browse files Browse the repository at this point in the history
  • Loading branch information
friendly committed Dec 18, 2024
1 parent 74c0c41 commit b1e9e25
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions 10-mlm-review.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -955,13 +955,15 @@ group minus the average of the other two, which is negative on `caring` and `emo
`group2` is the difference in means for the physical vs. mental groups.
Before doing multivariate tests, it is useful to see what would happen if we ran univariate ANOVAs on each
of the responses. These can be extracted from an MLM using `stats::summary.aov()`:
of the responses. These can be extracted from an MLM using `stats::summary.aov()` and they give tests
of the model terms for each response variable separately:
```{r parenting-summary-aov}
summary.aov(parenting.mlm)
```
If you like, you can also extract the univariate model fit statistics from the `"mlm"` object using the
`broom::glance()` method for a multivariate model object.
For a more condensed summary, you can instead extract the univariate model fit statistics from the `"mlm"` object using the
`heplots::glance()` method for a multivariate model object. The code below selects just the $R^2$ and
$F$-statistic for the overall model for each response, together with the associated $p$-value.
```{r}
glance(parenting.mlm) |>
Expand Down Expand Up @@ -1084,7 +1086,7 @@ or, expressed in terms of the variables,
\begin{eqnarray*}
\begin{bmatrix} y_{\text{anx}} \\y_{\text{dep}} \end{bmatrix} & = &
\begin{bmatrix} y_{\text{anx}} \\y_{\text{dep}} \end{bmatrix} & =
\begin{bmatrix} \beta_{0,\text{anx}} \\ \beta_{0,\text{dep}} \end{bmatrix} +
\begin{bmatrix} \beta_{1,\text{anx}} \\ \beta_{1,\text{dep}} \end{bmatrix} \text{grade} +
\begin{bmatrix} \beta_{2,\text{anx}} \\ \beta_{2,\text{dep}} \end{bmatrix} \text{grade}^2 \\
Expand All @@ -1101,11 +1103,7 @@ Some exploratory analysis is useful before fitting and visualizing models.
As a first step, we find the means, standard deviations, and standard errors of the means.
```{r addhealth-means}
#| code-fold: true
#| code-summary: Show the code
library(ggplot2)
library(dplyr)
#| code-fold: false
means <- AddHealth |>
group_by(grade) |>
summarise(
Expand Down Expand Up @@ -1171,7 +1169,7 @@ Now, let's fit the MLM for both responses jointly in relation to `grade`. The nu
$$
\HO : \mathbf{\mu}_7 = \mathbf{\mu}_8 = \cdots = \mathbf{\mu}_{12} \; ,
$$
or equivalently, that all coefficients except the intercept in the model \@ref(eq:AH-mod) are zero,
or equivalently, that all coefficients except the intercept in the model @eq-AH-mod are zero,
$$
\HO : \boldsymbol{\beta}_1 = \boldsymbol{\beta}_2 = \cdots = \boldsymbol{\beta}_5 = \boldsymbol{0} \; .
$$
Expand Down

0 comments on commit b1e9e25

Please sign in to comment.