The function traverses the tree in postorder (tips-->root) to calculate the quadratic parameters described by Maddison (1991) and obtain the globally parsimonious squared-change parsimony state for the root. The function then reroots at each node, updates all affected quadratic parameters in the tree and calculates the node's globally parsimonious squared-change parsimony state.
The function has asymptotic time complexity O(Nedges).
If tree$edge.length
is missing, each edge in the tree is assumed to have length 1. This is the same as setting weighted=FALSE
. The tree may include multi-furcations (i.e. nodes with more than 2 children) as well as mono-furcations (i.e. nodes with only one child). Edges with length 0 will be adjusted internally to some tiny length if needed (if weighted==TRUE
).
Tips must be represented in tip_states
in the same order as in tree$tip.label
. The vector tip_states
need not include item names; if it does, however, they are checked for consistency (if check_input==TRUE
).
If weighted==FALSE
, then this function yields the same ancestral state reconstructions as
ape::ace(tip_states, tree, type="continuous", method="ML", model="BM", CI=FALSE)
in the ape
package (v. 0.5-64), assuming the tree as unit edge lengths. If weighted==TRUE
, then this function yields the same ancestral state reconstructions as the maximum likelihood estimates under a Brownian motion model, as implemented by the Rphylopars
package (v. 0.2.10):
Rphylopars::anc.recon(tip_states, tree, vars=FALSE, CI=FALSE).