Draw samples from posterior distributions of fitted models
Source:R/get_posterior.R
getPosteriorSamples.Rd
This is an optional step in an analysis using limorhyde2
, and is useful for
quantifying uncertainty in posterior estimates of fitted curves and rhythmic
statistics. The function calls mashr::mash_compute_posterior_matrices()
.
Arguments
- fit
A `limorhyde2' object containing posterior fits.
- nPosteriorSamples
Number of samples to draw from each posterior distribution.
- overwrite
Logical indicating whether to recompute posterior samples if they already exist.
Value
A limorhyde2
object containing everything in fit
with added or
updated element:
mashPosteriorSamples
: a three-dimensional array of coefficients, with dim 1 corresponding to features, dim 2 to model terms, and dim 3 to posterior samples.
Examples
library('data.table')
y = GSE54650$y
metadata = GSE54650$metadata
fit = getModelFit(y, metadata)
fit = getPosteriorFit(fit)
fit = getPosteriorSamples(fit, nPosteriorSamples = 10L)
rhyStatsSamps = getRhythmStats(
fit, features = c('13170', '13869'), fitType = 'posterior_samples')
rhyStatsInts = getStatsIntervals(rhyStatsSamps)