This post is part of a running series on Bayesian MCMC tutorials. For updates, follow @StableMarkets. Metropolis Review Metropolis-Hastings is an MCMC algorithm for drawing samples from a distribution known up to a constant of proportionality, $latex p(\theta | y) \propto p(y|\theta)p(\theta)$. Very briefly, the algorithm works by starting with some initial draw $latex \theta^{(0)}$ then running … Continue reading Efficient MCMC with Caching

# Category: Numerical Methods

# Speeding up Metropolis-Hastings with Rcpp

Previous posts in this series on MCMC samplers for Bayesian inference (in order of publication): Bayesian Simple Linear Regression with Gibbs Sampling in R Blocked Gibbs Sampling in R for Bayesian Multiple Linear Regression Metropolis-in-Gibbs Sampling and Runtime Analysis with Profviz The code for all of these posts can be found in my BayesianTutorials GitHub … Continue reading Speeding up Metropolis-Hastings with Rcpp

# Exploring P-values with Simulations in R

The recent flare-up in discussions on p-values inspired me to conduct a brief simulation study. In particularly, I wanted to illustrate just how p-values vary with different effect and sample sizes. Here are the details of the simulation. I simulated $latex n $ draws of my independent variable $latex X $: $latex X_n \sim N(100, 400)$ where $latex … Continue reading Exploring P-values with Simulations in R

# Finding and Plotting Lorenz Solution using MATLAB

I use MATLAB to solve the following Lorenz initial value problem: $latex \begin{cases} x'=-10(x+y) \\ y'=-x(z+28)-y \\ z'=xy-\frac{8}{3}z \\ x(0)=y(0)=z(0)=5 \end{cases} $ I wrote a function, LorenzRK4IVP(), that takes the system of three differential equations as input and solves the system using the Runge-Kutta method with step size $latex h=.01$. I plot the strange attractor as … Continue reading Finding and Plotting Lorenz Solution using MATLAB

# Iterative OLS Regression Using Gauss-Seidel

I just finished covering a few numerical techniques for solving systems of equations, which can be applied to find best-fit lines through a give set of data points. The four points $latex \{(0,0), (1,3), (2,3), (5,6)\}$ are arranged into an inconsistent system of four equations and two unknowns: $latex b+a(0) = 0 \\ b+a(1) = 3 \\ b+a(2) … Continue reading Iterative OLS Regression Using Gauss-Seidel

# Unstable Market

The necessary and sufficient condition for convergence is that the slope of the supply curve be greater than the absolute value of the slope of the demand curve. If the slope of the supple curve is less, then price and quantity diverge from equilibrium over time.