Package {BioMixModel}


Type: Package
Title: Mixed Models for Biological, Clustered and Longitudinal Data
Version: 1.0.0
Description: Fits and interprets mixed-effects models for clustered, longitudinal and heterogeneous biological data. Provides variance partitioning, intraclass correlation, penalized likelihood summaries, a heterogeneous-data information criterion, model comparison, diagnostics, and ensemble-style summaries for multilevel data. The package is designed as a complementary, interpretable workflow around established mixed-model methods. Methods for intraclass correlation and variance partitioning are informed by Nakagawa and Schielzeth (2010) <doi:10.1111/j.1469-185X.2010.00141.x> and Nakagawa et al. (2017) <doi:10.1098/rsif.2017.0213>. Mixed-effects modeling approaches are described by Zuur et al. (2009) <doi:10.1007/978-0-387-87458-6>.
License: MIT + file LICENSE
Encoding: UTF-8
Language: en-US
Depends: R (≥ 4.1.0)
Imports: stats, graphics
Suggests: testthat (≥ 3.0.0), glmmTMB, nlme, mgcv, survival, coxme, brms
Config/testthat/edition: 3
URL: https://github.com/vinodhpmd/BioMixModel
BugReports: https://github.com/vinodhpmd/BioMixModel/issues
Config/roxygen2/version: 8.1.0
NeedsCompilation: no
Packaged: 2026-09-12 15:31:19 UTC; m
Author: Vinodhkumar Obli Rajendran [aut, cre], Keerthi Aaradhana [aut]
Maintainer: Vinodhkumar Obli Rajendran <vinodhkumar.rajendran@gmail.com>
Repository: CRAN
Date/Publication: 2026-09-22 06:50:11 UTC

Compare BioMixModel fits

Description

Compare BioMixModel fits

Usage

compare_biomix(...)

Arguments

...

biomix models.

Value

Comparison data frame.


Diagnose a BioMixModel fit

Description

Diagnose a BioMixModel fit

Usage

diagnose_biomix(model)

Arguments

model

A biomix model.

Value

Diagnostic data frame.


Fit a Bayesian mixed-effects model

Description

Fits a Bayesian mixed-effects model using brms.

Usage

fit_bayes_mix(formula, data, family = "gaussian", ...)

Arguments

formula

A model formula containing fixed and random effects.

data

A data frame.

family

Character family name or a brms family object.

...

Additional arguments passed to brms::brm().

Value

An object of class biomix_bayes.


Fit a biological mixed model

Description

Fits either an ordinary linear model or a linear mixed-effects model.

Usage

fit_biomix(formula, data, random = NULL, method = c("REML", "ML"))

Arguments

formula

Model formula containing fixed effects.

data

Data frame.

random

Optional random-effects specification as a one-sided formula, e.g. ~ 1 | subject or ~ time | subject.

method

Estimation method: "REML" or "ML".

Value

An object of class biomix.


Fit a generalized additive mixed model

Description

Fits a generalized additive mixed model using mgcv.

Usage

fit_gamm(formula, data, random = NULL, ...)

Arguments

formula

A GAM formula.

data

A data frame containing the response and predictors.

random

Optional random-effects specification.

...

Additional arguments passed to mgcv::gam() or mgcv::gamm().

Value

An object of class biomix_gamm.


Fit a generalized linear mixed-effects model

Description

Fits generalized linear mixed-effects models using glmmTMB. Supported distributions include binomial, Poisson, and negative-binomial models. Zero-inflated models can be fitted using ziformula.

Usage

fit_glmm(
  formula,
  data,
  family = c("binomial", "poisson", "nbinom1", "nbinom2"),
  ziformula = ~0,
  dispformula = ~1,
  ...
)

Arguments

formula

A model formula containing fixed and random effects.

data

A data frame.

family

Distribution. Supported values are "binomial", "poisson", "nbinom1", and "nbinom2".

ziformula

Formula for the zero-inflation component. The default ~0 specifies no zero-inflation component.

dispformula

Formula for the dispersion component.

...

Additional arguments passed to glmmTMB::glmmTMB().

Value

An object of class biomix_glmm.

Examples


dat <- data.frame(
  y = rpois(100, 5),
  x = rnorm(100),
  id = factor(rep(1:20, each = 5))
)

model <- fit_glmm(
  y ~ x + (1 | id),
  data = dat,
  family = "poisson"
)



Fit a multivariate mixed-effects model

Description

Fits a multivariate mixed-effects model using brms.

Usage

fit_multivariate(formulas, data, ...)

Arguments

formulas

A list of model formulas.

data

A data frame.

...

Additional arguments passed to brms::brm().

Value

An object of class biomix_multivariate.


Fit a nonlinear mixed-effects model

Description

Fits a nonlinear mixed-effects model using nlme.

Usage

fit_nlme_biomix(formula, data, fixed, random, start, ...)

Arguments

formula

Nonlinear model formula.

data

Data frame containing the response, predictors, and grouping variables.

fixed

Fixed-effects specification for nonlinear parameters.

random

Random-effects specification for nonlinear parameters.

start

Starting values for the nonlinear parameters.

...

Additional arguments passed to nlme::nlme().

Value

An object of class biomix_nlmm.


Fit a nonlinear mixed-effects model

Description

Fits nonlinear mixed-effects models using nlme.

Usage

fit_nlmm(
  model,
  data,
  fixed = NULL,
  random = NULL,
  start = NULL,
  method = c("REML", "ML"),
  ...
)

Arguments

model

Nonlinear model formula.

data

Data frame containing the response, predictors, and grouping variables.

fixed

Fixed-effects specification for the nonlinear parameters.

random

Random-effects specification for the nonlinear parameters.

start

Optional starting values for the nonlinear parameters.

method

Estimation method, "REML" or "ML".

...

Additional arguments passed to nlme::nlme().

Value

An object of class biomix_nlmm.


Fit a spatial mixed-effects model

Description

Fits a spatial mixed-effects model using a user-specified spatial correlation structure.

Usage

fit_spatial_mix(formula, data, correlation = NULL, ...)

Arguments

formula

Model formula.

data

Data frame.

correlation

Spatial correlation structure.

...

Additional arguments passed to nlme::lme().

Value

An object of class biomix_spatial.


Fit a survival mixed-effects model

Description

Fits frailty/mixed-effects Cox models using coxme.

Usage

fit_survival_mix(formula, data, ...)

Arguments

formula

A survival model formula.

data

Data frame.

...

Additional arguments passed to coxme::coxme().

Value

An object of class biomix_survival.


Extract the fitted model

Description

Extract the fitted model

Usage

get_fit(model)

Arguments

model

A BioMixModel object.

Value

The underlying fitted model.


Heterogeneity-aware Akaike information criterion

Description

Calculates HAIC by adding a heterogeneity penalty to AIC.

Usage

haic(model)

Arguments

model

A biomix model.

Value

Numeric HAIC.


Intraclass correlation coefficient

Description

Calculates the proportion of variance attributable to random effects.

Usage

icc_biomix(model)

Arguments

model

A biomix model.

Value

Numeric ICC.


Compact model summary

Description

Compact model summary

Usage

model_summary(model)

Arguments

model

A biomix model.

Value

A list of model statistics.


Summary for nonlinear mixed-effects BioMixModel

Description

Summary for nonlinear mixed-effects BioMixModel

Summarize a nonlinear mixed-effects model

Usage

## S3 method for class 'biomix_nlmm'
model_summary(model)

## S3 method for class 'biomix_nlmm'
model_summary(model)

Arguments

model

A biomix_nlmm model.

Value

A list containing nonlinear mixed-model statistics.

A list of model statistics.


Plot diagnostic residuals

Description

Plot diagnostic residuals

Usage

plot_biomix(model, type = c("residuals", "qq"))

Arguments

model

A biomix model.

type

Plot type, "residuals" or "qq".

Value

Invisibly returns the model.


Variance partitioning

Description

Extracts variance components from a BioMixModel fit.

Usage

variance_partition(model)

Arguments

model

A biomix model.

Value

Data frame containing variance components and proportions.