Blog Archives

A Little R Counter

June 11, 2011
By
A Little R Counter

I recently read a great post about environments in R, which featured this little bit of code:> createCounter <- function(value) { function(i) { value <<- value+i} }> counter <- createCounter(0)> counter(1)> a <- counter(0)&gt...

Read more »

Schelling’s Neighborhood Model

April 30, 2011
By
Schelling’s Neighborhood Model

The New York Times has created a beautiful visualization of the Census Bureau's 2005-2009 American Community Survey data. The distribution of racial and ethnic groups in New York City is particularly fascinating:Chinatown appears in red toward the sou...

Read more »

A Tiny Model of Evolution

April 25, 2011
By
A Tiny Model of Evolution

I've always wanted to write a(n overly) simple model of evolution. The assumptions are minimalistic: only one species, for which each individual's genotype is represented as a one-dimensional real number, e.g. 7.4. Now, the fun stuff: I define a fu...

Read more »

Of Height and Speed in Tennis, or Fuzziness and Techiness in College

April 24, 2011
By
Of Height and Speed in Tennis, or Fuzziness and Techiness in College

I thought of this after reading this post and perhaps also this one, one the Cheap Talk blog. Here's the puzzle: in general, being tall does not make you slow; but among professional tennis players, the tall athletes do tend to be relativel...

Read more »

Logistic Regression & Factors in R

April 24, 2011
By
Logistic Regression & Factors in R

Factors are R's enumerated type. Suppose you define the variable cities -- a vector of strings -- whose possible values are "New York," "Paris," "London" and "Beijing." Instead of representing each city as a string of characters, you might prefer to ...

Read more »

Flu Trends

April 18, 2011
By
Flu Trends

Not a model, but certainly Mickey Mousey: here’s some R code that plots Google’s US flu data:df <- read.csv(url("http://www.google.org/flutrends/us/data.txt"), skip=11)df$Date <- as.Date(df$Date)dev.new(height=8, width=12)# Leave a thin outer...

Read more »

Mickey Mouse Models

April 18, 2011
By
Mickey Mouse Models

My statistics professor once drew a little Markov chain on the board and called it “just a Mickey Mouse model,” because it was too simple to represent anything serious.

Read more »