We present vir, an R package for variational inference with shrinkage priors. Our package implements variational and stochastic variational algorithms for linear and probit regression models, the use of which is a common first step in many applied analyses. We review variational inference and show how the derivation for a Gibbs sampler can be easily modified to derive a corresponding variational or stochastic variational algorithm. We provide simulations showing that, at least for a normal linear model, variational inference can lead to similar uncertainty quantification as the corresponding Gibbs samplers, while estimating the model parameters at a fraction of the computational cost. Our timing experiments show situations in which our algorithms converge faster than the frequentist LASSO implementations in glmnet while simultaneously providing superior parameter estimation and variable selection. Hence, our package can be utilized to quickly explore different combinations of predictors in a linear model, while providing accurate uncertainty quantification in many applied situations. The package is implemented natively in R and RcppEigen, which has the benefit of bypassing the substantial operating system specific overhead of linking external libraries to work efficiently with R.
翻译:我们提出一个R包, 用于使用缩缩前的变异性推断。 我们的包件对线性模型和斜线回归模型采用变异性和随机性变异算法, 在许多应用分析中, 使用这种算法是常见的第一步。 我们审查变异推法, 并展示Gibbs取样器的推算方法如何容易修改, 以得出相应的变异或随机变异算法。 我们提供的模拟显示, 至少在正常的线性模型中, 变异推论可能导致与相应的Gibs采样器相似的不确定性量化, 同时以计算成本的一部分估算模型参数参数。 我们的计时实验显示, 我们的算法比在 glmnet 中经常使用 LASSO 执行的测算法速度更快, 同时提供较高的参数估计和变量选择。 因此, 我们的包件可以用来快速探索线性模型中不同的预测器组合, 同时在许多应用的情况下提供准确的不确定性量化。 包件在R 和 RcppEigen 本地实施, 其好处是绕过外部图书馆与R 高效连接工作的实质性操作的操作系统。