Monday, February 25, 2013

Mediterranean Diet

This is pretty cool on the face of it.  I love it when people really go for it and demonstrating/measure an effect which is both complex and hard to define.  Also worth a look is the effort they had to go through to get a dissenting voice:
Dr. Esselstyn said those in the Mediterranean diet study still had heart attacks and strokes. So, he said, all the study showed was that “the Mediterranean diet and the horrible control diet were able to create disease in people who otherwise did not have it.”
Yes... 'cause if you followed Dr. Esselstyn's special diet you'd never get a heart attack... just buy the book!  I don't know whether Dr. Esselstyn produced any more coherent statements on but this topic, but if not then the NYT is really stretching to tell us "both sides of the story". 


Can't they just call a slam dunk a slam dunk?  Or maybe read the paper and discuss some real flaws?  Also, did the nuts drive people nuts?  They didn't die of heart disease, but maybe they got into extreme sports?

Wednesday, January 23, 2013

Read your error messages

So for a conservation-oriented project I'm working on I wrote an R package to implement arbitrary-stage and currently 1-D integral projection models (IPM's)[1].  It lets you define and simulate from an IPM using a few data frames and R's formula interface to define the projection kernels[2].  It's been a great time-saver for me since I finished up most of it... but I'm still very suspicious of the code quality so when I got an error message I immediately blamed the package code...


> pop$step()
Error in model_matrix(newdata, covariates, n) :
  Model matrix columns for some coefficients missing:
        Missing columns for:
                sizes


... of course I had just happened include a coefficient which I did not use in the R formula for the model matrix ( ~ 1, where ~ 1 + sizes would have worked)... so I get to learn, once again, the age-old dictum of writing code: _read_ the error messages.  Really.  READ them. Especially if you went through the trouble of writing good ones.

[1] Ellner and Rees 2006 being the best starting reference for those....
[2] It'll be on CRAN someday...

Monday, September 17, 2012

Wherein Reuters reports that the rainforest is wet. Also riots and a certain prophet.

Once somebody "offends Islam"[1], even in the gentlest literary way possible, the ensuing pearl-cluthcing, apologies, riots, embassy attacks, further apologies, and murders are almost entirely predicable.  It's just a question of how bad it's going to get and how long the show will go on in the international news. 

Also predictable is the slew of "news" articles which no insight as to why a mere cartoon or book would lead to murder and mayhem on an international scale.  Instead of insight we get dreck like this:
"The demonstrations were the latest across the world provoked by a short film made with private funds in the United States that depicted the Prophet Mohammad as a fool and womanizer."
Somehow I don't think that people were sitting around having tea and listening to the news and when they heard about the movie they decided it would be a great time to go storm an embassy.  Apparently with kids in front (Reuters):
Figure 1: Love Islam, will throw stones for same.
Honestly, Reuters, are we supposed to believe that this school field trip (see fig. 1) was the result of a film?  ... or did somebody maybe work a little to convince these folks that throwing rocks and burning things that were vaguely Western was a good idea?  If you can't write news, maybe you could just give up and leave it to the bloggers who are honestly just as good at reading the press release from the Pakistani embassy.

[1] People can be offended, ideas... not so much.

Sunday, August 12, 2012

Evening Descent to Salt Lake City

The mist was thick. The salt lakes looked a little creepy, and in the dim light the rough landscape had a damaged look.  I was pretty sure we were descending into Salt Lake City, but I couldn't shake the thought that we were lost and it was really Mordor.  Maybe my mind was trying to process the idea of a presidential candidate who is willing to ignore global warming, who equivocates about Roe v. Wade, who wants to put invasive doctrinal positions on sex education ahead of the interest of the secular state and American children, and who support opportunists like Jindal.

Is this where we're at?  And he took Paul Ryan to the altar?!  Oy, can't wait to leave Mordor.

Saturday, May 5, 2012

The uncanny resemblance between certain abstracts and herbal remedy claims

Dear sir,

When you state the conclusion of your study as "our results show that X depends on Y and Z", that is about as memorable and informative as the labels on those little bottles of water in the homoeopathy aisle which say "has been shown to support prostate health."  The only thing that surprises me about your vague abstract is that there isn't a star next to it that says "*These claims may be relevant to science but I don't know why."

Friday, April 20, 2012

He had it coming, JAGS edition



From the JAGS help forum:
I figured it out. In case this is helpful for someone else, a way of adding a function [to JAGS] is to 1) go to src/modules/bugs/functions and add a .cc and .h file for your function (copy an existing one as a template) 2) edit both src/modules/bugs/functions/Makefile.in and src/modules/bugs/bugs.cc to reflect the addition 3) go to the top level and do a "autoreconf --force --install" to rebuild the configure file 4) configure, make, sudo make install as usual I apologise if this is not a good solution, but it did work for me.
The sampler for degrees of freedom in the Student's t distribution is behaving "badly" for my particular model and I'm facing the inevitable.... which reminds me that the following quote, from Troy Day's website is also applicable to programmers:
I love coding as much as the next guy, but not when it jumps out at you from some dark corner of a black box. Also, Chicago is relevant:


Student's t distribution: your tail looks fat

Student's t distribution can be approximated with a normal distribution for large degrees of freedom.  This is one of those statistics factoids which everyone recognizes, heck, it's in Wikipedia.  For some code I'm writing (part of which involves fitting a t distribution), it would be really convenient to be able to decide to use this approximation beyond a certain number of degrees of freedom.  John Cook has written a little post about this, but I was interested in quantifying it a little more. It's actually a little depressing.



dat <- seq(0,100,0.01)
out <- matrix(data=dat, nrow=length(dat), ncol=500)
for ( i in 1:500 ) { out[,i] <- dnorm(x=out[,i])/dt(x=out[,i],df=i*5)<0.1}
outW <- apply(X=out,MARGIN=2,FUN=function(x) {min(which(x>0))})
plot(x=1:500*5,y=outW/100, pch='.', 

   xlab='Degrees of Freedom', 
   ylab='# of SD before normal tail is 1/10th of t tail')

Prior to carrying out the analysis it's hard to tell what the estimated degrees of freedom might be (based on the mass of data near the central mound of the distribution), but I certainly expect quite a few samples out beyond five SD units.  No approximation for me.