Category: Programming tips
Galaxies, trees, and influenza cases have something in common: they tend to occur in clusters. The issue of how to model clustered spatial patterns is thus of interest to a variety of scientific disciplines.
We have a growing interest in using our favorite tools (R and Mathematica) to build web interfaces to interactively explore and visualize data. Our last 5 posts have involved interactive tools, namely Mathematica’s computable document format and R’s new Shiny package.
In our last post, we explored how Fourier transforms can be used in Mathematica to make a frequency filter for audio files. That post was primarily concerned with implementing the appropriate transforms (and, of course, paying homage to the amazing talent of Macklemore and Ryan Lewis).
The Heist by Macklemore and Ryan Lewis is a masterpiece. It is clearly the best album of 2012, and I suspect it will go down alongside classics like Illmatic, The Chronic, The Marshall Mathers LP, and The College Dropout.
The people behind the wonderful RStudio, which I gushed about in a previous post, have developed a new package, Shiny, that makes it easy to develop interactive web applications with R.
A couple of months ago, we wrote a post on how to use finite difference methods to numerically solve partial differential equations in Mathematica. Several readers have asked for more details about the method.
Art Heist Last week, burglars stole seven paintings from the Kunsthal museum in Rotterdam. The paintings included works by Picasso, Monet, Gauguin, and Matisse. The loot is likely worth hundreds of millions of dollars, but the loss of these great pieces surpasses anything that can be calculated as a monetary figure.
I write sloppy R scripts. It is a byproduct of working with a high-level language that allows you to quickly write code on the fly (see this post for a nice description of the problem in Python code) and the result of my limited formal training in computer programming.
I love the elegant simplicity of programming in Mathematica. There is something undeniably beautiful about accomplishing something complex in a concise chunk of code. A famous Mathematica mantra is, “if you are using a For loop, you are probably doing it wrong.
A quick break from my usual R-centric posts to toot the horn of one of my other favorite pieces of freeware, NetLogo, which “is a multi-agent programmable modeling environment.” If you are interested in modeling complex systems and spatially-explicit behavior or processes, you should definitely take the time to (at least) download NetLogo and browse a few of the many example models.
In a recent blog post, The Economist discusses its “Sinodependency Index”, which measures the world’s economic dependence on China. This index was originally proposed in 2010. In today’s post, we will take a closer look at this index, and in the process, we will explore some of Mathematica’s finance-related capabilities.
I am a sucker for beautiful applications. The latest R-related application to catch my eye is RStudio.
RStudio™ is a free and open source integrated development environment (IDE) for R.
In today’s post, we will explore numerical schemes for integrating stochastic differential equations in Mathematica. We will take an informal approach; for an in-depth treatment of stochastic differential equations, I recommend that you look at Stochastic Processes for Physicists by Kurt Jacobs and Modeling with Ito Stochastic Differential Equations by Edward Allen.
Ecologists commonly collect data representing counts of organisms. Generalized linear models (GLMs) provide a powerful tool for analyzing count data.1 The starting point for count data is a GLM with Poisson-distributed errors, but not all count data meet the assumptions of the Poisson distribution.
Mathematica’s NDSolve command is great for numerically solving ordinary differential equations, differential algebraic equations, and many partial differential equations. Most of the integration details are handled automatically, out of the user’s sight.
This post is a quick tip on how to use the paste1 function to read and write multiple files. First, let’s create some data.
dataset = data.frame(expand.grid(Trt=c(rep("Low",10),rep("High",10)), Sex=c(rep("Male",10),rep("Female",10))), Response=rnorm(400)) The next step is not necessary, but makes the subsequent code more readable.
As a general rule, you should not transform your data to try to fit a linear model. But proportions can be tricky. If the proportion data do not arise from a binomial process (e.
In a previous post, I showed how to keep text and symbols at the same size across figures that have different numbers of panels. The figures in that post were ugly because they used the default panel spacing associated with the mfrow argument of the par function.
You’ve probably heard of the traveling salesman problem: given a set of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city?
In R, there are a couple of packages that allow you to create multi-panel figures (ggplot2 and lattice), but, of course, you can also make multi-panel figures in the base package.
Ecological models sometimes find very unexpected applications. Work on wolf territory modeling by Mark Lewis’s research group at the University of Alberta has been employed by researchers studying gang territories in Los Angeles.