cluster_im_lmRob {mmiCATs}R Documentation

Cluster-Adjusted Confidence Intervals And p-Values Robust Linear Models

Description

Performs cluster-adjusted inference on a robust linear model object, using robust linear regression within each cluster. This function is designed to handle models where observations are clustered, and standard errors need to be adjusted to account for this clustering. The function applies a robust linear regression model to each cluster and then aggregates the results.

Usage

cluster_im_lmRob(
  robmod,
  formula,
  dat,
  cluster,
  ci.level = 0.95,
  drop = TRUE,
  return.vcv = FALSE,
  engine = "robust",
  ...
)

Arguments

robmod

A robust linear model object created using robust::lmRob() or robustbase::lmrob().

formula

A formula or a string that can be coerced to a formula.

dat

A data frame containing the data used in the model.

cluster

A formula indicating the clustering variable in dat.

ci.level

Confidence level for the confidence intervals, default is 0.95.

drop

Logical; if TRUE, drops clusters where the model does not converge.

return.vcv

Logical; if TRUE, the variance-covariance matrix of the cluster-averaged coefficients will be returned.

engine

Set the engine to "robust" to use robust::lmRob() or "robustbase" to use robustbase::lmrob(). Default is "robust".

...

Additional arguments to be passed to the robust::lmRob() or the robustbase::lmrob() function.

Value

A list containing the following elements:

p.values

A matrix of p-values for each independent variable.

ci

A matrix with the lower and upper bounds of the confidence intervals for each independent variable.

vcv.hat

The variance-covariance matrix of the cluster-averaged coefficients, returned if return.vcv is TRUE.

beta.bar

The cluster-averaged coefficients, returned if return.vcv is TRUE.

Examples

form <- Sepal.Length ~ Petal.Length + Petal.Width
mod <- robust::lmRob(formula = form, dat = iris)
cluster_im_lmRob(robmod = mod, formula = form, dat = iris,cluster = ~Species)


[Package mmiCATs version 0.1.1 Index]