broom (version 0.3.7)

lme4_tidiers: Tidying methods for mixed effects models

Description

These methods tidy the coefficients of mixed effects models, particularly responses of the merMod class

Usage

## S3 method for class 'merMod':
tidy(x, effects = "random", ...)

## S3 method for class 'merMod': augment(x, data = model.frame(x), newdata, ...)

## S3 method for class 'merMod': glance(x, ...)

Arguments

x
An object of class merMod, such as those from lmer, glmer, or nlmer
effects
Either "random" (default) or "fixed"
...
extra arguments (not used)
data
original data this was fitted on; if not given this will attempt to be reconstructed
newdata
new data to be used for prediction; optional

Value

  • All tidying methods return a data.frame without rownames. The structure depends on the method chosen.

    tidy returns one row for each estimated effect, either random or fixed depending on the effects parameter. If effects = "random", it contains the columns

  • groupthe group within which the random effect is being estimated
  • levellevel within group
  • termterm being estimated
  • estimateestimated coefficient
  • If effects="fixed", tidy returns the columns
  • termgixed term being estimated
  • estimateestimate of fixed effect
  • std.errorstandard error
  • statistict-statistic
  • p.valueP-value computed from t-statistic (depending on the model, this may or may not be calculated and included)
  • augment returns one row for each original observation, with columns (each prepended by a .) added. Included are the columns
  • .fittedpredicted values
  • .residresiduals
  • .fixedpredicted values with no random effects
  • Also added for "merMod" objects, but not for "mer" objects, are values from the response object within the model (of type lmResp, glmResp, nlsResp, etc). These include ".mu", ".offset", ".sqrtXwt", ".sqrtrwt", ".eta".

    glance returns one row with the columns

  • sigmathe square root of the estimated residual variance
  • logLikthe data's log-likelihood under the model
  • AICthe Akaike Information Criterion
  • BICthe Bayesian Information Criterion
  • deviancedeviance

Details

When the modeling was performed with na.action = "na.omit" (as is the typical default), rows with NA in the initial data are omitted entirely from the augmented data frame. When the modeling was performed with na.action = "na.exclude", one should provide the original data as a second argument, at which point the augmented data will contain those rows (typically with NAs in place of the new columns). If the original data is not provided to augment and na.action = "na.exclude", a warning is raised and the incomplete rows are dropped.

See Also

na.action

Examples

Run this code
if (require("lme4")) {
    # example regressions are from lme4 documentation
    lmm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
    tidy(lmm1)
    tidy(lmm1, effects = "fixed")
    head(augment(lmm1, sleepstudy))
    glance(lmm1)

    glmm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
                  data = cbpp, family = binomial)
    tidy(glmm1)
    tidy(glmm1, effects = "fixed")
    head(augment(glmm1, cbpp))
    glance(glmm1)

    startvec <- c(Asym = 200, xmid = 725, scal = 350)
    nm1 <- nlmer(circumference ~ SSlogis(age, Asym, xmid, scal) ~ Asym|Tree,
                  Orange, start = startvec)
    tidy(nm1)
    tidy(nm1, effects = "fixed")
    head(augment(nm1, Orange))
    glance(nm1)
}

Run the code above in your browser using DataCamp Workspace