Description Usage Arguments Value Examples

This function is a wrapper for `lmer()`

to formulate a mixed-effects linear model based on user-supplied multi-level equations.
In addition to the output from `lmer()`

, `hlmer2()`

also provides estimates of ICC statistics, random-effect reliability estimates, confidence intervals for fixed effects, and chi-square tests for random-effects variance.
To ensure that a simplified model (e.g., an unconditional model) run with this function will be based on the same cases as a more complex model, supply a `model_type`

argument using the values outlined in the documentation for the `hlmer()`

function.
IMPORTANT: Unlike the `hlmer()`

function, this function requires that the user manually center predictors. To automate the centering process, see the `center_data()`

function.

1 2 3 |

`eq_lvl1` |
Regression equation (as a string) for level-1 models. Do not use parentheses in the model. When supplying an interaction between level-1 variables, use either "*" or ":" notation and manually supply the main effects. In the output, all within-level interactions will be indicated by a "_X_" symbol between the variables. |

`eq_lvl2` |
List of regression equations (as strings) for level-2 models, with outcomes labeled as "intercept" or as level-1 predictor names. If left NULL, random intercepts will be estimated, but all slopes will be treated as fixed effects.
To specify a fixed effect, simply omit the variable from the |

`cluster` |
Column label of |

`conf_level` |
Confidence level to use in constructing confidence bounds around fixed effects. |

`cred_level` |
Credibility level to use in constructing credibility bounds (ranges of plausible values for random coefficients) around random effects. |

`remove_missing` |
Logical scalar that determines whether cases with missing data should be omitted. |

`check_lvl1_variance` |
Logical scalar that determines whether clusters with no variance in level-1 predictors should be screened out. |

`data` |
Data frame, matrix, or tibble containing the data to use in the linear model. |

`...` |
Additional arugments to be passed to the |

Output from the `lmerTest::lmer()`

function augmented with ICC statistics, random-effects reliability estimates, confidence intervals for fixed effects, and chi-square tests for random-effects variance.

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 | ```
## Not run:
## Center the HSB database:
dat <- center_data(cluster = "ID", data = hsb)
## Unconditional model (Raudenbush and Bryk Table 4.2):
hlmer2(eq_lvl1 = "MATHACH ~ 1", cluster = "ID", data = dat)
## Means-as-outcomes model (Raudenbush and Bryk Table 4.3):
hlmer2(eq_lvl1 = "MATHACH ~ 1", eq_lvl2 = "intercept ~ MEANSES",
cluster = "ID", data = dat)
## Random-coefficients model (Raudenbush and Bryk Table 4.4):
hlmer2(eq_lvl1 = "MATHACH ~ SES_cwc",
eq_lvl2 = list("intercept ~ MEANSES", "SES_cwc ~ 1"),
cluster = "ID", data = dat)
## Slopes and intercepts as outcomes model (Raudenbush and Bryk Table 4.5):
hlmer2(eq_lvl1 = "MATHACH ~ SES_cwc",
eq_lvl2 = list("intercept ~ SECTOR + MEANSES", "SES_cwc ~ SECTOR + MEANSES"),
cluster = "ID", data = dat)
## For a more complex model, we can specify which level-2 predictors
## should be used to predict which level-1 random effects.
## In this TIMSS example, the level-1 predictor is "self_efy" and
## the level-2 predictors are "students" and "alg." If we want to
## predict level-1 intercepts using both level-2 predictors, but we
## only want to predict level-1 "self_efy" slopes using "students,"
## we can specify that with the following model:
##
hlmer2(eq_lvl1 = "scores ~ self_efy",
eq_lvl2 = list("intercept ~ alg + students", "self_efy ~ students"),
cluster = "idteach", data = timss)
## End(Not run)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.