robust.lmer: Robust Estimation of Multilevel and Linear Mixed-Effects...

View source: R/robust.lmer.R

robust.lmerR Documentation

Robust Estimation of Multilevel and Linear Mixed-Effects Models

Description

This function estimates a multilevel and linear mixed-effects model based on a robust estimation method using the rlmer() function from the robustlmm package that down-weights observations depending on robustness weights computed by robustification of the scoring equations and an application of the Design Adaptive Scale (DAS) approach.

Usage

robust.lmer(model, method = c("DAStau", "DASvar"),setting = c("RSEn", "RSEa"),
            digits = 2, p.digits = 3, write = NULL, append = TRUE, check = TRUE,
            output = TRUE)

Arguments

model

a fitted model of class "lmerMod" or "lmerModLmerTest".

method

a character string indicating the method used for estimating theta and sigma, i.e., "DAStau" (default) for using numerical quadrature for computing the consistency factors and "DASvar" for computing the consistency factors using a direct approximation. Note that "DAStau" is slower than "DASvar" but yields more accurate results. However, complex models with correlated random effects with more than one correlation term can only estimated using "DASvar". See help page of the rlmer() function in the R package robustlmm for more details.

setting

a character string indicating the setting for the parameters used for computing the robustness weights, i.e., "RSEn" (default) and "RSEa" for higher asymptotic efficiency which results in lower robustness. See help page of the rlmer() function in the R package robustlmm for more details.

digits

an integer value indicating the number of decimal places to be used.

p.digits

an integer value indicating the number of decimal places to be used for displaying p-value.

write

a character string naming a file for writing the output into either a text file with file extension ".txt" (e.g., "Output.txt") or Excel file with file extension ".xlsx" (e.g., "Output.xlsx"). If the file name does not contain any file extension, an Excel file will be written.

append

logical: if TRUE (default), output will be appended to an existing text file with extension .txt specified in write, if FALSE existing text file will be overwritten.

check

logical: if TRUE (default), argument specification is checked.

output

logical: if TRUE (default), output is shown on the console.

Details

Function specification and Function Arguments

The function rlmer from the robustlmm package is specified much like the function lmer from the lme4 package, i.e., a formula object and data frame is specified as the first and second argument. However, the robust.lmer function requires a fitted "lmerMod" or "lmerModLmerTest" that is used to re-estimate the model using the robust estimation method. Note that the function rlmer provides the additional arguments rho.e, rho.b, rho.sigma.e, rho.sigma.b, rel.tol, max.iter, verbose, doFit, init, and initTheta that are not supported by the robust.lmer function. See help page of the rlmer() function in the R package robustlmm for more details.

Statistical Significance Testing

The function rlmer from the robustlmm package does not provide any degrees of freedom or significance values. When specifying a "lmerModLmerTest" object for the argument model, the robust.lmer function uses the Satterthwaite or Kenward-Roger degrees of freedom from the "lmerModLmerTest" object to compute significance values for the regression coefficients based on parameter estimates and standard error of the robust multilevel mixed-effects (see Sleegers et al. (2021).

Value

Returns an object of class misty.object, which is a list with following entries:

call

function call

type

type of analysis

model

object returned from the rlmer function

args

specification of function arguments

result

list with results, i.e., call for the the function call, randeff for the variance and correlation components, coef for the model coefficients, weights for the robustness weights, and and converg for the convergence check, i.e., 1 = model converged, 0 = model singular, and -1 model not converged.

Author(s)

Takuya Yanagida takuya.yanagida@univie.ac.at

References

Koller, M. (2016). robustlmm: An R Package for Robust Estimation of Linear Mixed-Effects Models. Journal of Statistical Software, 75(6), 1–24. https://doi.org/10.18637/jss.v075.i06

See Also

coeff.robust, summa

Examples

## Not run: 
# Load lme4, lmerTest, and misty package
misty::libraries(lme4, lmerTest, misty)

# Load data set "Demo.twolevel" in the lavaan package
data("Demo.twolevel", package = "lavaan")

#----------------------------------------------------------------------------
# Multilevel and Linear Mixed-Effects Model

# Cluster-mean centering, center() from the misty package
Demo.twolevel <- center(Demo.twolevel, x2, type = "CWC", cluster = "cluster")

# Grand-mean centering, center() from the misty package
Demo.twolevel <- center(Demo.twolevel, w1, type = "CGM", cluster = "cluster")

# Estimate two-level mixed-effects model
mod.lmer2 <- lmer(y1 ~ x2.c + w1.c + x2.c:w1.c + (1 + x2.c | cluster), data = Demo.twolevel)

# Example 1a: Default setting
mod.lmer2r <- robust.lmer(mod.lmer2)

# Example 1b: Extract robustness weights
mod.lmer2r$result$weight$iresid
mod.lmer2r$result$weight$iranef

#----------------------------------------------------------------------------
# Write Results

# Example 2a: Write results into a text file
robust.lmer(mod.lmer2, write = "Robust_lmer.txt", output = FALSE)

# Example 2b: Write results into a Excel file
robust.lmer(mod.lmer2, write = "Robust_lmer.xlsx", output = FALSE)

## End(Not run)

misty documentation built on Sept. 9, 2025, 5:23 p.m.

Related to robust.lmer in misty...