codalm: Transformation-free Linear Regression for Compositional...

View source: R/codalm_em.R

codalmR Documentation

Transformation-free Linear Regression for Compositional Outcomes and Predictors

Description

Implements the expectation-maximization (EM) algorithm as described in Fiksel et al. (2022) for transformation-free linear regression for compositional outcomes and predictors.

Usage

codalm(y, x, accelerate = TRUE)

Arguments

y

A matrix of compositional outcomes. Each row is an observation, and must sum to 1. If any rows do not sum to 1, they will be renormalized

x

A matrix of compositional predictors. Each row is an observation, and must sum to 1. If any rows do not sum to 1, they will be renormalized

accelerate

A logical variable, indicating whether or not to use the Squarem algorithm for acceleration of the EM algorithm. Default is TRUE.

Value

A D_s x D_r compositional coefficient matrix, where D_s and D_r are the dimensions of the compositional predictor and outcome, respectively

References

\Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/biom.13465")}

Examples

require(ggtern)
data("WhiteCells", package = 'ggtern')
image <- subset(WhiteCells, Experiment == "ImageAnalysis")
image_mat <- as.matrix(image[,c("G", "L", "M")])
microscopic <- subset(WhiteCells, Experiment == "MicroscopicInspection")
microscopic_mat <- as.matrix(microscopic[,c("G", "L", "M")])
x <- image_mat  / rowSums(image_mat)
y <- microscopic_mat / rowSums(microscopic_mat)
codalm(y, x)

codalm documentation built on Dec. 11, 2025, 5:08 p.m.