Description Usage Arguments Value Examples

This function is a wrapper for `lmer()`

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

, `hlmer()`

also provides estimates of ICC statistics, random-effect reliability estimates, confidence intervals for fixed effects, and chi-square tests for random-effects variance.
A key feature of `hlmer()`

is that it can automate the process of centering predictors and creating variables from the cluster means of level-1 predictors to be included in level 2 of the model.
The `model_type`

argument can be used to specify one of four pre-formatted types of models (using arguments of 1, 2, 3, or 4) or to compute the complete model implied by other arguments (using a 0 argument).
Variables that are cluster-mean centered within this function will be labeled with a "cwc" suffix (abbreviation for centered within cluster) and
variables that are grand-mean centered within this function will be labeled with a "cgm" suffix (abbreviation for centered grand mean).

1 2 3 4 5 |

`y_lvl1` |
Column label of |

`cluster` |
Column label of |

`x_lvl1` |
Column label(s) of |

`x_lvl2` |
Column label(s) of |

`y_lvl2` |
Optional list of level-1 statistics to be explained by level-2 predictors. Acceptable inputs are a scalar value of "all" (indicates that all level 2 predictors should be used to predict all random effects),
"intercepts" (indicates that all level 2 predictors should be used to predict random intercepts),
"slopes" (indicates that all level 2 predictors should be used to predict all random slopes),
or a list of vectors naming "Intercept" and/or |

`fixed_lvl1` |
Logical scalar or vector indicating which of the |

`center_lvl1` |
Optional vector identifying the types of mean centering procedures to be applied to the |

`center_lvl2` |
Vector or scalar identifying the types of mean centering procedures to be applied to the |

`y_lvl1means` |
Optional list of level-1 statistics to be explained by level-1 predictor mean values (only relevant when one or more level-1 predictors are cluster-mean centered). Acceptable formats for this argument are the same as for |

`center_lvl1means` |
Vector or scalar identifying the types of mean centering procedures to be applied to the means 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. |

`model_type` |
Numeric scalar indicating which of the following model types to run:
(0) the complete model implied by the supplied arguments (default),
(1) unconditional model (i.e,. random-effects ANOVA),
(2) means-as-outcomes model (requrires that at least one level-2 predictor is available, either from specification using the |

`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 35 36 37 | ```
## Not run:
## Unconditional model (Raudenbush and Bryk Table 4.2):
hlmer(y_lvl1 = "MATHACH", cluster = "ID", model_type = 1, data = hsb)
## Means-as-outcomes model (Raudenbush and Bryk Table 4.3):
hlmer(y_lvl1 = "MATHACH", cluster = "ID", x_lvl2 = "MEANSES",
y_lvl2 = "intercepts", model_type = 2, data = hsb)
## Random-coefficients model (Raudenbush and Bryk Table 4.4):
hlmer(y_lvl1 = "MATHACH", cluster = "ID", x_lvl1 = "SES",
center_lvl1 = "cluster", model_type = 3, data = hsb)
## Slopes and intercepts as outcomes model (Raudenbush and Bryk Table 4.5):
hlmer(y_lvl1 = "MATHACH", cluster = "ID", x_lvl1 = "SES",
x_lvl2 = "SECTOR", center_lvl1 = "cluster", y_lvl2 = "all",
y_lvl1means = "all", model_type = 4, data = hsb)
## 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 by passing a list to "y_lvl2" of the form:
##
## y_lvl2 = list(students = c("Intercept", "self_efy"),
## alg = "Intercept")
##
## This tells the program exactly which random effects to explain:
hlmer(y_lvl1 = "scores", cluster = "idteach",
x_lvl1 = "self_efy", x_lvl2 = c("students", "alg"),
center_lvl1 = "cluster", center_lvl2 = TRUE,
y_lvl2 = list(students = c("Intercept", "self_efy"),
alg = "Intercept"),
y_lvl1means = "intercepts", 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.