cnvrg_VI {CNVRG}R Documentation

Perform variational inference sampling

Description

This function uses a compiled Dirichlet multinomial model and performs variational inference estimation of posteriors using 'Stan'. Evaluating the performance of variational inference is currently under development per our understanding. Please roll over to the 'Stan' website and see if new diagnostics are available. If you use this function then credit 'Stan' and 'RStan' along with this package.

Usage

cnvrg_VI(
  countData,
  starts,
  ends,
  algorithm = "meanfield",
  output_samples = 500,
  params_to_save = c("pi", "p")
)

Arguments

countData

A matrix or data frame of counts.The first field should be sample names and the subsequent fields should be integer data. Data should be arranged so that the first n rows correspond to one treatment group and the next n rows correspond with the next treatment group, and so on. The row indices for the first and last sample in these groups are fed into this function via 'starts' and 'ends'.

starts

A vector defining the indices that correspond to the first sample in each treatment group. The indexer function can help with this.

ends

A vector defining the indices that correspond to the last sample in each treatment group. The indexer function can help with this.

algorithm

The algorithm to use when performing variational inference. Either 'meanfield' or 'fullrank'. The former is the default.

output_samples

The number of samples from the approximated posterior to save.

params_to_save

The parameters from which to save samples. Can be 'p', 'pi', 'theta'.

Details

It can be helpful to use the indexer function to automatically identify the indices needed for the 'starts' and 'ends' parameters. See the vignette for an example.

Warning: data must be input in the correct organized format or this function will not provide accurate results. See vignette if you are unsure how to organize data. Warning: depending upon size of data to be analyzed this function can take a very long time to run.

Value

A fitted 'Stan' object that includes the samples from the parameters designated.

Examples

#simulate an OTU table

[Package CNVRG version 1.0.0 Index]