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.4.1 |
Built: | 2024-11-27 19:58:25 UTC |
Source: | CRAN |
Set up Julia connection for jlme
check_julia_ok() stop_julia() jlme_status() jlme_setup( ..., add = NULL, restart = FALSE, threads = NULL, verbose = interactive() )
check_julia_ok() stop_julia() jlme_status() jlme_setup( ..., add = NULL, restart = FALSE, threads = NULL, verbose = interactive() )
... |
Unused |
add |
A character vector of additional Julia packages to add and load. |
restart |
Whether to run |
threads |
Number of threads to start Julia with. Defaults to |
verbose |
Whether to alert setup progress. Defaults to |
Invisibly returns TRUE
on success
# 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()
# 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
jlm(formula, data, family = "gaussian", contrasts = jl_contrasts(data), ...) jlmer( formula, data, family = NULL, contrasts = jl_contrasts(data), ..., fit = TRUE, optsum = list(), progress = interactive() )
jlm(formula, data, family = "gaussian", contrasts = jl_contrasts(data), ...) jlmer( formula, data, family = NULL, contrasts = jl_contrasts(data), ..., fit = TRUE, optsum = list(), progress = interactive() )
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 |
... |
Additional arguments to the |
fit |
Whether to fit the model. If |
optsum |
A list of values to set for the optimizer. See |
progress |
Whether to print model fitting progress. Defaults to |
A julia model object of class jlme
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") # Set optimizer options via `optsum` jlmer( r2 ~ Anger + Gender + (1 | id), VerbAgg, family = "binomial", optsum = list( optimizer = jl(":LN_NELDERMEAD"), maxfeval = 10L ) ) stop_julia()
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") # Set optimizer options via `optsum` jlmer( r2 ~ Anger + Gender + (1 | id), VerbAgg, family = "binomial", optsum = list( optimizer = jl(":LN_NELDERMEAD"), maxfeval = 10L ) ) stop_julia()
Re-exported functions for interacting with Julia model objects
propertynames(x) issingular(x) likelihoodratiotest(x, ...)
propertynames(x) issingular(x) likelihoodratiotest(x, ...)
x |
Julia model object |
... |
Additional arguments passed to the Julia function |
An appropriate R or Julia object
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) # `likelihoodratiotest()` conducts a likelihood-ratio test between nested models likelihoodratiotest( x, jlmer(r2 ~ 1 + (1 | id), lme4::VerbAgg, family = "binomial") ) stop_julia()
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) # `likelihoodratiotest()` conducts a likelihood-ratio test between nested models likelihoodratiotest( x, jlmer(r2 ~ 1 + (1 | id), lme4::VerbAgg, family = "binomial") ) stop_julia()
Parametric bootstrap for Julia mixed effects models
parametricbootstrap( x, nsim, seed, ..., optsum_overrides = list(ftol_rel = 1e-08) )
parametricbootstrap( x, nsim, seed, ..., optsum_overrides = list(ftol_rel = 1e-08) )
x |
A Julia MixedModel of class |
nsim |
Number of simulations |
seed |
Seed for the random number generator (Random.MersenneTwister) |
... |
Not implemented |
optsum_overrides |
Values to override in the OptSummary. |
MixedModels.parametricboostrap() output as object of class jlmeboot
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()
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()
Profile the likelihood surface of Julia mixed effects models
profilelikelihood(x, ...)
profilelikelihood(x, ...)
x |
A Julia MixedModel of class |
... |
Not implemented |
MixedModels.profile() output as object of class jlmeprof
jlme_setup(restart = TRUE) jmod <- jlmer(Reaction ~ Days + (Days | Subject), lme4::sleepstudy) tidy(jmod) prof <- profilelikelihood(jmod) prof tidy(prof) stop_julia()
jlme_setup(restart = TRUE) jmod <- jlmer(Reaction ~ Days + (Days | Subject), lme4::sleepstudy) tidy(jmod) prof <- profilelikelihood(jmod) prof tidy(prof) stop_julia()
Tidier methods for Julia regression models
## S3 method for class 'jlmeboot' tidy(x, effects = c("var_model", "ran_pars", "fixed"), ...) ## S3 method for class 'jlmeprof' 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, ...)
## S3 method for class 'jlmeboot' tidy(x, effects = c("var_model", "ran_pars", "fixed"), ...) ## S3 method for class 'jlmeprof' 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, ...)
x |
An object of class |
effects |
One of "var_model", "ran_pars", or "fixed" |
... |
Unused |
A data frame