View source: R/summary-stats.R
| calculate_pic_stat | R Documentation |
Calculates a set of test statistics on the contrasts included with a 'unit.tree' object.
calculate_pic_stat(unit.tree, stats = NULL)
unit.tree |
a |
stats |
a named list of test statistics to calculate on the unit.tree.
If no |
This function can be applied to either a single 'unit.tree' of object or a list of 'unit.tree' objects.
If stats=NULL default test statistics are used. The default test statistics are the following:
m.sig: The mean of the squared contrasts. This is equivalent to the REML estimate of sigsq.
c.var: The coefficient of variation of the absolute value of the contrasts.
s.var: The slope of a linear model fit between the contrasts and their expected variances.
s.asr: The slope of a linear model fit between the contrasts and their inferred ancestral state.
s.hgt: The slope of a linear model fit between the contrasts and the node height at which they were calculated.
d.cdf: The D-statistic from a KS test comparing the distribution of the contrasts to a normal distribution with mean 0 and variance equal to the square root of the squared mean of the contrasts.
User defined test statistics can be supplied as a named list of functions (see examples). The functions supplied
must take a unit.tree as argument and perform an operation on at least one of the elements of the object
(see make_unit_tree for details).
A data.frame with the calculated test statistics across all unit.trees provided.
default_pic_stat, pic_stat_msig, pic_stat_cvar, pic_stat_svar, pic_stat_shgt, pic_stat_sasr, pic_stat_dcdf
data(finch)
phy <- finch$phy
dat <- finch$data[,"wingL"]
unit.tree <- make_unit_tree(phy, data=dat)
## use default statistics
test.stat <- calculate_pic_stat(unit.tree, stats=NULL)
test.stat
## user defined statistics
mean.con <- function(x) mean(x$pics[,"contrasts"])
max.con <- function(x) max(x$pics[,"contrasts"])
test.stat.user <- calculate_pic_stat(unit.tree,
stats=list(mean = mean.con, max = max.con))
test.stat.user
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.