Learn R Programming

miniLNM

library(miniLNM)
library(dplyr)
knitr::knit_hooks$set(output = miniLNM::ansi_aware_handler)
options(crayon.enabled = TRUE)

miniLNM is a lightweight package for fitting and using logistic-normal multinomial models. It wraps a simple ‘Stan’ script (see inst/stan/ folder in the source code) and defines an S4 class that makes it easy to specify, estimate, and draw samples from the fit. For example, you can use tidyselect syntax to relate multiple compositional outputs to a set of influential biological factors.

example_data <- lnm_data()
xy <- bind_cols(example_data[c("X", "y")])
fit <- lnm(starts_with("y") ~ starts_with("x"), xy)
## Warning: Pareto k diagnostic value is 12.45. Resampling is disabled. Decreasing tol_rel_obj may help if variational algorithm has terminated prematurely. Otherwise consider using sampling instead.

The print method gives a concise summary of the fitted model, which is easier to read than the full ‘Stan’ output.

fit

You can also use predict, like in ordinary linear models, and can draw posterior predictive samples using sample.

p_hat <- predict(fit)
y_star <- sample(fit, depth = 200)

Help

We welcome questions and comments about the package either through github or email.

Copy Link

Version

Install

install.packages('miniLNM')

Monthly Downloads

174

Version

0.1.0

License

CC0

Issues

Pull Requests

Stars

Forks

Maintainer

Kris Sankaran

Last Published

September 13th, 2024

Functions in miniLNM (0.1.0)

lnm

Fit a logistic normal multinomial model using R's formula interface.
ansi_aware_handler

Pretty Printing
predict,lnm-method

LNM Fitted Probabilities
beta_samples

LNM Posterior Samples
prepare_newdata

Design Matrix for a Model
phi_inverse

Inverse log ratio transformation
sample,lnm-method

LNM Fitted Probabilities
lnm-class

S4 Class for a Logistic Normal Multinomial Model
lnm_data

Simulates data from a Logistic Normal Multinomial Model.
beta_mean

LNM Posterior Mean