MixedModels.jl Documentation

MixedModels.jl is a Julia package providing capabilities for fitting and examining linear and generalized linear mixed-effect models. It is similar in scope to the lme4 package for R.

Quick Start

You can fit a model using a lmer-style model formula using @formula and a dataset. Here is a short example of how to fit a linear mixed-effects modeling using the dyestuff dataset:

using DataFrames, MixedModels           # load packages
dyestuff = MixedModels.dataset(:dyestuff);              # load dataset

lmod = lmm(@formula(yield ~ 1 + (1|batch)), dyestuff)   # fit the model!
Linear mixed model fit by maximum likelihood
 yield ~ 1 + (1 | batch)
   logLik   -2 logLik     AIC       AICc        BIC    
  -163.6635   327.3271   333.3271   334.2501   337.5307

Variance components:
            Column    Variance Std.Dev.
batch    (Intercept)  1388.3332 37.2603
Residual              2451.2501 49.5101
 Number of obs: 30; levels of grouping factors: 6

  Fixed-effects parameters:
────────────────────────────────────────────────
              Coef.  Std. Error      z  Pr(>|z|)
────────────────────────────────────────────────
(Intercept)  1527.5     17.6946  86.33    <1e-99
────────────────────────────────────────────────

For a generalized linear mixed-effect model, you have to specify a distribution for the response variable (and optionally a link function). A quick example of generalized linear model using the verbagg dataset:

using DataFrames, MixedModels               # load packages
verbagg = MixedModels.dataset(:verbagg);    # load dataset

frm = @formula(r2 ~ 1 + anger + gender + btype + situ + mode + (1|subj) + (1|item));
bernmod = glmm(frm, verbagg, Bernoulli())   # fit the model!
Generalized Linear Mixed Model fit by maximum likelihood (nAGQ = 1)
  r2 ~ 1 + anger + gender + btype + situ + mode + (1 | subj) + (1 | item)
  Distribution: Bernoulli{Float64}
  Link: LogitLink()

   logLik    deviance     AIC       AICc        BIC    
 -4067.9164  8135.8329  8153.8329  8153.8566  8216.2370

Variance components:
        Column   Variance Std.Dev. 
subj (Intercept)  1.793543 1.339232
item (Intercept)  0.117147 0.342267

 Number of obs: 7584; levels of grouping factors: 316, 24

Fixed-effects parameters:
──────────────────────────────────────────────────────
                   Coef.  Std. Error       z  Pr(>|z|)
──────────────────────────────────────────────────────
(Intercept)   -0.152626     0.385225   -0.40    0.6920
anger          0.0573837    0.016753    3.43    0.0006
gender: M      0.320634     0.19121     1.68    0.0936
btype: scold  -1.05993      0.184157   -5.76    <1e-08
btype: shout  -2.10392      0.186516  -11.28    <1e-28
situ: self    -1.05436      0.151193   -6.97    <1e-11
mode: want     0.706979     0.151006    4.68    <1e-05
──────────────────────────────────────────────────────

Contents