Learn R Programming

multilevelcoda

Overview

This package provides functions to model compositional data in a multilevel framework using full Bayesian inference. It integrates the principes of Compositional Data Analysis (CoDA) and Multilevel Modelling and supports both compositional data as an outcome and predictors in a wide range of generalized (non-)linear multivariate multilevel models.

Installation

To install the latest release version from CRAN, run

install.packages("multilevelcoda")

The current developmental version can be downloaded from github via

if (!requireNamespace("remotes")) {
  install.packages("remotes")
}
remotes::install_github("florale/multilevelcoda")

Because multilevelcoda is built on brms, which is based on Stan, a C++ compiler is required. The program Rtools (available on https://cran.r-project.org/bin/windows/Rtools/) comes with a C++ compiler for Windows. On Mac, Xcode is required. For further instructions on how to get the compilers running, see the prerequisites section on https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started.

Resources

You can learn about the package from these vignettes:

Citing multilevelcoda and related software

When using multilevelcoda, please cite one or more of the following publications:

  • Le F., Dumuid D., Stanford T. E., Wiley J. F. (2024). Bayesian multilevel compositional data analysis with the R package multilevelcoda. arXiv preprint arXiv:2411.12407.
  • Le, F., Stanford, T. E., Dumuid, D., & Wiley, J. F. (2024). Bayesian Multilevel Compositional Data Analysis: Introduction, Evaluation, and Application. arXiv preprint arXiv:2405.03985.

As multilevelcoda depends on brms and Stan, please also consider citing:

  • Bürkner P. C. (2017). brms: An R Package for Bayesian Multilevel Models using Stan. Journal of Statistical Software. 80(1), 1-28. doi.org/10.18637/jss.v080.i01
  • Bürkner P. C. (2018). Advanced Bayesian Multilevel Modeling with the R Package brms. The R Journal. 10(1), 395-411. doi.org/10.32614/RJ-2018-017
  • Bürkner P. C. (2021). Bayesian Item Response Modeling in R with brms and Stan. Journal of Statistical Software, 100(5), 1-54. doi.org/10.18637/jss.v100.i05
  • Stan Development Team. YEAR. Stan Modeling Language Users Guide and Reference Manual, VERSION. https://mc-stan.org
  • Carpenter B., Gelman A., Hoffman M. D., Lee D., Goodrich B., Betancourt M., Brubaker M., Guo J., Li P., and Riddell A. (2017). Stan: A probabilistic programming language. Journal of Statistical Software. 76(1). doi.org/10.18637/jss.v076.i01

Copy Link

Version

Install

install.packages('multilevelcoda')

Monthly Downloads

298

Version

1.3.1

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Flora Le

Last Published

November 23rd, 2024

Functions in multilevelcoda (1.3.1)

compilr

Indices from a (dataset of) Multilevel Composition(s) (deprecated.)
complr

Indices from a (dataset of) Multilevel Composition(s)
bayes_factor.brmcoda

Bayes Factors from Marginal Likelihoods
VarCorr.brmcoda

Extract Variance and Correlation Components
nobs.brmcoda

Extract Number of Observations from brmcoda object
brmcoda

Fit Bayesian generalised (non-)linear multilevel compositional model via full Bayesian inference
is.substitution

Checks if argument is a substitution object
as.data.frame.complr

Extract Compositional Data from complr object.
launch_shinystan.brmcoda

Interface to shinystan
build.basesub

Build Base Pairwise Substitution
psub

Possible Pairwise Substitutions
build.sbp

Build Sequential Binary Partition
pairs.brmcoda

Create a matrix of output plots from a brmcoda's brmsfit object
coef.brmcoda

Model Coefficients
ranef.brmcoda

Group-Level Estimates
summary.pivot_coord

Create a Summary of a fitted brmsfit model from a pivot_coord object
build.rg

Reference Grid for substitution model.
fixef.brmcoda

Population-Level Estimates
is.brmcoda

Checks if argument is a brmcoda object
summary.substitution

Create a Summary of a Substitution Model represented by a substitution object
is.complr

Checks if argument is a complr object
get-substitution

Helper functions used only internally to estimate substitution model
pivot_coord

Estimate pivot balance coordinates
pivot_coord_refit

Estimate pivot balance coordinates by refitting model.
pivot_coord_rotate

Estimate pivot balance coordinates by rotating sequential binary partition.
plot.brmcoda

Trace and Density Plots for MCMC Draws plot
wsub

Within-person Simple Substitution
submargins

Average Substitution
wsubmargins

Within-person Average Substitution
substitution

Multilevel Compositional Substitution Analysis
bsub

Between-person Simple Substitution
loo.brmcoda

Efficient approximate leave-one-out cross-validation (LOO)
create_substitution

Constructor function for substitution class.
diagnostic-quantities-brmcoda

Extract Diagnostic Quantities from brmsfit Models in brmcoda
mcmc_plot.brmcoda

MCMC Plots Implemented in bayesplot
print.complr

Print a Summary for a complr object
print.substitution

Print a Summary for a substitution object
model.frame.brmcoda

Extracting the Model Frame from a Formula or Fit from brmcoda object
multilevelcoda_sim

multilevelcoda Simulation Study Results
bsubmargins

Between-person Average Substitution
print.summary.complr

Summary for a complr object
prior_summary.brmcoda

Extract Priors of a brmsfit from a brmcoda object
plot.substitution

Substitution Plot
summary.brmcoda

Create a Summary of a fitted brmsfit model in a brmcoda object
summary.complr

Create a Summary of a complr object
pp_check.brmcoda

Posterior Predictive Checks for brmcoda Objects
draws-index-brmcoda

Index brmcoda objects
fitted.brmcoda

Expected Values of the Posterior Predictive Distribution
mcompd

Multilevel Compositional Data
sim

multilevelcoda Simulation Study results
mean.complr

Mean amounts and mean compositions presented in a complr object.
sub

Simple Substitution
predict.brmcoda

Draws from the Posterior Predictive Distribution
update.brmcoda

Update brmcoda models
print.brmcoda

Print a Summary for a fitted brmsfit model in a brmcoda object
residuals.brmcoda

Posterior Draws of Residuals/Predictive Errors
sbp

Sequential Binary Partition
var.complr

Variance of compositions presented in a complr object.
vcov.brmcoda

Covariance and Correlation Matrix of Population-Level Effects
update.complr

Update complr