I just fixed a bug in optim.phylo.ls() - my simple ("for fun") function for least squares phylogeny estimation. Basically, there was an error in the internal function ls.tree(), which was causing the distance matrix to be improperly sorted. In particular, I originally had:
which used the index from a sorted matrix to columnarize D - but never actually sorted D by the $tip.label order! Oops. I have now changed this to:
and the problem is solved. See updated code here.