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

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

https://arxiv.org/abs/2004.07881

Examples

require(ggtern)
#> Loading required package: ggtern
#> Loading required package: ggplot2
#> Registered S3 methods overwritten by 'ggtern': #> method from #> grid.draw.ggplot ggplot2 #> plot.ggplot ggplot2 #> print.ggplot ggplot2
#> -- #> Remember to cite, run citation(package = 'ggtern') for further info. #> --
#> #> Attaching package: ‘ggtern’
#> The following objects are masked from ‘package:ggplot2’: #> #> aes, annotate, ggplot, ggplot_build, ggplot_gtable, ggplotGrob, #> ggsave, layer_data, theme_bw, theme_classic, theme_dark, #> theme_gray, theme_light, theme_linedraw, theme_minimal, theme_void
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)
#> [,1] [,2] [,3] #> [1,] 9.742582e-01 0.02292755 2.814241e-03 #> [2,] 3.267605e-09 1.00000000 3.620972e-10 #> [3,] 9.484137e-18 0.04198815 9.580118e-01