The Robbins and colleagues paper (2010) has an extremely detailed description of the intended use of their mass estimation formulae. One particular note became an unexpected challenge when I was adding their method to Anthropomotron.

There are different formulae to use depending on the estimated age of the individual. Each formulae is tied to one whole number year (e.g. 1, 2) plus or minus 6 months. To decide which formula to use at the 6 month split, the researchers wrote:

“Results are intended to apply to individuals at [plus or minus] 6 months from these ages, e.g., the 1-year-old formula applies to individuals 6 months to 17.59 months,” (Robbins et al., 2010:147).

In practical use, this means that someone estimated to be 1.5 years of age (one year and six months) would use the formula for one year olds, while someone 1.6 years of age would use the formula for two year olds. While Javascript has automatic rounding capabilities, it would round 1.5 up to 2 instead of one, which is different than what is prescribed in the paper.

Chances are that the likelihood someone will use my app, enter an age near a number of years and 5.59 months, and get a different result than what they would’ve gotten by following the original article is extremely small. Still, one of my rules in making this app is that I will go by the word of the developers of these techniques and not impose my own judgement on someone else’s work. My goal then is to make Javascript round the age in a unique way using the mathematical tools provided in the scripting language.

This is my solution, which is a great exercise in thinking like a computer. The first step is to handle the fact that I use years in Anthropomotron while the paper describes its methods in terms of months. Then I need to apply the special rounding rule using an if-then statement: if the decimal portion is less than 0.59 months, then round down, else round up. I tried a variety of techniques to convert years in decimals into months, but I decided that the easiest way would be to convert the 0.59 months into years instead. A quick calculation that 0.466 years is roughly equivalent to 5.59 months (the halfway mark in the year when the rounding rule changes).

However, for Javascript to make a decision based around 0.466, I need to isolate the decimal portion of the number of months for the statement to work. There is no Javascript command to strip out the whole number portion of a number to leave the decimal. Yet, there is a command to strip out the decimal to leave the whole number, though. I cursed my luck at this turn of events but then I realized if I take the number of months and subtract the isolated whole number portion, I’m left with just the decimal like I wanted! Adding that step and passing the result to the if-then statement then gave me the foundation for the special rounding method. I then used two Javascript commands as appropriate, Floor and Ceiling, to force the down- or up-rounding of the original data in years. Whew!