File: timingInstEval.R

package info (click to toggle)
r-cran-glmmtmb 1.1.5%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,504 kB
  • sloc: cpp: 1,018; sh: 16; makefile: 9
file content (32 lines) | stat: -rw-r--r-- 1,174 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## @kaskr points out that this may not be the most effective timing check
## as repeated data may be optimized away by subexpression elimination:
## https://github.com/glmmTMB/glmmTMB/pull/652#issuecomment-821025662

## timingFuns.R _should_ be in the working directory (.../vignettes) but ??
if (file.exists("timingFuns.R")) {
  source("timingFuns.R")
  data(InstEval,package="lme4")
  library("lme4")
  library("glmmTMB")
  library("plyr")  ## load before dplyr; for ldply()
  library("tidyr")
  library("dplyr")

  ## make sure this is run with optimized build of glmmTMB,
  ## i.e. "make install" rather than "make quick-install/quick-check"
  ## (or at least document)
  nvals <- seq(0.1, 1, by=0.1)

  form <- y~service+lectage+studage+(1|d)+(1|s)+(1|dept)
  tmat <- ldply(nvals, getTimes, basedata=InstEval,
                form=form, family=NULL, which=c("glmmTMB", "lmer"),
                .progress="text")

  ## reshape: wide-to-long, add n values
  ff <- function(dd, n=seq(nrow(dd))) {
    mutate(dd, n = nvals) %>%
      gather(pkg, time, -n)
  }
  tmatInstEval <- ff(tmat)
  save("tmatInstEval", file="InstEvalTimings.rda")
}  ## if timingFuns.R is available