Skip to content

Commit

Permalink
make titles and headings a consistent case
Browse files Browse the repository at this point in the history
  • Loading branch information
mccarthy-m-g committed Jun 4, 2024
1 parent d0180bd commit 6fe9ba6
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
14 changes: 7 additions & 7 deletions vignettes/articles/chapter-2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ In Section 2.1 Singer and Willett (2003) introduce two distinct formats of data

For this example we illustrate the difference between the two formats using the `deviant_tolerance_pl` and `deviant_tolerance_pp` data sets, which correspond to the adolescent tolerance of deviant behaviour data organized in the person-level and person-period formats, respectively.

### The Person-Level Data Set
### The person-Level data set

In the person-level format (also known as **wide** or **multivariate** format), each person has only one row of data and multiple columns containing data from each measurement occasion for any time-varying variables. This is demonstrated in the `deviant_tolerance_pl` data set, a person-level data frame with 16 rows and 8 columns:

Expand Down Expand Up @@ -76,7 +76,7 @@ deviant_tolerance_pl |>

Considered together, these disadvantages make the person-level format ill-suited for most longitudinal data analyses. Fortunately, each of the disadvantages of the person-level format can be addressed by a simple conversion to the person-period format.

### The Person-Period Data Set
### The person-period data set

In the person-period format (also known as **long** or **univariate** format), each person has one row of data for each measurement occasion, with a **participant identifier variable** for each person, and a **time-indicator variable** for each measurement occasion. In this format, time-invariant variables have identical values across each measurement occasion; whereas time-varying variables have potentially differing values. This is demonstrated in the `deviant_tolerance_pp` data set, a person-period data frame with 80 rows and 5 columns:

Expand Down Expand Up @@ -104,7 +104,7 @@ Indeed, most R functions are designed to work with data in the person-period for

Thus, the person-period format is simply a special case of the tidy data format, which distinguishes itself through its longitudinal nature and requirements for explicit participant identifier and time-indicator variables.

### Converting Between Person-Level and Person-Period Data Sets
### Converting between person-level and person-period data sets

Unfortunately, longitudinal data is often initially stored as a person-level data set, meaning that most real analyses will require at least a little tidying to get your data into a person-period format. There are a few reasons for this:

Expand Down Expand Up @@ -163,7 +163,7 @@ To learn more about the principles of tidy data and how pivoting works, see the

In Section 2.2 Singer and Willett (2003) use the `deviant_tolerance_pp` data set to demonstrate how the person-period format facilitates exploratory analyses that describe how individuals in the data set change over time, revealing the nature and idiosyncrasies of each person’s temporal pattern of change.

### Empirical Growth Plots
### Empirical growth plots

**Empirical growth plots** show, for each individual, the sequence of change in a time-varying variable. Here change can be evaluated in either absolute terms against the scale of the variable of interest, or in relative terms in comparison to other sample members. Singer and Willett (2003) identify several questions that are helpful to answer when examining empirical growth plots:

Expand Down Expand Up @@ -209,7 +209,7 @@ deviant_tolerance_pp |>
list_rbind()
```

### Using a Trajectory to Summarize Each Person’s Empirical Growth Record
### Using a trajectory to summarize each person's empirical growth record

Each person's empirical growth record can be summarized by applying two standardized approaches:

Expand All @@ -218,7 +218,7 @@ Each person's empirical growth record can be summarized by applying two standard

Singer and Willett (2003) recommend using both approaches---beginning with the nonparametric approach---as examining the smoothed trajectories will help you select a common functional form for the trajectories in the parametric approach.

#### The Nonparametric Approach
#### The nonparametric approach

The `stat_smooth()` function can be used to add a nonparametric smooth layer to the empirical growth record plot. The choice of a particular smoothing algorithm is primarily a matter of convenience, so we'll use the default loess smoother. The `span` argument controls the amount of smoothing for the default loess smoother---with smaller numbers producing wigglier lines and larger numbers producing smoother lines; here choose a value that creates a similar smooth to the textbook figure.

Expand All @@ -238,7 +238,7 @@ Singer and Willett (2003) recommend focusing on the elevation, shape, and tilt o

Answering the last question is particularly important, as it will help you select a common functional form for the trajectories in the parametric approach.

#### The Parametric Approach
#### The parametric approach

For the parametric approach, Singer and Willett (2003) suggest using the following three-step process:

Expand Down
12 changes: 6 additions & 6 deletions vignettes/articles/chapter-3.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ library(lme4)
library(broom.mixed)
```

## 3.1 What Is the Purpose of the Multilevel Model for Change?
## 3.1 What is the purpose of the multilevel model for change?

In Chapter 3 Singer and Willett (2003) develop and explain the **multilevel model for change** using a subset of data from Burchinal, Campbell, Bryant, Wasik, and Ramey (1997), who measured the effect of early educational intervention on cognitive performance in a sample of African-American children at ages 12, 18, and 24 months (i.e., 1.0, 1.5, and 2.0 years).

Expand Down Expand Up @@ -89,7 +89,7 @@ As Singer and Willett (2003) discuss, the kind of statistical model needed to re

Together, these two components form a **multilevel model** (also known as a **linear mixed-effects model** or **mixed model**) for change.

## 3.2 The Level-1 Submodel for Individual Change
## 3.2 The level-1 submodel for individual change

In Section 3.2 Singer and Willett (2003) introduce the level-1 component of the multilevel model for change: The **submodel for individual change**---also known as the **individual growth model**---which represents the individual change in the outcome variable that we expect will occur during each time period under study.

Expand Down Expand Up @@ -128,7 +128,7 @@ Here $\text{age}$ has been **centred** to $(\text{age} - 1)$ so that the model i

Finally, the model slope, $\pi_{1i}$, represents the true **rate of change** in the $i$th child's true $\text{cognitive_score}$ over time---in this case, their true *annual* rate of change.

### Relating the Level-1 Submodel to the Exploratory Methods of Chapter 2
### Relating the level-1 submodel to the exploratory methods of Chapter 2

Before fitting this model, we find it helpful to introduce Gelman and Hill's (2006) concepts of complete pooling, no pooling, and partial pooling in relation to the exploratory linear models we fit in Chapter 2 to summarize both average and individual patterns of change over time.

Expand Down Expand Up @@ -289,7 +289,7 @@ early_intervention_fit_1 |>
labs(linewidth = "trajectory")
```

## 3.3 The Level-2 Submodel for Systematic Interindividual Differences in Change
## 3.3 The level-2 submodel for systematic interindividual differences in change

In Section 3.3 Singer and Willett (2003) introduce the level-2 component of the multilevel model for change---the **submodel for systematic interindividual differences in change**---which is defined by four specific features:

Expand Down Expand Up @@ -342,7 +342,7 @@ $$
\end{align}
$$

## 3.4 Fitting the Multilevel Model for Change to Data
## 3.4 Fitting the multilevel model for change to data

Putting the level-1 and level-2 submodels together, our multilevel model for change for the `early_intervention` data looks like:

Expand Down Expand Up @@ -411,7 +411,7 @@ early_intervention_fit <- lmer(
summary(early_intervention_fit)
```

## 3.5 Examining Estimated Fixed Effects
## 3.5 Examining estimated fixed effects

In Section 3.5 Singer and Willett (2003) explain two ways to interpret the fixed effects estimates of the multilevel model for change:

Expand Down
24 changes: 12 additions & 12 deletions vignettes/articles/chapter-4.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ $$
}_{\text{Random Effects}}
$$

## 4.3 Methods of Estimation, Revisited
## 4.3 Methods of estimation, revisited

In Section 4.3 Singer and Willett (2003) discuss two methods of estimation available to frequentist multilevel models, which must be selected *before* fitting the model:

Expand All @@ -203,7 +203,7 @@ Because generalized least squares and maximum likelihood estimation use differen

Additionally, maximum likelihood estimation can be further distinguished into two types: **full** and **restricted**. As Singer and Willett (2003) explain, under **full maximum likelihood** (FML) the likelihood of the *sample data* is maximized, and goodness-of-fit statistics refer to the fit of the entire model (fixed and random effects); under **restricted maximum likelihood** (REML) the likelihood of the *sample residuals* is maximized, and goodness-of-fit statistics refer to the fit of only the random effects. Consequently, statistical tests comparing the goodness-of-fit statistics from FML models can be used to test hypotheses about either fixed or random effect parameters, whereas those from REML models can be used only to test hypotheses about random effect parameters.

## 4.4 First Steps: Fitting Two Unconditional Multilevel Models for Change
## 4.4 First steps: Fitting two unconditional multilevel models for change

In Section 4.4 Singer and Willett (2003) introduce a new **model building** workflow for the multilevel model for change that begins by fitting two unconditional multilevel models for change before including any substantive predictors:

Expand Down Expand Up @@ -314,7 +314,7 @@ model_B |>
labs(linewidth = "trajectory")
```

## 4.5 Practical Data Analytic Strategies for Model Building
## 4.5 Practical data analytic strategies for model building

In Section 4.5 Singer and Willett (2003) present their data analytic strategy for model building, which focuses on building a systematic sequence of models that, as a set, address your research questions in a meaningful way. They refer to this sequence as a **taxonomy of statistical models**, where:

Expand Down Expand Up @@ -477,7 +477,7 @@ alcohol_use_1_fits_r2 <- r2_yy |>
alcohol_use_1_fits_r2
```

### Interpreting Fitted Models
### Interpreting fitted models

To systematically compare fitted models---describing what happens as predictors are added and removed---Singer and Willett (2003) suggest placing them side-by-side in a table, which allows you to more easily inspect and compare estimated fixed effects, variance components, and goodness-of-fit statistics from one model to the next. We can construct such a table using the `modelsummary()` function from the **modelsummary** package. To better match the table in the text, we will set the table `output` to `"gt"` so we can post-process it using the **gt** package.

Expand Down Expand Up @@ -525,7 +525,7 @@ alcohol_use_1_fits |>
cols_hide(effect)
```

### Displaying Prototypical Change Trajectories
### Displaying prototypical change trajectories

In addition to numerical summaries, Singer and Willett (2003) suggest plotting fitted trajectories for **prototypical individuals** to describe the results of model fitting, with prototypical values of predictors selected using one or more of the following strategies:

Expand Down Expand Up @@ -583,7 +583,7 @@ prototypical_alcohol_use |>

Note that depending on the number of predictors across different models, it may be preferable to instead create separate plots (which could be later added together using the **patchwork** package).

## 4.6 Comparing Models Using Deviance Statistics
## 4.6 Comparing models using deviance statistics

In Section 4.6 Singer and Willett (2003) introduce the **deviance** statistic, which quantifies how much worse the current model fit is in comparison to a saturated model that fits the observed data perfectly by comparing log-likelihood statistics for the two models:

Expand All @@ -610,19 +610,19 @@ with(

Note that by default the `anova()` function will refit objects of class `merMod` with FML before comparing models if they have been estimated with REML to prevent the common mistake of inappropriately comparing REML-fitted models with different fixed effects, whose likelihoods are not directly comparable. For REML-fitted models with identical fixed effects and different random effects, the `refit` argument can be set to `FALSE` to directly compare the REML-fitted models.

## 4.7 Using Wald Statistics to Test Composite Hypotheses About Fixed Effects
## 4.7 Using Wald statistics to test composite hypotheses about fixed effects

This section is intentionally left blank.

## 4.8 Evaluating the Tenability of a Model’s Assumptions
## 4.8 Evaluating the tenability of a model's assumptions

In Section 4.8 Singer and Willett (2003) offer strategies for checking the following assumptions of the multilevel model for change:

1. The linear (or nonlinear) **functional form** of the hypothesized individual change trajectory seems reasonable for the observed data---there do not appear to be systematic deviations from linearity (or nonlinearity) across participants.
2. The level-1 and level-2 residuals are all **normally distributed**.
3. The level-1 and level-2 residuals have **equal variances** at each level of every predictor.

### Checking Functional Form
### Checking functional Form

The functional form assumption of the multilevel model for change can be assessed by inspecting "outcome versus predictors" plots at each level.

Expand Down Expand Up @@ -670,7 +670,7 @@ wrap_plots(alcohol_use_1_ovp) +
plot_layout(axes = "collect")
```

### Checking Normality
### Checking normality

The normality assumption of the multilevel model for change can be assessed by inspecting Q-Q plots of the level-1 and level-2 residuals, and also (optionally) with statistical tests of normality. The `check_normality()` function from the **performance** package can perform both of these tasks.

Expand Down Expand Up @@ -705,7 +705,7 @@ model_F |>
```
-->

### Checking Homoscedasticity
### Checking homoscedasticity

The homoscedasticity assumption of the multilevel model for change can be assessed by inspecting "residual versus predictors" plots at each level to see if residual variability is approximately equal at *every* predictor value.

Expand Down Expand Up @@ -749,7 +749,7 @@ alcohol_use_1_rvp <- map(
wrap_plots(alcohol_use_1_rvp) + plot_layout(axes = "collect")
```

## 4.9 Model-Based Estimates of the Individual Growth Parameters
## 4.9 Model-based estimates of the individual growth parameters

In Section 4.9 Singer and Willett (2003) discuss how to use **model-based estimates** to display individual growth trajectories, which are simply the partial pooling trajectories we previously discussed in Chapter 3.

Expand Down
8 changes: 4 additions & 4 deletions vignettes/articles/chapter-5.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ library(modelsummary)
library(gt)
```

## 5.1 Variably Spaced Measurement Occasions
## 5.1 Variably spaced measurement occasions

In Section 5.1 Singer and Willett (2003) demonstrate how you can fit the multilevel model for change for data with **variably spaced measurement occasions** using a subset of data from the Children of the National Longitudinal Study of Youth (US Bureau of Labor and Statistics), which measured changes in the reading subtest of the Peabody Individual Achievement Test (PIAT) in a sample of 89 African-American children across three waves around the ages of 6, 8, and 10.

Expand Down Expand Up @@ -128,7 +128,7 @@ reading_scores_fits |>

Comparing these models, we see that the `age` model fits the data better than the `age_group` model---with less unexplained variation in initial status and rates of change, and smaller AIC and BIC statistics.

## 5.2 Varying Numbers of Measurement Occasions
## 5.2 Varying numbers of measurement occasions

In Section 5.2 Singer and Willett (2003) demonstrate how you can fit the multilevel model for change for data with **varying numbers of measurement occasions** (i.e., unbalanced data) using a subset of data from the National Longitudinal Study of Youth tracking the labour market experiences of male high school dropouts (Murnane, Boudett, & Willett, 1999).

Expand Down Expand Up @@ -252,7 +252,7 @@ ggplot(prototypical_dropout_wages, aes(x = experience, y = log_wages)) +
coord_cartesian(ylim = c(1.6, 2.4))
```

### 5.2.2 Practical Problems That May Arise When Analyzing Unbalanced Data Sets
### 5.2.2 Practical problems that may arise when analyzing unbalanced data sets

The multilevel model may fail to converge or be unable to estimate one or more variance components for data sets that are severely unbalanced, or if too few people have enough waves of data. In Section 5.2.2 Singer and Willett (2003) discuss two strategies for addressing these problems:

Expand Down Expand Up @@ -326,7 +326,7 @@ dropout_wages_fits_subset |>
cols_hide(effect)
```

## 5.3 Time-Varying Predictors
## 5.3 Time-varying predictors

In Section 5.3 Singer and Willett (2003) demonstrate how to fit the multilevel model for change for data with **time-varying predictors** using a subset of data from Ginexi, Howe, and Caplan (2000), who measured changes in depressive symptoms after job loss in a sample of 254 recently unemployed men and women. Interviews were conducted in three waves at around 1, 5, and 12 months after job loss.

Expand Down
12 changes: 6 additions & 6 deletions vignettes/articles/chapter-6.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Chapter 6: Modeling Discontinuous and Nonlinear Change"
title: "Chapter 6: Modelling discontinuous and nonlinear change"
---

```{r, include = FALSE}
Expand Down Expand Up @@ -32,7 +32,7 @@ library(modelsummary)
library(gt)
```

## 6.1 Discontinuous Individual Change
## 6.1 Discontinuous individual change

In Section 6.1, Singer and Willett (2003) discuss strategies for fitting **discontinuous individual change trajectories** using a subset of data from the National Longitudinal Study of Youth tracking the labour market experiences of male high school dropouts (Murnane, Boudett, & Willett, 1999).

Expand Down Expand Up @@ -346,7 +346,7 @@ ggplot(prototypical_dropout_wages_F, aes(x = experience, y = log_wages)) +
facet_wrap(vars(highest_grade), labeller = label_both)
```

## 6.2 Using Transformations to Model Nonlinear Individual Change
## 6.2 Using transformations to model nonlinear individual change

In Section 6.2, Singer and Willett (2003) discuss strategies for transforming outcome and time-indicator variables to model **nonlinear individual change trajectories** using a subset of data from Curran, Stice, and Chassin (1997), who measured the relation between changes in alcohol use and changes in peer alcohol use over a 3-year period in a community-based sample of Hispanic and Caucasian adolescents.

Expand Down Expand Up @@ -504,7 +504,7 @@ Singer and Willett (2003) recommend using two approaches for selecting among com
- Examining empirical growth plots to identify the highest order polynomial change trajectory suggested by the data.
- Comparing goodness-of-fit statistics across a series of polynomial level-1 models.

### Using a polynomial trajectory to summarize each persons empirical growth record
### Using a polynomial trajectory to summarize each person's empirical growth record

We begin by examining empirical growth plots for a subset of children whose trajectories span the wide array of individual change patterns in the `externalizing_behaviour` data.

Expand Down Expand Up @@ -585,7 +585,7 @@ externalizing_behaviour_empgrowth +
)
```

### Testing Higher Order Terms in a Polynomial Level-1 Model
### Testing higher order terms in a polynomial level-1 model

To select a "final" polynomial trajectory, Singer and Willett (2003) suggest fitting a series of level-1 individual growth models of increasing polynomial complexity, stopping when goodness-of-fit statistics suggest there is no need to add further polynomial predictors to the model.

Expand Down Expand Up @@ -674,7 +674,7 @@ externalizing_behaviour_fits |>
tidy()
```

## 6.4 Truly Nonlinear Trajectories
## 6.4 Truly nonlinear trajectories

In Section 6.4, Singer and Willett (2003) discuss strategies for fitting **truly nonlinear change trajectories** using data from Tivnan (1980), who measured changes in cognitive growth over a three-week period in a sample of 17 first and second-graders. Childrens' cognitive growth was based on improvement in the number of moves completed in a two-person checkerboard game, Fox n' Geese, before making a catastrophic error.

Expand Down
2 changes: 1 addition & 1 deletion vignettes/articles/chapter-7.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Chapter 7: Examining the Multilevel Model's Error Covariance Structure"
title: "Chapter 7: Examining the multilevel model's error covariance structure"
---

```{r, include = FALSE}
Expand Down

0 comments on commit 6fe9ba6

Please sign in to comment.