View source: R/compare.summStat.R
compare_pic_stat | R Documentation |
Calculates two–tailed p-values from comparing observed to simulated test statistics in order to evaluate model adequacy for phylogenetic models of continuous character evolution.
compare_pic_stat(obs, sim)
obs |
a data.frame containing the observed test statistics with the column names denoting the names of the statistics used. |
sim |
a data.frame containing the simulated test statistics with the column names denoting the names of the statistics used. |
The column names must be the same for the observed and simulated
test statistics (though not necessarily in the same order). Both
obs
and sim
are designed to be obtained
from the function calculate_pic_stat
.
If there is only 1 row in obs
(such as the case if ML estimate
of model is used), then the function will compare the observed test statistic(s) to
the distribution of simulated simulated test statistics.
If there is more than 1 row in obs
(such as the case if we have
a posterior distribution of parameter estimates or the test statistics are calculated
across many trees), then the function requires that the number of rows in
obs
and sim
be equal. This is because the function
calculates the p-values by performing pairwise comparisons. the function will automatically
check that this condition is met and produce an error if it is not.
In both cases, the p-values that are returned are two–tailed p-values as the function considers the probability of the observed statistics being larger or smaller than the simulated statistics.
The distribution of simulated test statistics along with the observed test
statistic using a generic plot
function (see plot.arbutus
)
for more details. For the purposes of plotting, the observed and simulated test
statistics used as arguments are returned with the p-values.
The p-values can be extracted from the output of compare_pic_stat
using the
function pvalue_arbutus
an object of class arbutus
which is a list containing the following objects:
Two–tailed p-values for all test statistics
The input data frame of observed test statistics
The input data frame of simulated test statistics
calculate_pic_stat
, plot.arbutus
, pvalue_arbutus
,
arbutus
data(finch) phy <- finch$phy dat <- finch$data[,"wingL"] unit.tree <- make_unit_tree(phy, data=dat) ## calculate default test stats on observed data obs <- calculate_pic_stat(unit.tree, stats=NULL) ## simulate data on unit.tree simdat <- simulate_char_unit(unit.tree, nsim=10) ## calculate default test stats on simulated data sim <- calculate_pic_stat(simdat, stats=NULL) ## compare simulated to observed test statistics res <- compare_pic_stat(obs, sim) ## extract p-values pvalue_arbutus(res) ## plot results plot(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.