|
1 | 1 | # Model constructors |
2 | 2 |
|
3 | 3 | 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`. |
5 | 5 |
|
6 | 6 | ## Examples of linear mixed-effects model fits |
7 | 7 |
|
@@ -58,6 +58,15 @@ fm1 = fit(MixedModel, fm, dyestuff) |
58 | 58 | DisplayAs.Text(ans) # hide |
59 | 59 | ``` |
60 | 60 |
|
| 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 | + |
61 | 70 | (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.) |
62 | 71 |
|
63 | 72 | ```@example Main |
@@ -210,14 +219,18 @@ DisplayAs.Text(ans) # hide |
210 | 219 | ## Fitting generalized linear mixed models |
211 | 220 |
|
212 | 221 | 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: |
213 | 223 |
|
214 | 224 | ```@example Main |
215 | 225 | verbagg = MixedModels.dataset(:verbagg) |
216 | 226 | verbaggform = @formula(r2 ~ 1 + anger + gender + btype + situ + mode + (1|subj) + (1|item)); |
217 | 227 | gm1 = fit(MixedModel, verbaggform, verbagg, Bernoulli()) |
218 | 228 | DisplayAs.Text(ans) # hide |
219 | 229 | ``` |
220 | | - |
| 230 | +The model can also be fit as |
| 231 | +```@example Main |
| 232 | +gm1 = glmm(verbaggform, verbagg, Bernoulli()) |
| 233 | +``` |
221 | 234 | The canonical link, which is `LogitLink` for the `Bernoulli` distribution, is used if no explicit link is specified. |
222 | 235 |
|
223 | 236 | 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. |
|
0 commit comments