Blog Archives

MALA – Metropolis Adjusted Langevin Algorithm in Julia

MALA – Metropolis Adjusted Langevin Algorithm in Julia

Metropolis Adjusted Langevin Algorithm (MALA) Haven’t dumped much code here in a while. Here’s a Julia implementation of MALA with an arbitrary preconditioning matrix M. Potentially I might use this in the future. Generic Julia Implementation Arguments are a function to evaluate the logdensity, function to evaluate the gradient, a step size h, a preconditioning […] The post MALA – Metropolis Adjusted Langevin Algorithm in Julia appeared first on I've…

Read more »

Generate Random Inverse Gaussian in R

Generate Random Inverse Gaussian in R

Needed to generate draws from an inverse Gaussian today, so I wrote the following Rcpp code: It seems to be faster than existing implementations such as rig from mgcv and rinvgauss from statmod packages. rename rrinvgauss as desired. The post Generate Random Inverse Gaussian in R appeared first on I've Moved! Click Here .

Read more »

Generalized Double Pareto Priors for Regression

Generalized Double Pareto Priors for Regression

This post is a review of the “GENERALIZED DOUBLE PARETO SHRINKAGE” Statistica Sinica (2012) paper by Armagan, Dunson and Lee. Consider the regression model \(Y=X\beta+\varepsilon\) where we put a generalized double pareto distribution as the prior on the regression coefficients \(\beta\). The GDP distribution has density $$\begin{equation} f(\beta|\xi,\alpha)=\frac{1}{2\xi}\left( 1+\frac{|\beta|}{\alpha\xi} \right)^{-(\alpha+1)}. \label{} \end{equation}$$ GDP as Scale […] The post Generalized Double Pareto Priors for Regression appeared first on I've Moved! Click…

Read more »

EM Algorithm for Bayesian Lasso R Cpp Code

EM Algorithm for Bayesian Lasso R Cpp Code

Bayesian Lasso $$\begin{align*} p(Y_{o}|\beta,\phi)&=N(Y_{o}|1\alpha+X_{o}\beta,\phi^{-1} I_{n{o}})\\ \pi(\beta_{i}|\phi,\tau_{i}^{2})&=N(\beta_{i}|0, \phi^{-1}\tau_{i}^{2})\\ \pi(\tau_{i}^{2})&=Exp \left( \frac{\lambda}{2} \right)\\ \pi(\phi)&\propto \phi^{-1}\\ \pi(\alpha)&\propto 1\\ \end{align*}$$ Marginalizing over \(\alpha\) equates to centering the observations and losing a degree of freedom and working with the centered \( Y_{o} \). Mixing over \(\tau_{i}^{2}\) leads to a Laplace or Double Exponential prior on \(\beta_{i}\) with rate parameter \(\sqrt{\phi\lambda}\) […] The post EM Algorithm for Bayesian Lasso R Cpp Code appeared first on I've…

Read more »

Compile R and OpenBLAS from Source Guide

Compile R and OpenBLAS from Source Guide

1. Get OpenBLAS 2.1 Get R 2.2 Specific Instructions for DSS Users 3. Validation 4. Benchmark This guide is intended to aid any R and Linux user who desires a threaded version of BLAS. In particular I hope this will allow other grad students, who like me do not have many user privileges on their […] The post Compile R and OpenBLAS from Source Guide appeared first on I've Moved!…

Read more »

Monotonicity of EM Algorithm Proof

Here the monotonicity of the EM algorithm is established. $$ f_{o}(Y_{o}|\theta)=f_{o,m}(Y_{o},Y_{m}|\theta)/f_{m|o}(Y_{m}|Y_{o},\theta)$$ $$ \log L_{o}(\theta)=\log L_{o,m}(\theta)-\log f_{m|o}(Y_{m}|Y_{o},\theta) \label{eq:loglikelihood} $$ where \( L_{o}(\theta)\) is the likelihood under the observed data and \(L_{o,m}(\theta)\) is the likelihood under the complete data. Taking the expectation of the second line with respect to the conditional distribution of \(Y_{m}\) given \(Y_{o}\) and […] The post Monotonicity of EM Algorithm Proof appeared first on I've Moved! Click Here…

Read more »

C++11 versus R Standalone Random Number Generation Performance Comparison

If you are writing some C++ code with the intent of calling it from R or even developing it into a package you might wonder whether it is better to use the pseudo random number library native to C++11 or the R standalone library. On the one hand users of your package might have an […] The post C++11 versus R Standalone Random Number Generation Performance Comparison appeared first on…

Read more »

Stochastic Optimization in R by Parallel Tempering

Stochastic Optimization in R by Parallel Tempering

I’ve written a few posts now about using parallel tempering to sample from complicated multi-modal target distributions but there are also other benefits and uses to this algorithm. There is a nice post on Darren Wilkinson’s blog about using tempered posteriors for marginal likelihood calculations. There is also another area where parallel tempering finds application, […] The post Stochastic Optimization in R by Parallel Tempering appeared first on I've Moved!…

Read more »

Parallel Tempering in R with Rmpi

Parallel Tempering in R with Rmpi

My office computer recently got a really nice upgrade and now I have 8 cores on my desktop to play with. I also at the same time received some code for a Gibbs sampler written in R from my adviser. I wanted to try a metropolis-coupled markov chain monte carlo, , algorithm on it to […] The post Parallel Tempering in R with Rmpi appeared first on I've Moved! Click…

Read more »

Easy 3-Minute Guide to Making apply() Parallel over Distributed Grids and Clusters in R

Easy 3-Minute Guide to Making apply() Parallel over Distributed Grids and Clusters in R

Last week I attended a workshop on how to run highly parallel distributed jobs on the Open Science Grid (osg). There I met Derek Weitzel who has made an excellent contribution to advancing R as a high performance computing language by developing BoscoR. BoscoR greatly facilitates the use of the already existing package “GridR” by […] The post Easy 3-Minute Guide to Making apply() Parallel over Distributed Grids and Clusters…

Read more »


Subscribe

Email:

  Subscribe