# collapsed.intervals

##### Collapsed Coalescent Intervals

This function takes a `"coalescentIntervals"`

objects and collapses neighbouring
coalescent intervals into a single combined interval so that every collapsed interval is
larger than `epsilon`

. Collapsed coalescent intervals are used, e.g., to obtain the
generalized skyline plot (`skyline`

). For `epsilon = 0`

no interval
is collapsed.

- Keywords
- manip

##### Usage

`collapsed.intervals(ci, epsilon=0)`

##### Arguments

- ci
coalescent intervals (i.e. an object of class

`"coalescentIntervals"`

).- epsilon
collapsing parameter that controls the amount of smoothing (allowed range: from

`0`

to`ci$total.depth`

)

##### Details

Proceeding from the tips to the root of the tree each small
interval is pooled with the neighboring interval closer to the root. If the
neighboring interval is also small, then pooling continues until the composite
interval is larger than `epsilon`

. Note that this approach prevents the
occurrence of zero-length intervals at the present.
For more details see Strimmer and Pybus (2001).

##### Value

An object of class `"collapsedIntervals"`

with the following entries:

A vector with the number of lineages at the start of each coalescent interval.

A vector with the length of each coalescent interval.

A vector indicating for each coalescent interval to which collapsed interval it belongs.

The total number of coalescent intervals.

The number of collapsed intervals.

The sum of the lengths of all coalescent intervals.

The value of the underlying smoothing parameter.

##### References

Strimmer, K. and Pybus, O. G. (2001) Exploring the demographic history
of DNA sequences using the generalized skyline plot. *Molecular
Biology and Evolution*, **18**, 2298--2305.

##### See Also

##### Examples

```
# NOT RUN {
data("hivtree.table") # example tree
# colescent intervals from vector of interval lengths
ci <- coalescent.intervals(hivtree.table$size)
ci
# collapsed intervals
cl1 <- collapsed.intervals(ci,0)
cl2 <- collapsed.intervals(ci,0.0119)
cl1
cl2
# }
```

*Documentation reproduced from package ape, version 4.1, License: GPL (>= 2)*