FitAllShrink: Applies INLA to multiple data rows using shrinkage priors.

View source: R/FitAllShrink.R

FitAllShrinkR Documentation

Applies INLA to multiple data rows using shrinkage priors.

Description

This is a wrapper function that facilitates multiple calls to INLA using parallel processing. It currently supports the following univariate likelihoods: Poisson, negative binomial, zero-inflated negative binomial, Gaussian. It uses the output from ShrinkSeq or ShrinkGauss as input for the prior parameters.

Usage

FitAllShrink(forms, dat, shrinksimul, finalprior=FALSE, dispersefixed = 10, disperseaddfixed = 1, disperserandom = 1, maxprecfixed = 4, fams = "zinb", ncpus = 2, 
effoutput = TRUE, keepmargrand = FALSE, keepmarghyper = TRUE, setthreads1 = TRUE, showupdate = FALSE, silentINLA = TRUE, updateby = 5000, 
ndigits = 5, addpackage = NULL, safemode = TRUE, designlist=NULL, ...)

Arguments

forms

Formula, or list of formulas the length of which equals the number of data rows. See inla and f for specification of the model formula.

dat

Matrix, data frame or list containing the data. Rows are features, columns are samples. For lists: each component represents a feature.

shrinksimul

A list object resulting from ShrinkSeq or ShrinkGauss

finalprior

Boolean. If TRUE, dispersefixed, disperseaddfixed, disperserandom are all set to 1.

dispersefixed

Numeric. Inflation factor for the variance of the main fixed parameter.

disperseaddfixed

Numeric. Inflation factor for the variance of the additional fixed parameter.

disperserandom

Numeric. Inflation factor for the variance of the random effects precision.

maxprecfixed

Numeric. Maximum precision used for the main fixed effect.

fams

Character string. Either equal to "poisson", "zip" (zero-inflated Poisson), "nb" (negative binomial), or "zinb" (zero-inflated negative binomial), "gaussian": likelihood to be used.

ncpus

Integer. The number of cpus to use for parallel computations.

effoutput

Boolean. If FALSE, all INLA output will be saved. If TRUE, some fields will be deleted.

keepmargrand

Boolean. Do you wish to save the marginals of the random effect regression parameters (beta's)?

keepmarghyper

Boolean. Do you wish to save the marginals of the hyper-parameters?

setthreads1

Boolean. If TRUE, sequential computation is forced within each call to inla.

showupdate

Boolean. Do you wish to see updates on progression of the computation? TRUE may slow down the computations due to less efficient parallel computation.

silentINLA

Boolean. Do you wish to silence the output of inla? NOTE: currently not all INLA output can be silenced.

updateby

Integer, only relevant when showupdate=TRUE. Show an update for each updateby number of features executed.

ndigits

Integer. Numerical precision in digits for the output.

addpackage

Character string. Additional package that you wish to export to slave nodes when parallel computing.

safemode

Boolean. Only relevant for fams="zinb" or fams="nb". If fitting fails, should it re-run in a safe mode?

designlist

List. Components are data frames containting the variables in form. Length of list should equal nr of features in data. If NULL design is assumed to be the same for all features (and inferred from form)

...

Further arguments passed on to inla.

Details

dispersefixed, disperseaddfixed and disperserandom can be used to fit under a flatter prior than the one found by the joint shrinkage procedures ShrinkSeq or ShrinkGauss. This is typically useful when one aims to empirically fit a mixture prior or nonparametric prior for the main fixed or random parameter (see MixtureUpdatePrior or NonParaUpdatePrior). finalprior=FALSE should be used in combination with MixtureUpdatePrior or NonParaUpdatePrior, while finalprior=TRUE should be used in combination with BFUpdatePosterior or SpikeSlabUpdatePosterior, because the latter two functions do not further update the prior.

About setthreads1: usually it is computationally most efficient to use only one node (thread) per INLA call. About addpackage: sometimes the formula contains a call to an external package (e.g. for fitting splines). If so, this package needs to be specified for exporting to slave nodes when computing parallelly. About safemode: if TRUE, then features for which fitting fails when the size parameter of the NB or ZI-NB are estimated are re-fitted with fixed size parameter, which equals the prior mean.

Value

Two-component list object.

res

A list of length nrow(dat) containing inla output for each data row

priors

A list passing through all information on priors present in shrinksimul

Note

Extensions to the supported likelihoods (including multivariate ones) may be released in the feature

Author(s)

Mark A. van de Wiel

References

Rue H, Martino S and Chopin N (2009). Approximate Bayesian inference for latent Gaussian models by using integrated nested Laplace approximations (with discussion). J. R. Statist. Soc. B, 71, 319-392. www.r-inla.org

Van de Wiel MA, Leday GGR, Pardo L, Rue H, Van der Vaart AW, Van Wieringen WN (2012). Bayesian analysis of RNA sequencing data by estimating multiple shrinkage priors. Biostatistics.

See Also

www.r-inla.org, ShrinkSeq, ShrinkGauss

Examples

#See ShrinkSeq, ShrinkGauss and CombinePosteriors

markvdwiel/ShrinkBayes documentation built on March 27, 2022, 7:47 p.m.