aphylo_cv: Leave-one-out Cross Validation

View source: R/cv.R

aphylo_cvR Documentation

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 class 'formula'
aphylo_cv(model, ...)

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.

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.

Examples

# It takes about two minutes to run this example


  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)
  


USCbiostats/aphylo documentation built on Oct. 28, 2023, 7:22 a.m.