summa | R Documentation |
This function prints a summary of the result object returned by the function
"lm"
for estimating linear regression models and for the result object
returned by the function "lmer"
from the lme4 or lmerTest
package, or by the function "rlmer"
from the robustlmm package to
estimate two- or three-level (robust) multilevel and linear mixed-effects models.
By default, the function prints the function call, model summary, and the regression
coefficient table.
summa(model, print = c("all", "default", "call", "descript", "cormat", "modsum",
"coef", "confint", "stdcoef", "vif"),
robust = FALSE, ddf = c("Satterthwaite", "Kenward-Roger", "lme4"),
conf.level = 0.95, method = c("profile", "wald", "boot"), R = 1000,
boot = c("perc", "basic", "norm"), seed = NULL, digits = 2, p.digits = 3,
write = NULL, append = TRUE, check = TRUE, output = TRUE)
model |
a fitted model of class |
print |
a character vector indicating which results to print, i.e.
|
robust |
logical: if |
ddf |
a character string for specifying the method for computing
the degrees of freedom when using the lmerTest package
to obtain p-values for fixed effects in multilevel
and linear mixed-effects models, i.e., |
conf.level |
a numeric value between 0 and 1 indicating the confidence level of the interval. |
method |
a character string for specifying the method for computing
confidence intervals (CI), i.e., |
R |
a numeric value indicating the number of bootstrap replicates (default is 1000). |
boot |
a character string for specifying the type of bootstrap
confidence intervals (CI), i.e., i.e., |
seed |
a numeric value specifying seeds of the pseudo-random numbers used in the bootstrap algorithm when conducting bootstrapping. |
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 multiple R, R-squared and p-value. |
write |
a character string naming a file for writing the output into
either a text file with file extension |
append |
logical: if |
check |
logical: if |
output |
logical: if |
The function rlmer
from the robustlmm package does not provide
any degrees of freedom or significance values. This function re-estimates the
model without using robust estimation to obtain the Satterthwaite or Kenward-Roger
degrees of freedom depending on the argument ddf
before computing
significance values for the regression coefficients based on parameter estimates
and standard error of the robust multilevel mixed-effects (see Sleegers et al.
(2021).
Returns an object of class misty.object
, which is a list with following
entries:
call |
function call |
type |
type of analysis |
model |
model specified in |
args |
specification of function arguments |
result |
list with results, i.e., |
Takuya Yanagida
Kuznetsova, A, Brockhoff, P. B., & Christensen, R. H. B. (2017). lmerTest Package: Tests in linear mixed effects models. Journal of Statistical Software, 82 13, 1-26. https://doi.org/10.18637/jss.v082.i13
Sleegers, W. W. A., Proulx, T., & van Beest, I. (2021). Pupillometry and hindsight bias: Physiological arousal predicts compensatory behavior. Social Psychological and Personality Science, 12(7), 1146–1154. https://doi.org/10.1177/1948550620966153
descript
, cor.matrix
, coeff.std
,
coeff.robust
, check.collin
#----------------------------------------------------------------------------
# Linear Model
# Estimate linear model
mod.lm <- lm(mpg ~ cyl + disp, data = mtcars)
# Example 1a: Default setting
summa(mod.lm)
# Example 1b: Heteroscedasticity-consistent standard errors
summa(mod.lm, robust = TRUE)
# Example 1c: Print all available results
summa(mod.lm, print = "all")
# Example 1d: Print default results plus standardized coefficient
summa(mod.lm, print = c("default", "stdcoef"))
## Not run:
#----------------------------------------------------------------------------
# Multilevel and Linear Mixed-Effects Model
# Load lme4 and misty package
misty::libraries(lme4, misty)
# Load data set "Demo.twolevel" in the lavaan package
data("Demo.twolevel", package = "lavaan")
#------------------
## Two-Level Data
# 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 2a: Default setting
summa(mod.lmer2)
# Example 2b: Print all available results
summa(mod.lmer2, print = "all")
# Example 2c: Print default results plus standardized coefficient
summa(mod.lmer2, print = c("default", "stdcoef"))
# Load lmerTest package
library(lmerTest)
# Re-estimate two-level model using the lme4 and lmerTest package
mod.lmer2 <- lmer(y1 ~ x2.c + w1.c + x2.c:w1.c + (1 + x2.c | cluster), data = Demo.twolevel)
# Example 2d: Default setting, Satterthwaite's method
summa(mod.lmer2)
# Example 2e: Kenward-Roger's method
summa(mod.lmer2, ddf = "Kenward-Roger")
# Example 2f: Cluster-robust standard errors
summa(mod.lmer2, robust = TRUE)
#------------------
## Robust Estimation using the R package robustlmm
# Estimate two-level mixed-effects model
mod.lmer2r <- robustlmm::rlmer(y1 ~ x2.c + w1.c + x2.c:w1.c + (1 + x2.c | cluster),
data = Demo.twolevel)
# Example 2f: Default setting
summa(mod.lmer2r)
#------------------
## Three-Level Data
# Create arbitrary three-level data
Demo.threelevel <- data.frame(Demo.twolevel, cluster2 = Demo.twolevel$cluster,
cluster3 = rep(1:10, each = 250))
# Cluster-mean centering, center() from the misty package
Demo.threelevel <- center(Demo.threelevel, x1, type = "CWC", cluster = c("cluster3", "cluster2"))
# Cluster-mean centering, center() from the misty package
Demo.threelevel <- center(Demo.threelevel, w1, type = "CWC", cluster = c("cluster3", "cluster2"))
# Estimate three-level model using the lme4 package
mod.lmer3 <- lmer(y1 ~ x1.c + w1.c + (1 | cluster3/cluster2), data = Demo.threelevel)
# Example 3a: Default setting
summa(mod.lmer3)
# Example 3b: Print all available results
summa(mod.lmer3, print = "all")
#------------------
## Robust Estimation using the R package robustlmm
# Estimate three-level model using the lme4 package
mod.lmer3r <- robustlmm::rlmer(y1 ~ x1.c + w1.c + (1 | cluster3/cluster2),
data = Demo.threelevel)
# Example 3c: Default setting
summa(mod.lmer3r)
#----------------------------------------------------------------------------
# Write Results
# Example 4a: Write Results into a text file
summa(mod.lm, print = "all", write = "Linear_Model.txt")
# Example 4b: Write Results into a Excel file
summa(mod.lm, print = "all", write = "Linear_Model.xlsx")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.