Package 'jlme'

Title: Regression Modelling with 'GLM.jl' and 'MixedModels.jl' in 'Julia'
Description: Bindings to 'Julia' packages 'GLM.jl' <doi:10.5281/zenodo.3376013> and 'MixedModels.jl' <doi:10.5281/zenodo.12575371>, powered by 'JuliaConnectoR'. Fits (generalized) linear (mixed-effects) regression models in 'Julia' using familiar model fitting syntax from R. Offers 'broom'-style data frame summary functionalities for 'Julia' regression models.
Authors: June Choe [aut, cre]
Maintainer: June Choe <[email protected]>
License: MIT + file LICENSE
Version: 0.3.0
Built: 2024-09-18 03:31:37 UTC
Source: CRAN

Help Index


Set up Julia connection for jlme

Description

Set up Julia connection for jlme

Usage

check_julia_ok()

stop_julia()

jlme_status()

jlme_setup(
  ...,
  add = NULL,
  restart = FALSE,
  threads = NULL,
  verbose = interactive()
)

Arguments

...

Unused

add

A character vector of additional Julia packages to add and load.

restart

Whether to run stop_julia() first, before attempting setup

threads

Number of threads to start Julia with. Defaults to 1

verbose

Whether to alert setup progress. Defaults to interactive()

Value

Invisibly returns TRUE on success

Examples

# Check whether Julia installation meets requirements
check_julia_ok()

# Connect to a Julia runtime for use with `{jlme}`
jlme_setup()

# Show information about the Julia runtime
jlme_status()

# Stop Julia runtime
stop_julia()

Fit a (mixed-effects) regression model in Julia

Description

Fit a (mixed-effects) regression model in Julia

Usage

jlm(formula, data, family = "gaussian", contrasts = jl_contrasts(data), ...)

jlmer(
  formula,
  data,
  family = NULL,
  contrasts = jl_contrasts(data),
  ...,
  progress = interactive()
)

Arguments

formula

A formula written in Julia syntax. Can be a string or a language object.

data

A data frame

family

A distribution family

contrasts

A Julia dictionary of contrasts Inferred from data by default.

...

Additional arguments to the fit() function called in Julia

progress

Whether to print model fitting progress. Defaults to interactive()

Value

A julia model object of class jlme

Examples

jlme_setup(restart = TRUE)

# Fixed effects models
lm(mpg ~ hp, mtcars)
jlm(mpg ~ hp, mtcars)

# Auto-handling of contrasts
x <- mtcars
x$cyl_helm <- factor(x$cyl)
contrasts(x$cyl_helm) <- contr.helmert(3)
colnames(contrasts(x$cyl_helm)) <- c("4vs6", "4&6vs8")
lm(mpg ~ cyl_helm, x)
jlm(mpg ~ cyl_helm, x)

# Mixed effects models
library(lme4)

glmer(r2 ~ Anger + Gender + (1 | id), VerbAgg, family = "binomial")
jlmer(r2 ~ Anger + Gender + (1 | id), VerbAgg, family = "binomial")

stop_julia()

Helpers for interacting with Julia model objects and functions

Description

Helpers for interacting with Julia model objects and functions

Usage

propertynames(x)

issingular(x)

Arguments

x

Julia model object

Value

An appropriate R object

Examples

jlme_setup(restart = TRUE)

x <- jlmer(r2 ~ Anger + (1 | id), lme4::VerbAgg, family = "binomial")

# `propertynames()` lists properties accessible via `$`
propertynames(x)

# `issingular()` reports whether model has singular fit
issingular(x)

stop_julia()

Parametric bootstrap for Julia mixed effects models

Description

Parametric bootstrap for Julia mixed effects models

Usage

parametricbootstrap(
  x,
  nsim,
  seed,
  ...,
  optsum_overrides = list(ftol_rel = 1e-08)
)

Arguments

x

A Julia MixedModel of class jlme

nsim

Number of simulations

seed

Seed for the random number generator (Random.MersenneTwister)

...

Not implemented

optsum_overrides

Values to override in the OptSummary.

Value

MixedModels.parametricboostrap() output as object of class jlmeboot

Examples

jlme_setup(restart = TRUE)

jmod <- jlmer(Reaction ~ Days + (Days | Subject), lme4::sleepstudy)
tidy(jmod)

samp <- parametricbootstrap(jmod, nsim = 100L, seed = 42L)
samp

tidy(samp)

stop_julia()

Tidier methods for Julia regression models

Description

Tidier methods for Julia regression models

Usage

## S3 method for class 'jlmeboot'
tidy(x, effects = c("var_model", "ran_pars", "fixed"), ...)

## S3 method for class 'jlme'
tidy(x, effects = c("var_model", "ran_pars", "fixed"), ...)

## S3 method for class 'jlme'
glance(x, ...)

Arguments

x

An object of class jlme

effects

One of "var_model", "ran_pars", or "fixed"

...

Unused

Value

A data frame