Skip to content

Commit aae458c

Browse files
committed
added docs
1 parent fee6c84 commit aae458c

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

docs/src/constructors.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Model constructors
22

33
The `LinearMixedModel` type represents a linear mixed-effects model.
4-
Typically it is constructed from a `Formula` and an appropriate `Table` type, usually a `DataFrame`.
4+
Typically, it is constructed from a `Formula` and an appropriate `Table` type, usually a `DataFrame`.
55

66
## Examples of linear mixed-effects model fits
77

@@ -58,6 +58,15 @@ fm1 = fit(MixedModel, fm, dyestuff)
5858
DisplayAs.Text(ans) # hide
5959
```
6060

61+
You can also use the convenience function `lmm` to fit the model as follows:
62+
63+
```@example Main
64+
fm = @formula(yield ~ 1 + (1|batch))
65+
fm2 = lmm(fm, dyestuff)
66+
DisplayAs.Text(ans) # hide
67+
```
68+
Notice that both are equivalent.
69+
6170
(If you are new to Julia you may find that this first fit takes an unexpectedly long time, due to Just-In-Time (JIT) compilation of the code. The subsequent calls to such functions are much faster.)
6271

6372
```@example Main
@@ -210,14 +219,18 @@ DisplayAs.Text(ans) # hide
210219
## Fitting generalized linear mixed models
211220

212221
To create a GLMM representation, the distribution family for the response, and possibly the link function, must be specified.
222+
You can either use `fit(MixedModel, ...)` or `glmm(...)` to fit the model. For instance:
213223

214224
```@example Main
215225
verbagg = MixedModels.dataset(:verbagg)
216226
verbaggform = @formula(r2 ~ 1 + anger + gender + btype + situ + mode + (1|subj) + (1|item));
217227
gm1 = fit(MixedModel, verbaggform, verbagg, Bernoulli())
218228
DisplayAs.Text(ans) # hide
219229
```
220-
230+
The model can also be fit as
231+
```@example Main
232+
gm1 = glmm(verbaggform, verbagg, Bernoulli())
233+
```
221234
The canonical link, which is `LogitLink` for the `Bernoulli` distribution, is used if no explicit link is specified.
222235

223236
Note that, in keeping with convention in the [`GLM` package](https://github.com/JuliaStats/GLM.jl), the distribution family for a binary (i.e. 0/1) response is the `Bernoulli` distribution.

docs/src/index.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@ CurrentModule = MixedModels
77
*MixedModels.jl* is a Julia package providing capabilities for fitting and examining linear and generalized linear mixed-effect models.
88
It is similar in scope to the [*lme4*](https://github.com/lme4/lme4) package for `R`.
99

10+
# TLDR
11+
12+
```@setup Main
13+
using DisplayAs
14+
```
15+
You can fit a model using a `lmer`-style model formula using `@formula` and a dataset.
16+
Here is a short example of how to fit a linear mixed-effects modeling using the `dyestuff` dataset:
17+
18+
```@example Main
19+
using DataFrames, MixedModels # load packages
20+
dyestuff = MixedModels.dataset(:dyestuff); # load dataset
21+
22+
lmod = lmm(@formula(yield ~ 1 + (1|batch)), dyestuff) # fit the model!
23+
DisplayAs.Text(ans) # hide
24+
```
25+
For a generalized linear mixed-effect model, you have to specify a distribution for the response variable (and optionally a link function).
26+
A quick example of generalized linear model using the `verbagg` dataset:
27+
28+
```@example Main
29+
using DataFrames, MixedModels # load packages
30+
verbagg = MixedModels.dataset(:verbagg); # load dataset
31+
32+
frm = @formula(r2 ~ 1 + anger + gender + btype + situ + mode + (1|subj) + (1|item));
33+
bernmod = glmm(frm, verbagg, Bernoulli()) # fit the model!
34+
DisplayAs.Text(ans) # hide
35+
```
36+
1037
```@contents
1138
Pages = [
1239
"constructors.md",

0 commit comments

Comments
 (0)