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.

Wednesday, March 14, 2012

Re: XKCD 979

Life imitates XKCD.
  1. Get cryptic error from Libre Office
  2. Realize this is one package I never want to understand.  It's an MS Office replacement which faithfully replicates the whole anti-UNIX philosophy of MS Office.  Down to some of the Excel statistics bugs.
  3. Google for "Extension manager: exception in synchronize" 
  4. Find this record of an chat session in German
  5. Find a reference to this bug at 8:25 pm in the chat
  6. ls /usr/lib/libreoffice/share/uno_packages/cache/uno_packages
  7. chmod a+rx /usr/lib/libreoffice/share/uno_packages/cache/uno_packages
  8. It works again!
I'm glad Vassar at least taught me to use primary sources....




Monday, March 12, 2012

Math in biology manuscripts

Steps for co-authors helping out with the math on a manuscript: 
  1. look at equations (and text), dig up references;
  2. figure out the equations are wrong;
  3. try to figure out why they're right;
  4. fail;
  5. start to write email explaining your logic about the (potential) mistake (don't fill in recipient at this stage);
  6. find your mistake;
  7. discard draft email;
  8. repeat 1-6 until step 6 fails;
  9. fill in recipient and send;
  10. rinse and repeat, try not to look like a douche 
Step 10 is the hardest.  I suppose failing at step 2 is eventually the way out.

Tuesday, March 6, 2012

Bane of my existence

 That little "12031" is a life-saver though.


> source('adjustData.R'); source('runModel.R')
Compiling model graph
   Declaring variables
   Resolving undeclared variables
   Allocating nodes
   Graph Size: 1724335

Initializing model
Deleting model

Error in jags.model(file = "unroll-wbATS-DCJS.bugs", data = final.data,  :
  Error in node alive[12031]
Unobserved node inconsistent with unobserved parents at initialization


Bad habits

If you're a biologist and there's crazy weather, your first thought is "I wonder what my study site(s) look(s) like?"... the second is inevitably whether it was sensible to go driving on dirt roads to find out.

Figure 1: No, it was not sensible, but it was beautiful.