cluster_im_lmRob {mmiCATs} | R Documentation |
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.
cluster_im_lmRob(
robmod,
formula,
dat,
cluster,
ci.level = 0.95,
drop = TRUE,
return.vcv = FALSE,
engine = "robust",
...
)
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 |
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. |
A list containing the following elements:
A matrix of p-values for each independent variable.
A matrix with the lower and upper bounds of the confidence intervals for each independent variable.
The variance-covariance matrix of the cluster-averaged
coefficients, returned if return.vcv
is TRUE.
The cluster-averaged coefficients, returned if return.vcv
is TRUE.
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)