Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tjmahr/huttenlocher1991

Vocabulary growth in 22 infants (Huttenlocher et al., 1991)
https://github.com/tjmahr/huttenlocher1991

Last synced: about 1 month ago
JSON representation

Vocabulary growth in 22 infants (Huttenlocher et al., 1991)

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(tidyverse)
```

# huttenlocher1991

This package provides the vocabulary growth data from the following article:

> Huttenlocher, J., Haight, W., Bryk, A., Seltzer, M., & Lyons, T. (1991). Early
> vocabulary growth: Relation to language input and gender. *Developmental
> Psychology*, *27*(2), 236–248.

This dataset is useful educationally because it features longitudinal/repeated
measures growth data. It is also unusual because in the associated article, the
only fixed effect predictor for growth is quadratic time--that is, there are
no intercept or linear time terms.

I retrieved this data from the [HLM software's examples
page](https://ssicentral.com/index.php/products/hlm-general/hlm-examples/) and
created a .csv-file out of it.

## Installation

You can install the development version of huttenlocher1991 like so:

``` r
remotes::install_github("tjmahr/huttenlocher1991")
```

## Example

Here are the data all plotted.

```{r}
#| spag-1, fig.width = 3, fig.height = 2.5, dpi = 300, out.width = "50%"
library(huttenlocher1991)
library(tidyverse)

vocab_growth

ggplot(vocab_growth) +
aes(x = age, y = vocab) +
geom_line(aes(group = id))
```

Here is the "obvious" fully specified growth model.

```{r}
library(lme4)

m <- lmer(
vocab ~ age_12 + age_12_sq + (age_12 + age_12_sq | id),
vocab_growth
)
summary(m)
```

They note in footnote 2 that there was high collinearity between
π1*i* and π2*i* (the two random slopes) which we see
above.

They use a reduced quadratic model, which I think was basically:

```{r}
mr <- lmer(
vocab ~ 0 + age_12_sq + (0 + age_12_sq | id),
vocab_growth
)
summary(mr)
```

There is no intercept because at x = 0 (age = 12 months), vocabulary should be 0 (?).

If I include `group`, I can reproduce the coefficients from Table 1, which makes
me think I am on the right track.

```{r}
mr_group <- lmer(
vocab ~ 0 + age_12_sq + age_12_sq:group + (0 + age_12_sq | id),
vocab_growth
)
summary(mr_group)
```

Finally, we can recreate the figures:

```{r}
#| spag-2, fig.width = 3, fig.height = 2.5, dpi = 300, out.width = "50%"
library(broom.mixed)
data <- mr %>%
augment(newdata = vocab_growth)

ggplot(data %>% filter(id %in% c(11, 5, 7))) +
aes(x = age, y = vocab, shape = factor(id)) +
geom_point() +
geom_line(aes(y = .fitted, linetype = factor(id))) +
guides(shape = "none", linetype = "none") +
labs(x = "age [months]", y = "vocabulary")

knitr::include_graphics("man/figures/f1.png")
```

Excluding the intercept entirely reminded me of nonlinear models, so can we just
one of those?

```{r}
nform <- ~ beta * input ^ 2
nfun <- deriv(
nform,
namevec = "beta",
function.arg = c("input", "beta")
)

mr_nl <- nlmer(
vocab ~ nfun(age_12, beta) ~ beta | id,
data = vocab_growth,
start = c(beta = 0)
)

summary(mr_nl)

fixef(mr_nl)
fixef(mr)

VarCorr(mr_nl)
VarCorr(mr)
```