Tidier methods for Julia regression models
Examples
# \donttest{
# Fixed-effects only model
mod1 <- to_jlmer(weight ~ 1 + Diet, ChickWeight)
tidy(mod1)
#> # A tibble: 4 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) 103. 4.67 22.0 6.77e-107
#> 2 Diet2 20.0 7.87 2.54 1.11e- 2
#> 3 Diet3 40.3 7.87 5.12 3.01e- 7
#> 4 Diet4 32.6 7.91 4.12 3.73e- 5
glance(mod1)
#> # A tibble: 1 × 8
#> nobs df sigma logLik AIC BIC deviance df.residual
#> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 578 5 69.3 -3268. 6546. 6568. 2758693. 573
# Mixed model
mod2 <- to_jlmer(weight ~ 1 + Diet + (1 | Chick), ChickWeight)
tidy(mod2)
#> # A tibble: 6 × 7
#> effect group term estimate std.error statistic p.value
#> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 fixed NA (Intercept) 102. 5.78 17.6 2.74e-69
#> 2 fixed NA Diet2 20.8 9.79 2.13 3.34e- 2
#> 3 fixed NA Diet3 41.2 9.79 4.20 2.63e- 5
#> 4 fixed NA Diet4 33.3 9.83 3.39 7.08e- 4
#> 5 ran_pars Chick sd__(Intercept) 15.7 NA NA NA
#> 6 ran_pars Residual sd__Observation 67.3 NA NA NA
glance(mod2)
#> # A tibble: 1 × 8
#> nobs df sigma logLik AIC BIC deviance df.residual
#> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 578 6 67.3 -3265. 6542. 6568. 6530. 572
# Select which of fixed/random effects to return
tidy(mod2, effects = "fixed")
#> # A tibble: 4 × 5
#> term estimate std.error statistic p.value
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 (Intercept) 102. 5.78 17.6 2.74e-69
#> 2 Diet2 20.8 9.79 2.13 3.34e- 2
#> 3 Diet3 41.2 9.79 4.20 2.63e- 5
#> 4 Diet4 33.3 9.83 3.39 7.08e- 4
tidy(mod2, effects = "ran_pars")
#> # A tibble: 2 × 3
#> group term estimate
#> <chr> <chr> <dbl>
#> 1 Chick sd__(Intercept) 15.7
#> 2 Residual sd__Observation 67.3
# }