Posts

Hetero What?

Image
Normality is the Great Neurosis of civilization. Tom Robbins, Normality is death. Theodor W. Adorno Consider the following data: It looks like there is a definite linear trend in the data, so a natural model might be \[{\mathbf{y}} = {\beta _0} + {\beta _1}{\mathbf{x}} + {\mathbf{\varepsilon }}\] The betas are numerical coefficients and ${\mathbf{\varepsilon }}$ represents an error term, i.e. the linear difference between the model values and the data values. Fitting a linear model to this sort of data is almost trivial in languages like R , Python , or Julia . In R: > fit.lm <- lm(y ~ x, df.lm$df) > summary(fit.lm) Call: lm(formula = y ~ x, data = df.lm$df) Residuals: Min 1Q Median 3Q Max -0.29382 -0.04390 -0.00026 0.03665 0.39976 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.1046755 0.0052070 20.10 <2e-16 *** x 0.0247682 0.0003006 82.41 <2e-16 *** --- Signi...

Mixing with Julia

Image
We have such a mixture now, such a fusion of different genres.   Ryszard Kapuscinski A while ago , I wrote a small app in Julia . In some of my other work, I needed to look at some data that could be modeled as being drawn from a mixture of probability distributions.  There are many packages available in R and Python for analyzing mixture models . However, since version 1.1 of Julia was released recently, I decided to renew my acquaintance  with the language by using it to build a simple mixture of normal (Gaussian) distributions. Although Julia provides methods for handling mixture models, I wanted to build my own routine for analysis to get some practice with Julia. Finite Mixture Models A mixture model is a probabilistic distribution that combines a set of components to represent the overall distribution. That is, given a set of data ${\mathbf{X}} = \{ {{\mathbf{x}}_1},{{\mathbf{x}}_2}...{{\mathbf{x}}_n}\} $ where each ${{\mathbf{x}}_{\mathbf{i}}}$ is an ...

Gibbs Sampling and the Paleothermometer

Image
Every glass thermometer has subtle variations in the size and shape of the bulb at the bottom and the capillary tube inside, as well as variations in the width of gradations on the side. The compounded effect of these uncertainties is that each thermometer reads temperature slightly differently.  - Sam Kean I loved dinosaurs, I loved space, and I thought maybe I'd be the first paleo-astronaut.  -Bill Maris A while ago, I wrote about using Gibbs sampling for spline regression.  The motivation for that post was this paper  BAYSPLINE: A New Calibration for the Alkenone Paleothermometer by Jessica E. Tierney and Martin P. Tingley. (It's behind a paywall. I'll spare you my rant about taxpayer supported research being a profit center for private companies.) There is accompanying software to the paper in Python and MATLAB . In this post, I'll use the the R software presented previously to reproduce the results from the Tierney and Tingley paper. A few marine s...