Monthly Archives: December 2014

Interactive Horizontal Bar Charts

Some notes on them here: http://nbviewer.ipython.org/gist/aflaxman/c93489dd19cee2eabf00

Capture

Comments Off on Interactive Horizontal Bar Charts

Filed under dataviz, software engineering

The challenges of counting gun deaths

This interesting article crossed my desk recently, A Year of Gun Deaths: What Slate learned from trying, and failing, to record every death by gun in America since Newtown. It is a long piece that touches on many of the things that make population health metrics hard.

It also drew my attention to an IOM report on Priorities for Research to Reduce the Threat of Firearm-Related Violence. Gun deaths are a public health problem.

Comments Off on The challenges of counting gun deaths

Filed under global health

PyMC3 with PyMC2

Did you know I have a fork of PyMC3 that you can run at the same time as PyMC2? I don’t keep it up to date, but people seem to want it every once in a while. Maybe this will help someone find it: https://github.com/aflaxman/pymc

import pymc as pm2
import pymc3 as pm3

Good for head-to-head comparisons…

Comments Off on PyMC3 with PyMC2

Filed under software engineering

Old Maze Making Code

Playing around with that GIS optimization stuff was a chance for me to revisit some maze-making code I wrote a few years ago: https://healthyalgorithms.com/2011/01/07/piggies-and-mazes/ I wonder what age kids it will be good for.

Comments Off on Old Maze Making Code

Filed under combinatorial optimization

Combinatorial Optimization for GIS

A real, applied problem in spatial epidemiology crossed my desk last week, and it turns out that it is a super-fun combinatorial optimization challenge, too.

Details here: http://gis.stackexchange.com/questions/126280/group-polygon-features-to-match-a-set-of-specifications

I don’t have time to play around with it a lot now, but I did try a little stochastic search, which makes me think that this will not be trivial to solve:

bad_clustering

Comments Off on Combinatorial Optimization for GIS

Filed under TCS

Bayesian Correlation in PyMC

Here is a StackOverflow question with a nice figure:

t0AeE

Is there a nice, simple reference for just what exactly these graphical model figures mean? I want more of them.

4 Comments

Filed under statistics

Statistics in Python: Calculating R^2

I wanted to include some old-fashioned statistics in a paper recently, and did some websearching on how to calculate R^2 in Python. It’s all very touchy, it seems. Here’s what I found:

http://stats.stackexchange.com/questions/36064/calculating-r-squared-coefficient-of-determination-with-centered-vs-un-center
http://stackoverflow.com/questions/893657/how-do-i-calculate-r-squared-using-python-and-numpy
http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.linregress.html
http://forums.udacity.com/questions/100154896/why-is-r-squared-from-formula-different-than-scipy-functions-one

I eventually went with this:

%load_ext rmagic

x = np.array(1/df.J)
y = np.array(df.conc_rand)
%Rpush x y
%R print(summary(lm(y ~ x + 0)))

Comments Off on Statistics in Python: Calculating R^2

Filed under statistics