grid paper using Stata

I just wrote a program to make grids using Stata! Not much use for many people, but if you have a friend who is a knitter and needs a grid template, well this may come in handy ūüôā

This is an ado file, so just: 1) copy the text below the image into a text editor; 2) save it with the extension “.ado”; 3) put it in your Stata personal directory

The following grid was generated using the command:
mkgrid 60 80 "44 162 95" vthin label alt
grid_60x80


/**
Program to produce a y by x grid
Carl Higgs 16 April 2016

Input parameters (arguments):
y number of vertical spaces
x number of horizontal spaces
colour line colour
width line width
labels whether numbered axes are desired (if so, write "label" here, or leave blank)
alt if you have specified having labels, you might want them to alternate: type "alt"

e.g.
mkgrid 60 80
mkgrid 60 80 black
mkgrid 60 80 black vthin label
mkgrid 60 80 black vthin label alt
**/
* capture program drop mkgrid
program mkgrid, rclass
version 13.1
args y x colour width labels alt
di "y is `y' and x is `x'"
drop _all
loc obs = max(`y',`x')
set obs `obs'
if `y'==`obs' {
egen y = fill(1(1)`y')
gen x = `x'
}
else {
gen y = `y'
egen x = fill(1(1)`x')
}

loc aspect = `y'/`x'

if "`labels'"=="label" {
tw sc y x, ms(i) ///
graphregion(fcolor(white) lcolor(white)) scheme(s2color) ///
xlab(0(1)`x',grid nogextend gmin glc("`colour'") `alt' labsize(vsmall) glwidth("`width'")) ///
ylab(0(1)`y',grid nogextend gmin glc("`colour'") `alt' angle(h) labsize(vsmall) glwidth("`width'")) ///
ytitle("") ///
xtitle("") ///
aspect(`aspect') ///
xsca(noextend) ysca(noextend) ///
name(grid_`y'x`x',replace)
}

else {
tw sc y x, ms(i) ///
graphregion(fcolor(white) lcolor(white)) scheme(s2color) ///
xlab(0(1)`x',grid nogextend gmin glc("`colour'") glwidth("`width'")) ///
ylab(0(1)`y',grid nogextend gmin glc("`colour'") glwidth("`width'")) ///
ytitle("") ///
xtitle("") ///
aspect(`aspect') ///
xsca(off) ysca(off) ///
name(grid_`y'x`x',replace)
}

end

A 5×5 grid:
grid_5x5

A 2496×738 grid, towards the limits of what this code can do, the artifacts of electrical glitch spirits start to surface:
grid_2496x738

bird mites

In late November 2015 we had a bit of a bird mite infestation (we think). ¬†First awareness of it as an insect issue was after going to the doctor with what I thought was a strange rash; the doctor advised that this was urticaria (a new word for me ¬†– ie. hives) resulting from an allergic reaction most likely to some type of insect…. The worst case scenario for us¬†was bed bugs…

Traumatic bed bugs: years ago a friend was house-sitting for us and she has the unlucky superpower of being super-sensitive to bed bug bites – massive allergic reaction. ¬†We (in 2009) were sceptical at first having never knowingly come across these, and that we didn’t have any such reaction – however once we started looking we found all the evidence – blood spotting on the sheets, mattress and furniture near the bed, shed skins and little white eggs in the joins of the wooden bed frame and nearby wooden bookshelf – and laid there as test bait with a torch at the ready and saw them crawling on us. ¬† ¬†Well we¬†learnt a few lessons in dealing with this issue over the next few months – the biggest help was¬†the ‘Code of Practice¬†For the Control of Bed Bug Infestations in Australia‘ by Stephen Doggett of the Department of Medical Entomology at Westmead Hospital in Sydney.

So returning to late 2015, we were cautiously aware that unlike this previous experience and later encounters with ‘chinches’ while travelling in Latin America in 2013 that our current allergic reaction suggested something different. ¬†Nevertheless we isolated all sheets and clothing¬†in the bed room, bagging these up and¬†systematically hot washed and freezing these while we looked for BB evidence (bloodspots, eggs, cascas, certain sweet smell) – nothing; and this was a relief. ¬†But we still didn’t know what this issue was – and it’s not much fun to be covered in painfully itchy bites!

To cut the ramble short Рthere were two possibilities that we saw as being plausible: bird mites or rate mites.  We had heard scurrying in the roof above our bed recently, and we had noticed a lot of birds around.  Our landlord came around and found bird droppings in the roof cavity and some small holes in the ceiling tiles.

We did some more research and found an article in the Australian Department of Health’s Communicable Diseases Intelligence journal describing a bird mite infestation in Wollongong at a similar time of year: apparently young starlings are known to leave their nests at this time of year, and their opportunistic bird mites hungrily seek out an alternate meal. ¬†Humans, although not satisfactory, make a decent second best in the short term. ¬†Inspired by this author’s detective work, we purchased a USB¬†microscope from JayCar and got our clear tape at the ready – and when Caroline felt something crawling on her torso we were able to get it on the sticky tape:

bird mite microscope image 27nov2015

A tiny thing (it was fun playing entomologist)! And¬†it really did match up to the profile of either a rat mite or bird mite. ¬†Doing a bit of investigation, I found an empty nest in a cluster of branches¬†of an overgrown vine-extending tree which¬†had over the past few months grown to extend¬†brushing up against¬†the mesh screen of¬†our bedroom window and which had also pushed their way into the roof eaves above our bedroom. ¬†Well I did some severe pruning to this tree, and a pest inspector sent by¬†the landlord also suggested he thought bird mites were the likely source of the bites and he sprayed some pyrethrum ¬†in the guttering ¬†(a step I wasn’t sure about as I thought this might send things scurrying into our house! ¬†But he was the expert so we went with it). ¬†It is now a couple of months later and things seem fine, so the idea of bird mites having a last ditech attempt at a meal after their little bird hosts had skipped the nest seems like the likely explanation for the bites and the ¬†allergic reaction¬†I had.

So here is a little song and video, the latter featuring some microscope footage from the Digitech 5MP USB microscope camera of our bird mite!

Quick little mash up video using some old footage I had lying around (see fox-faced dancing animal in the Ghostlight¬†video), Resolume, the bird mite microscope vid, and a webcam shot of some paper with ‘dear Adversaire’ written on it.

Latex to Excel

Converting LaTeX tables to Excel is a pain; here are some steps I found useful for reformatting and removing persistent hidden whitespace characters:

  • remove the \\ symbols and import the latex text document in Excel with the ampersand symbol (&) set as a delimiter (simple and good idea¬†from¬†this blog¬†post – thank you Ever Barbero!)
  • replacing intervening table code (e.g. \multicolumn{5}{c} ) and remaining curly brackets with nothing
  • and replacing sub-/super-script (eg. ^2) and other symbol codes (eg. \chi) with their equivalent unicode characters (e.g. Ōá¬≤)
  • using the ‘TRIM(cell reference)’ formula in Excel to remove space characters except for single space between words/values…. However in itself I found this did not work satisfactorily. ¬†Through trial and error I found that the embellishment of the TRIM() function as TRIM(CLEAN(cell reference)) removes hidden characters which trim alone may not. I had hidden spaces screwing up alignment of table items, and expanding this formula ‚ÄĒactually, IF(ISBLANK(cell reference,””,TRIM(CLEAN(cell reference))) , so empty cells didnt’ return as errors ‚ÄĒ to reference the tables contents, and then pasted as values over the top solved this problem.

Whilst writing this post I found a StackOverflow post covering this and a few other tips which would have saved me some trial and error time if I found it sooner.