Skip to content

Instantly share code, notes, and snippets.

@bbolker
Created September 4, 2022 15:52
Show Gist options
  • Select an option

  • Save bbolker/48a8e860f7c6c008620466bee6bd378d to your computer and use it in GitHub Desktop.

Select an option

Save bbolker/48a8e860f7c6c008620466bee6bd378d to your computer and use it in GitHub Desktop.
testing speed of brms vs lmer
library(brms)
library(lme4)
system.time(b1 <- brm(Reaction ~ Days + (Days|Subject), sleepstudy)) ## 39 sec
scode <- make_stancode(Reaction ~ Days + (Days|Subject), data = sleepstudy)
sdata <- make_standata(Reaction ~ Days + (Days|Subject), data = sleepstudy)
library(microbenchmark)
m1 <- microbenchmark(
lmer = lmer(Reaction ~ Days + (Days|Subject), sleepstudy),
lmerprof = profile(lmer(Reaction ~ Days + (Days|Subject), sleepstudy)),
stan = stanfit <- rstan::stan(model_code = scode, data = sdata),
times = 25L
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment