sample,lnm-method {miniLNM}R Documentation

LNM Fitted Probabilities

Description

Given an input dataset, sample compositions that are consistent with the input. Specifically, this samples from a multinomial with mean \phi^{-1}(Bx). The default depth is 5e4. Modify the "depth" parameter to change this.

Usage

## S4 method for signature 'lnm'
sample(x, size = 1, depth = 50000, newdata = NULL, ...)

Arguments

x

An object of class lnm with fitted parameters \hat{B} and which we want to use to form predictions on new samples.

size

The number of samples to generate.

depth

The depth to use when sampling the multinomial for each simulated element.

newdata

New samples on which to form predictions. Defaults to NULL, in which case predictions are made at the same design points as those used during the original training.

...

Additional keyword arguments, for consistency with R's predict generic (never used).

Value

A matrix of dimension size x n_outcomes, where each row represents one sample from the posterior predictive of the fitted logistic-normal multinomial model. Each row sums up to the depth argument, which defaults to 5e4.

Examples

example_data <- lnm_data(N = 50, K = 10)
xy <- dplyr::bind_cols(example_data[c("X", "y")])
fit <- lnm(
    starts_with("y") ~ starts_with("x"), xy, 
    iter = 25, output_samples = 25
)
head(sample(fit))

[Package miniLNM version 0.1.0 Index]