-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FOWARDPORT: Prettier Markdown (and thus better Documenter Support) (#478
) * Prettier Markdown (and thus better Documenter Support) (#476) * REPL-like output for our objects * describe show functionality * model and var corr now as pretty markdown * use Markdown stdlib for LRT * nicer optsum markdown * remove dead comments * fix test * fix doc build * more use of Markdown stdlib * append! version compat * example of raw markdown * The Zen of Alex * woops * fix exponent alignment * update documenter ci * remove unused option * one more attempt at correct rendering * maybe it's 1.6? * The Zen Continues Co-authored-by: Alex Arslan <[email protected]> * slightly more complicated example (and bugfix!) * patch bump Co-authored-by: Alex Arslan <[email protected]> (cherry picked from commit c7ff101) * small edits * Update al;lowable versions of dependencies * Remove unnecessary using statement * contrast coding * statsmodels for statsmodels example Co-authored-by: Douglas Bates <[email protected]>
- Loading branch information
Showing
14 changed files
with
293 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ Pages = [ | |
"GaussHermite.md", | ||
"bootstrap.md", | ||
"rankdeficiency.md", | ||
"mime.md", | ||
] | ||
Depth = 2 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Alternative display and output formats | ||
|
||
In the documentation, we have presented the output from MixedModels.jl in the same format you will see when working in the REPL. | ||
You may have noticed, however, that output from other packages received pretty printing. | ||
For example, DataFrames are converted into nice HTML tables. | ||
In MixedModels, we recently (v3.2.0) introduced limited support for such pretty printing. | ||
(For more details on how the print and display system in Julia works, check out [this NextJournal post](https://nextjournal.com/sdanisch/julias-display-system).) | ||
|
||
In particular, we have defined Markdown output, i.e. `show` methods, for our types, which can be easily translated into HTML, LaTeX or even a MS Word Document using tools such as [pandoc](https://pandoc.org/). | ||
Packages like `IJulia` and `Documenter` can often detect the presence of these display options and use them automatically. | ||
|
||
|
||
```@example Main | ||
using MixedModels | ||
form = @formula(rt_trunc ~ 1 + spkr * prec * load + | ||
(1 + load | item) + | ||
(1 + spkr + prec + load | subj)) | ||
contr = Dict(:spkr => EffectsCoding(), | ||
:prec => EffectsCoding(), | ||
:load => EffectsCoding(), | ||
:item => Grouping(), | ||
:subj => Grouping()) | ||
kbm = fit(MixedModel, form, MixedModels.dataset(:kb07); contrasts=contr) | ||
``` | ||
|
||
Note that the display here is more succinct than the standard REPL display: | ||
|
||
```@example Main | ||
using DisplayAs | ||
kbm |> DisplayAs.Text | ||
``` | ||
|
||
This brevity is intentional: we wanted these types to work well with traditional academic publishing constraints on tables. | ||
The summary for a model fit presented in the REPL does not mesh well with being treated as a single table (with columns shared between the random and fixed effects). | ||
In our experience, this leads to difficulties in typesetting the resulting tables. | ||
We nonetheless encourage users to report fit statistics such as the log likelihood or AIC as part of the caption of their table. | ||
If the correlation parameters in the random effects are of interest, then [`VarCorr`](@ref) can also be pretty printed: | ||
|
||
```@example Main | ||
VarCorr(kbm) | ||
``` | ||
|
||
Similarly for [`BlockDescription`](@ref), `OptSummary` and `MixedModels.likelihoodratiotest`: | ||
|
||
```@example Main | ||
BlockDescription(kbm) | ||
``` | ||
|
||
```@example Main | ||
kbm.optsum | ||
``` | ||
|
||
```@example Main | ||
m0 = fit(MixedModel, @formula(reaction ~ 1 + (1|subj)), MixedModels.dataset(:sleepstudy)) | ||
m1 = fit(MixedModel, @formula(reaction ~ 1 + days + (1+days|subj)), MixedModels.dataset(:sleepstudy)) | ||
MixedModels.likelihoodratiotest(m0,m1) | ||
``` | ||
|
||
To explicitly invoke this behavior, we must specify the right `show` method: | ||
```julia | ||
show(MIME("text/markdown"), m1) | ||
``` | ||
```@example Main | ||
println(sprint(show, MIME("text/markdown"), kbm)) # hide | ||
``` | ||
(The raw and not rendered output is intentionally shown here.) | ||
|
||
In the future, we may directly support HTML and LaTeX as MIME types. | ||
|
||
This output can also be written directly to file: | ||
|
||
```julia | ||
show(open("model.md", "w"), MIME("text/markdown"), kbm) | ||
``` |
Oops, something went wrong.