Skip to contents

Apply a logistic normal multinomial model to jointly model a vector of count responses $y$ in an outcome or mediation model. This is a common choice for data where the parameter of interest is the composition across responses (e.g., microbiome).

Usage

lnm_model(...)

Arguments

...

Keyword parameters passed to lnm in the 'miniLNM' package.

Value

model An object of class model with estimator, predictor, and sampler functions associated wtih a linear model.

See also

model lm_model rf_model glmnet_model brms_model

Examples

m <- lnm_model()
mat <- data.frame(matrix(rpois(250, 10), 25, 10))
colnames(mat) <- paste0("y", seq_len(6))
fit <- estimator(m)(y1 + y2 + y3 + y4 ~ y5 + y6, mat)
#> Chain 1: ------------------------------------------------------------
#> Chain 1: EXPERIMENTAL ALGORITHM:
#> Chain 1:   This procedure has not been thoroughly tested and may be unstable
#> Chain 1:   or buggy. The interface is subject to change.
#> Chain 1: ------------------------------------------------------------
#> Chain 1: 
#> Chain 1: 
#> Chain 1: 
#> Chain 1: Gradient evaluation took 9e-05 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.9 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: Begin eta adaptation.
#> Chain 1: Iteration:   1 / 250 [  0%]  (Adaptation)
#> Chain 1: Iteration:  50 / 250 [ 20%]  (Adaptation)
#> Chain 1: Iteration: 100 / 250 [ 40%]  (Adaptation)
#> Chain 1: Iteration: 150 / 250 [ 60%]  (Adaptation)
#> Chain 1: Iteration: 200 / 250 [ 80%]  (Adaptation)
#> Chain 1: Success! Found best value [eta = 1] earlier than expected.
#> Chain 1: 
#> Chain 1: Begin stochastic gradient ascent.
#> Chain 1:   iter             ELBO   delta_ELBO_mean   delta_ELBO_med   notes 
#> Chain 1:    100        -5574.268             1.000            1.000
#> Chain 1:    200         -350.516             7.952           14.903
#> Chain 1:    300         -293.670             5.366            1.000
#> Chain 1:    400         -255.233             4.062            1.000
#> Chain 1:    500         -248.825             3.255            0.194
#> Chain 1:    600         -262.916             2.721            0.194
#> Chain 1:    700         -250.397             2.340            0.151
#> Chain 1:    800         -256.953             2.050            0.151
#> Chain 1:    900         -283.830             1.833            0.095
#> Chain 1:   1000         -245.215             1.665            0.151
#> Chain 1:   1100         -244.821             1.566            0.095   MAY BE DIVERGING... INSPECT ELBO
#> Chain 1:   1200         -248.446             0.077            0.054
#> Chain 1:   1300         -265.950             0.064            0.054
#> Chain 1:   1400         -263.389             0.050            0.050
#> Chain 1:   1500         -257.201             0.050            0.050
#> Chain 1:   1600         -247.242             0.048            0.040
#> Chain 1:   1700         -242.917             0.045            0.026
#> Chain 1:   1800         -245.240             0.044            0.024
#> Chain 1:   1900         -242.659             0.035            0.018
#> Chain 1:   2000         -241.643             0.020            0.015
#> Chain 1:   2100         -243.343             0.020            0.015
#> Chain 1:   2200         -250.057             0.022            0.018
#> Chain 1:   2300         -246.020             0.017            0.016
#> Chain 1:   2400         -246.665             0.016            0.016
#> Chain 1:   2500         -240.445             0.016            0.016
#> Chain 1:   2600         -240.664             0.012            0.011
#> Chain 1:   2700         -242.534             0.011            0.009   MEDIAN ELBO CONVERGED
#> Chain 1: 
#> Chain 1: Drawing a sample of size 1000 from the approximate posterior... 
#> Chain 1: COMPLETED.
#> Warning: Pareto k diagnostic value is 1.29. Resampling is disabled. Decreasing tol_rel_obj may help if variational algorithm has terminated prematurely. Otherwise consider using sampling instead.