R/summary_lmer.R

Defines functions summary_lmer

Documented in summary_lmer

#' Summary table for a \code{lmerMod} object.
#' 
#' This function creates the summary table with p values for a \code{lmerMod} object.
#' 
#' @param mod A `lmerMod` object.
#' @examples
#' 
#' require(lme4)
#' fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
#' summary(fm1) # Usual table without p values
#' summary_lmer(fm1) # Table with p values
#' @return \code{summary_lmer} function returns a matrix with p values in last column.
#' 
#' @export
#' 
summary_lmer <- function(mod) {
  if (class(mod) != "lmerMod") stop("The model is not a lmerMod object")
  coefi <- summary(mod)$coefficients
  pvalues <- 2*pnorm(q=abs(coefi[, 3]), lower.tail=FALSE)
  res <- cbind(coefi, p.value=round(pvalues, 4))
  colnames(res) <- c("Estimate", "Std.Err", "t value", "Pr(>t)")
  printCoefmat(res)
}
fhernanb/model documentation built on Sept. 16, 2017, 11 a.m.