arbutus_plot_dist: Plot the simulated test statistics versus observed test...

View source: R/plotting-fxns.R

arbutus_plot_distR Documentation

Plot the simulated test statistics versus observed test statistic (distribution of parameter estimates)

Description

Plots a histogram of the simulated values along a histogram of the observed values for a single test statistic when a distribution of estimates is used

Usage

arbutus_plot_dist(
  x,
  stat,
  xlab = NA,
  ylab = "Counts",
  col = NA,
  breaks = NA,
  las = 1,
  lwd = 3,
  legend = TRUE,
  legend.pos = "topright",
  cex = 1,
  ...
)

Arguments

x

an arbutus object inherited from compare_pic_stat

stat

the name of the test statistic to plot

xlab

x-axis label. Defaults to stat.

ylab

y-axis label. Defaults to "Counts".

col

colours used in plot. The first colour corresponds to the histogram of simulated test statistics. The second colour to the line representing the observed value of the test statistic. If no argument is supplied, the function uses the default colours.

breaks

the number of breaks in the histogram. Defaults to 20.

las

plot parameter (see par).

lwd

plot parameter (see par).

legend

logical, specifying whether a legend should be included.

legend.pos

postiion of the legend (see legend).

cex

plot parameter for legend (see par).

...

additional arguments to be passed to plot

Details

This function is designed to give researchers a quick visual inspection of model adequacy by plotting the simulated distribution of a test statistic along with the distribution of empirical estimates.

If the empirical distribution of the test statistic lies in the tails of the distribution of simulated test statistics, the model can be rejected as inadequate.

The p-values corresponding to this plot can be obtained with the function pvalue_arbutus.

plot.arbutus wraps this function and allows results from all test statistics to be viewed in a single plot.

See Also

arbutus, compare_pic_stat, plot.arbutus

Examples

## finch data
data(finch)
phy <- finch$phy
data <- finch$data[,1]

## pretend that the tree has already been rescaled
## and that we have a list of rescaled trees
mphy <- lapply(seq_len(50), function(x) {phy})
class(mphy) <- "multiPhylo"
modelad <- arbutus(mphy, data=data)
arbutus_plot_dist(modelad, "m.sig")


## Not run: 
## use diversitree to fit a BM model with MCMC
require(diversitree)
lik <- make.bm(phy, data)
f <- mcmc(lik, x.init=1, nsteps=1000, w=1, print.every=0
modelad.bm <- arbutus(f, sample=100)
arbutus_plot_dist(modelad.bm, "m.sig")

## End(Not run)


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