Here you will find daily news and tutorials about R, contributed by over 573 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

My colleague Karen needed an equation to predict trunk diameter given tree height, which she hoped to base on measurements of trees in semi-arid Australian woodlands. This is the dark art of allometry and a quick google found a large number of formulae that have been used in different studies of tree dimensions. No problem: I started to play with a few of them and eventually settled on this one:

dbh = exp( b0 + b1 / (b2 + h) ) where: dbh is trunk diameter at breast height; h is tree height.

Karen also needed to do reverse predictions, ie. predict a tree’s height given its trunk diameter. Again no problem, the inverse equation is simply:

height = b1 / (log( dbh ) – b0) – b2

But then, the pièce de résistance: the forward predictions had to agree with the reverse predictions, ie. if plugging height h into the forward equation gave trunk diameter d, then plugging d into the reverse equation should get you back to h. Karen pointed out that this seemed to be a Model II regression problem because as well as needing symmetric predictions, both variables were subject to measurement error.

R has at least two packages with Model II regression functions: lmodel2 and smatr, but both seemed to be restricted to a single predictor (I’d be interested to hear if I’m wrong about that). Meanwhile, the trusty nls function seemed to do a good job of fitting the forward and reverse equations while dealing with the pattern of variance displayed by the tree data (mu^3).

A solution arrived in the form of this post in the r-help list archive explaining how the coefficients from the forward and reverse fits could be combined by taking their geometric mean to arrive at a form of Model II regression. We tried this and it appeared to work nicely. The plot above shows the separate fits, plus the combined fit which does indeed give symmetric predictions, for one of the tree species.

Related

To leave a comment for the author, please follow the link and comment on their blog: Last Resort Software.