calculate_pic_stat: Calculate test statistics on a unit tree

View source: R/summary-stats.R

calculate_pic_statR Documentation

Calculate test statistics on a unit tree

Description

Calculates a set of test statistics on the contrasts included with a 'unit.tree' object.

Usage

calculate_pic_stat(unit.tree, stats = NULL)

Arguments

unit.tree

a unit.tree object or list of unit.trees

stats

a named list of test statistics to calculate on the unit.tree. If no stats argument supplied, default test statistics are used.

Details

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:

  1. m.sig: The mean of the squared contrasts. This is equivalent to the REML estimate of sigsq.

  2. c.var: The coefficient of variation of the absolute value of the contrasts.

  3. s.var: The slope of a linear model fit between the contrasts and their expected variances.

  4. s.asr: The slope of a linear model fit between the contrasts and their inferred ancestral state.

  5. s.hgt: The slope of a linear model fit between the contrasts and the node height at which they were calculated.

  6. 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).

Value

A data.frame with the calculated test statistics across all unit.trees provided.

See Also

default_pic_stat, pic_stat_msig, pic_stat_cvar, pic_stat_svar, pic_stat_shgt, pic_stat_sasr, pic_stat_dcdf

Examples

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
 

mwpennell/arbutus documentation built on Oct. 6, 2022, 10 a.m.