Learn R Programming

aphylo (version 0.3-3)

aphylo_cv: Leave-one-out Cross Validation

Description

This implements Leave-one-out cross-validation (LOO-CV) for trees of class aphylo and multiAphylo.

Usage

aphylo_cv(...)

# S3 method for formula aphylo_cv(model, ...)

Value

An object of class aphylo_cv with the following components:

  • pred_out Out of sample prediction.

  • expected Expected annotations

  • call The call

  • ids Integer vector with the ids of the leafs used in the loo process.

Arguments

...

Further arguments passed to the method.

model

As passed to aphylo_mcmc.

Details

For each observation in the dataset (either a single gene if of class aphylo, or an entire tree if of class multiAphylo), we restimate the model removing the observation and use the parameter estimates to make a prediction on it. The prediction is done using the function predict.aphylo_estimates with argument loo = TRUE.

Examples

Run this code
# It takes about two minutes to run this example
# \donttest{

  set.seed(123)
  atrees <- rmultiAphylo(10, 10, P = 1)

  cv_multi  <- aphylo_cv(atrees ~ mu_d + mu_s + Pi)
  cv_single <- aphylo_cv(atrees[[1]] ~ mu_d + mu_s + Pi)
  
# }

Run the code above in your browser using DataLab