Analysis code for paper