Skip to contents

Fit a Julia regression model using lme4 syntax

Usage

to_jlmer(
  formula,
  data,
  family = c("gaussian", "binomial"),
  jlmer_spec_opts = list(),
  ...,
  progress = FALSE
)

Arguments

formula

Model formula in R syntax

data

A data frame

family

A GLM family. Currently supports "gaussian" and "binomial".

jlmer_spec_opts

List of options passed to make_jlmer_spec()

...

Optional arguments passed to Julia for model fitting.

progress

If TRUE, prints the timing of iterations.

Value

A jlmer_mod object.

Examples

# \donttest{

# Fitting a regression model with R formula syntax
to_jlmer(weight ~ 1 + Diet, ChickWeight)
#> <Julia object of type StatsModels.TableRegressionModel>
#> ────────────────────────────────────────────────────────────────────────
#>                 Coef.  Std. Error      z  Pr(>|z|)  Lower 95%  Upper 95%
#> ────────────────────────────────────────────────────────────────────────
#> (Intercept)  102.645      4.67395  21.96    <1e-99   93.4847    111.806
#> Diet2         19.9712     7.86744   2.54    0.0111    4.55132    35.3911
#> Diet3         40.3045     7.86744   5.12    <1e-06   24.8847     55.7244
#> Diet4         32.6173     7.91046   4.12    <1e-04   17.113      48.1215
#> ────────────────────────────────────────────────────────────────────────

# `lm()` equivalent
summary(lm(weight ~ 1 + Diet, ChickWeight))$coef
#>              Estimate Std. Error   t value     Pr(>|t|)
#> (Intercept) 102.64545   4.673954 21.961161 4.712762e-78
#> Diet2        19.97121   7.867437  2.538465 1.139708e-02
#> Diet3        40.30455   7.867437  5.122958 4.113938e-07
#> Diet4        32.61726   7.910461  4.123307 4.286352e-05

# Fitting a mixed model with {lme4} syntax
to_jlmer(weight ~ 1 + Diet + (1 | Chick), ChickWeight)
#> <Julia object of type LinearMixedModel>
#> Variance components:
#>             Column    Variance Std.Dev.
#> Chick    (Intercept)   247.2559 15.7244
#> Residual              4527.9661 67.2902
#>  ──────────────────────────────────────────────────
#>                 Coef.  Std. Error      z  Pr(>|z|)
#> ──────────────────────────────────────────────────
#> (Intercept)  101.781      5.78499  17.59    <1e-68
#> Diet2         20.8353     9.79412   2.13    0.0334
#> Diet3         41.1687     9.79412   4.20    <1e-04
#> Diet4         33.284      9.82881   3.39    0.0007
#> ──────────────────────────────────────────────────

# Passing MixedModels.jl fit options to the `...`
to_jlmer(weight ~ 1 + Diet + (1 | Chick), ChickWeight, REML = TRUE)
#> <Julia object of type LinearMixedModel>
#> Variance components:
#>             Column    Variance Std.Dev.
#> Chick    (Intercept)   305.7755 17.4864
#> Residual              4526.5647 67.2797
#>  ──────────────────────────────────────────────────
#>                 Coef.  Std. Error      z  Pr(>|z|)
#> ──────────────────────────────────────────────────
#> (Intercept)  101.634      6.04044  16.83    <1e-62
#> Diet2         20.9832    10.2365    2.05    0.0404
#> Diet3         41.3165    10.2365    4.04    <1e-04
#> Diet4         33.4041    10.27      3.25    0.0011
#> ──────────────────────────────────────────────────

# }