Intro

This creates a standard regression table for the fixed effects, mostly in keeping with the broom::tidy approach.

Examples

library(lme4)
library(glmmTMB)
library(nlme)
library(brms)
library(mgcv)


lmer_model <-
  lmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy)

lme_model  <-
  lme(Reaction ~ Days, random = ~ 1 + Days | Subject, data = sleepstudy)

tmb_model  <-
  glmmTMB(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy)

# brms_model <-
#   brm(Reaction ~ Days + (1 + Days | Subject), 
#       data = sleepstudy,
#       cores = 4,
#       refresh = -1,
#       verbose = FALSE
#   )

# this is akin to (1 | Subject) + (0 + Days | Subject) in lme4
mgcv_model <-
  gam(
    Reaction ~  Days +
      s(Subject, bs = 're') +
      s(Days, Subject, bs = 're'),
    data = lme4::sleepstudy,
    method = 'REML'
  )
library(mixedup)

extract_fixed_effects(lmer_model)
# A tibble: 2 x 7
  term      value    se     t p_value lower_2.5 upper_97.5
  <chr>     <dbl> <dbl> <dbl>   <dbl>     <dbl>      <dbl>
1 Intercept 251.   6.82 36.8        0    238.        265. 
2 Days       10.5  1.55  6.77       0      7.44       13.5


extract_fixed_effects(lme_model)
# A tibble: 2 x 7
  term      value    se     z p_value lower_2.5 upper_97.5
  <chr>     <dbl> <dbl> <dbl>   <dbl>     <dbl>      <dbl>
1 Intercept 251.   6.82 36.8        0    238.        265. 
2 Days       10.5  1.55  6.77       0      7.42       13.5


extract_fixed_effects(tmb_model)
# A tibble: 2 x 7
  term      value    se     z p_value lower_2.5 upper_97.5
  <chr>     <dbl> <dbl> <dbl>   <dbl>     <dbl>      <dbl>
1 Intercept 251.   6.63 37.9        0    238.        264. 
2 Days       10.5  1.50  6.97       0      7.52       13.4


extract_fixed_effects(brms_model)
# A tibble: 2 x 5
  term      value    se lower_2.5 upper_97.5
  <chr>     <dbl> <dbl>     <dbl>      <dbl>
1 Intercept 250.   7.13    234.        262. 
2 Days       10.6  1.44      8.03       13.5


extract_fixed_effects(mgcv_model)
# A tibble: 2 x 7
  term      value    se     t p_value lower_2.5 upper_97.5
  <chr>     <dbl> <dbl> <dbl>   <dbl>     <dbl>      <dbl>
1 Intercept 251.   6.88 36.5        0    238.        265. 
2 Days       10.5  1.56  6.71       0      7.39       13.5

Options

extract_fixed_effects(
  lmer_model,
  ci_level = .9,
  ci_args = list(method = 'boot', nsim = 50),
  digits = 2
)
# A tibble: 2 x 7
  term      value    se     t p_value lower_5 upper_95
  <chr>     <dbl> <dbl> <dbl>   <dbl>   <dbl>    <dbl>
1 Intercept 251.   6.82 36.8        0  242.      264. 
2 Days       10.5  1.55  6.77       0    8.23     12.7
tmb_zip <- glmmTMB(
  count ~ spp + mined + (1 | site),
  zi =  ~ spp + mined + (1 | site),
  family = truncated_poisson,
  data = Salamanders
)

extract_fixed_effects(
  tmb_zip,
  cond = 'zi',
  exponentiate = TRUE
)
# A tibble: 8 x 7
  term      value    se      z p_value lower_2.5 upper_97.5
  <chr>     <dbl> <dbl>  <dbl>   <dbl>     <dbl>      <dbl>
1 Intercept 0.935 0.193 -0.325   0.745     0.624       1.4 
2 sppPR     0.594 0.166 -1.87    0.062     0.344       1.03
3 sppDM     1.25  0.181  1.55    0.121     0.942       1.66
4 sppEC-A   0.822 0.165 -0.972   0.331     0.554       1.22
5 sppEC-L   1.91  0.253  4.89    0         1.47        2.47
6 sppDES-L  1.83  0.239  4.64    0         1.42        2.36
7 sppDF     1.05  0.161  0.299   0.765     0.774       1.42
8 minedno   2.76  0.516  5.42    0         1.91        3.98