Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions blockedcholesky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.luarc.json
/Manifest*.toml
/jds.bst
/jdsart.cls
/*.ipynb
/*.pdf
/data/ml-32m.zip
/data/ratings.arrow
570 changes: 258 additions & 312 deletions blockedcholesky/BlockedCholeskyMM.qmd

Large diffs are not rendered by default.

Binary file added blockedcholesky/BlockedCholeskyMM.zip
Binary file not shown.
119 changes: 119 additions & 0 deletions blockedcholesky/Environment.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
title: "Computing environment and similar model fits in R"
format: pdf
author:
- name: Douglas Bates
email: dmbates@gmail.com
orcid: 0000-0001-8316-9503
affiliation:
- name: University of Wisconsin--Madison
city: University of Wisconsin--Madison
state: WI
url: https://www.wisc.edu
department: Department of Statistics
- name: Phillip M. Alday
email: phillip@phillipalday.com
orcid: 0000-0002-9984-5745
affiliation:
- name: Beacon Biosignals
city: Beacon Biosignals
url: https://beacon.bio
- name: Ajinkya H. Kokandakar
email: ajinkya@stat.wisc.edu
orcid: 0000-0001-6628-2272
affiliations:
- name: University of Wisconsin--Madison
city: University of Wisconsin--Madison
state: WI
url: https://www.wisc.edu
department: Department of Statistics
monofont: JuliaMono
date: last-modified
number-sections: true
execute:
cache: true
engine: julia
julia:
exeflags:
- -tauto
- --project=@.
---

# Computing environment

The timings in the paper, with the exception of the fits of models to the `ml-32m` data, were performed on a laptop with the following characteristics

```{julia}
using AppleAccelerate, InteractiveUtils, LinearAlgebra, RCall
versioninfo()
```

The versions of the Julia packages in use were

```{julia}
import Pkg
Pkg.status()
```

and the accelerated BLAS used for this computer were

```{julia}
BLAS.get_config()
```

# Timing similar model fits with lme4

For comparison we fit the same model as in section 3.1.1 using the `lme4::lmer` and `glmmTMB::tmbmod` functions in `R`

```{r}
dat <- lme4::InstEval
dat$service <- as.numeric(dat$service) - 1 # convert to a 0/1 numeric vector
ctrl <- lme4::lmerControl(calc.derivs = FALSE)
form <- y ~ 1 + service + (1 | s) + (1 | d) + (1 | dept) + (0 + service | dept)
mlmer <- lme4::lmer(form, dat, REML = FALSE, control = ctrl)
print(summary(mlmer, correlation = FALSE))
NULL # suppress printing of the internal structure of the summary result
```

```{r}
tmbmod <- glmmTMB::glmmTMB(form, dat)
print(summary(tmbmod))
NULL
```

These model fits are essentially the same as that from `MixedModels.jl` but they take longer

```{r}
#| warning: false
print(
microbenchmark::microbenchmark(
lmer = lme4::lmer(form, dat, REML = FALSE, control = ctrl),
glmmTMB = glmmTMB::glmmTMB(form, dat),
times=6L,
unit="seconds"
)
)
NULL
```

Recall from section 3.1.1 of the paper that the `MixedModels.jl` fit of this model took just over one second on the same laptop computer.

We attempted to fit the `ml-32m` example using `glmmTMB` on a desktop computer with 64 GiB of memory but shut it down after it had been running for more than a week on the machine without converging.
Given otherwise similar performance, we do not expect `lme4` to perform any better than `glmmTMB`.

# Versions of R and the R packages that were used

```{r}
print(R.version.string)
print(packageVersion("lme4"))
print(packageVersion("glmmTMB"))
NULL
```

# Environment for the ml-32m model fits

The environment for the ml-32m model fits is shown in the `config.txt` file. The Julia source code to download the `ml-32m.zip` file, extract the `ratings` table, create `moviesnratings.arrow` and `usersnratings.arrow`, followed by `ratings.arrow` is `ml32-download.jl`.

The Julia source file to run the `ml-32m` fits is `ml32-timefit.jl`.
Before you start these fits remember that they take up to a day on a powerful server computer.
Don't do this frivolously.
2 changes: 1 addition & 1 deletion blockedcholesky/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ preview:
quarto preview $(DOCNAME).qmd

render:
quarto render $(DOCNAME).qmd --to jss-pdf+jss
quarto render $(DOCNAME).qmd --to jds-pdf

render-arxiv:
sed -i'.bak' -e '/city:/d' $(DOCNAME).qmd
Expand Down
15 changes: 10 additions & 5 deletions blockedcholesky/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@ CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
Chairmarks = "0ca39b1e-fe0b-4e98-acfc-b1656634c4de"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
MKL = "33e6dc65-8f57-5167-99aa-e5a354878fb2"
MKL_jll = "856f044c-d86e-5d09-b602-aeab76dc8ba7"
MixedModels = "ff71e718-51f3-5ec2-a782-8ffcbfa3c316"
PRIMA = "0a7d04aa-8ac2-47b3-b7a7-9dbd6ad661ed"
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
RCall = "6f49c342-dc21-5d91-9882-a32aef131414"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"

[compat]
AlgebraOfGraphics = "0.10.4"
AlgebraOfGraphics = "0.11,0.12"
Arrow = "2.8"
CSV = "0.10"
CairoMakie = "0.13.4"
CairoMakie = "0.13,0.14,0.15"
Chairmarks = "1.3"
DataFrames = "1.7"
MixedModels = "4.34"
PrettyTables = "2.4"
MixedModels = "4,5"
PrettyTables = "2,3"
Printf = "1"
julia = "1.10"
julia = "1.12"
33 changes: 19 additions & 14 deletions blockedcholesky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,31 @@

## Steps

- Install (or update) [`quarto`](https://quarto.org/) version 1.7 or greater (v1.6 may work as well, basically use any version of `quarto` that supports `engine: julia`)
- Install the current Julia release version according to the instructions at https://julialang.org/downloads
- Install (or update) [`quarto`](https://quarto.org/) version 1.9.0 or greater
- Install `jupyter-cache` using the instructions from the quarto Julia docs [here](https://quarto.org/docs/computations/julia.html#jupyter-cache).
- Install the `JuliaMono` font, see instructions at: https://juliamono.netlify.app
- Install required `Julia` dependencies by running:
```bash
$ julia --project=@. -e "import Pkg; Pkg.instantiate()"
```
- Generate the JSS formatted preview using:
- Install the [`JDS extensions`](https://github.com/wenjie2wang/jds.qmd) for [`quarto`](https://quarto.org)
- Install the required `Julia` dependencies by running:
```bash
$ make render
julia --project=@. -e "import Pkg; Pkg.instantiate()"
```
- Generate the arXiv formatted version using:
- Generate the JDL formatted preview using:
```bash
$ make render-arxiv
make render
```
**Note:** this command re-runs the `R` benchmark script which can take a long time.
**Note:** For the arxiv version, you need to have `cbfonts-fd` and `cbfonts` packages installed in your latex distribution
- If you get errors due to caching, try using the `--no-cache` option for quarto:
```bash
quarto render BlockedCholeskyMM.qmd --no-cache # for JSS version render
quarto render BlockedCholeskyMM.qmd --no-cache --to arxiv-pdf+arxiv # for arxiv version

quarto render BlockedCholeskyMM.qmd --no-cache --to jds-pdf # for JDS version render
```
- To create a Julia script from the Quarto file (`BlockedCholeskyMM.qmd`) convert the .qmd file to a Jupyter notebook and apply `jupyter nbconvert` to create a script.
```bash
quarto convert BlockedCholeskyMM.qmd
jupyter nbconvert --no-prompt --to script BlockedCholeskyMM.ipynb
mv BlockedCholeskyMM.txt BlockedCholeskyMM.jl
```
- Alternatively, `Quarto mode` for editors such as [VSCode](https://code.visualstudio.com) or [Positron](https://positron.posit.co) provide the ability to interactively evaluate code chunks from a Quarto document.

- Comparison fits in R using the `lme4` and `glmmTMB` packages are shown in `Environment.pdf` generated from `Environment.qmd`

- Because the ml-32m dataset cannot be redistributed, reproduction of the results in Table 4, require a separate script, `scripts/ml32-download.jl` to download the data, create the ratings table, and save it in the [Arrow](https://arrow.apache.org) format. The evaluation of the models is performed by `ml32-timefit.jl` **but** be aware that fitting very large models like this requires a computer with a large amount of memory (64 GiB is recommended) and can take a long time. It took roughly 18 hours for all the model fits on a cloud compute instance with the characteristics shown in `config.txt`.
27 changes: 27 additions & 0 deletions blockedcholesky/_extensions/wenjie2wang/jds/_extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
title: Journal of Data Science
author: Wenjie Wang and Jun Yan
version: 0.1.1
quarto-required: ">= 1.4.0"
contributes:
formats:
common:
shortcodes:
- shortcodes.lua
pdf:
documentclass: jdsart
classoption:
- letterpaper
- inpress
template: template.tex
cite-method: natbib
biblio-style: jds
biblio-config: false
fig-width: 6.5
fig-height: 4.5
format-resources:
- jdsart.cls
- jds.bst
html:
number-sections: true
toc: true
csl: apa.csl
Loading