ESS: Effective sample size

Description Usage Arguments Details Value Methods (by class) Author(s) References Examples

View source: R/ESS.R

Description

Effective sample size

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ESS(x)

## S3 method for class 'phybreak'
ESS(x)

## S3 method for class 'factor'
ESS(x)

## S3 method for class 'numeric'
ESS(x)

Arguments

x

An object of class phybreak.

x

Vector of class factor.

x

Vector of class numeric, containing only integers. This will be treated as a categorical variable.

Details

When applied to an object of class phybreak, ESS calculates for all parameters and continuous variables (infection times) the effective sample size (ESS) with the effectiveSize function in coda. For the infectors, a method is used that is similar to the method for the approximate ESS for phylogenetic trees, described in Lanfaer et al (2016):

  1. Define as distance measure between two sampled infectors D(i,j) = 0 if i = j, and D(i,j) = 1 if i <> j

  2. Calculate the mean squared distance f(k) between sampled infectors at intervals k = 1,2,... in the mcmc chain. The distance will increase with increasing interval k.

  3. Use the rate at which f(k) approaches the asymptote to calculate the ESS (see Lanfaer et al, 2016)

The latter method can also be directly called for single vectors of class factor or integer.

Value

Effective sample sizes.

Methods (by class)

Author(s)

Don Klinkenberg don@xs4all.nl

References

Lanfaer et al. (2016) Estimating the effective sample size of tree topologies from Bayesian phylogenetic analyses. Genome Biol Evol, 8(8): 2319-2332.

Examples

1
2
3
4
5
6
7
#First create a phybreak object
simulation <- sim_phybreak(obsize = 5)
MCMCstate <- phybreak(dataset = simulation)

MCMCstate <- burnin_phybreak(MCMCstate, ncycles = 20)
MCMCstate <- sample_phybreak(MCMCstate, nsample = 50, thin = 2)
ESS(MCMCstate)

donkeyshot/phybreak documentation built on Sept. 17, 2021, 9:32 p.m.