From b1e9e259974e848f6b2722f25d2b86a1bc855247 Mon Sep 17 00:00:00 2001 From: Michael Friendly Date: Wed, 18 Dec 2024 17:31:53 -0500 Subject: [PATCH] edits to Ch10 --- 10-mlm-review.qmd | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/10-mlm-review.qmd b/10-mlm-review.qmd index cab3d3d..85d3916 100644 --- a/10-mlm-review.qmd +++ b/10-mlm-review.qmd @@ -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) |> @@ -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 \\ @@ -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( @@ -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} \; . $$