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.
fitYou 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.