link.traits {treats}R Documentation

link.traits

Description

Linking traits objects together to simulate simulate them sequentially.

Usage

link.traits(base.trait, next.trait, link.type, link.args, trait.name)

Arguments

base.trait

One or more "treats" "traits" object(s) to be considered first.

next.trait

One or more "treats" "traits" object(s) to be considered sequentially.

link.type

The type of link between the traits. Can be "conditional".

link.args

Optional arguments to interpret the link between the objects (based on the link.type).

trait.name

Optional, a character, the name the resulting trait.

Details

This function allows to link several traits together in the simulations. The current link types implemented are:

Value

This function outputs a treats object that is a named list of elements handled internally by the treats function.

Author(s)

Thomas Guillerme

See Also

treats trait.process make.traits

Examples

## Setting up a discrete trait
discrete_trait <- make.traits(discrete.process,
       process.args = list(transitions = matrix(c(3, 0.2, 0.05, 3), 2, 2)),
       trait.names  = "discrete")

## Setting up one dummy trait (always outputs 1)
always_one <- make.traits(process = function(x0 = 0, edge.length = 1) {return(1)},
                          trait.names = "one")
## Setting up a Brownian motion trait
BM_trait <- make.traits(trait.names = "BM")

## Setting a condition list to link all traits
## (if discrete trait is 0, simulate a BM trait)
## (if discrete trait is 1, simulate the always one trait)
conditions <- list("choose.BM"  = function(x1) {x1 == 0},
                   "choose.one" = function(x1) {x1 == 1}) 

## Creating the linked trait
conditional <- link.traits(base.trait = discrete_trait,
                           next.trait = list(BM_trait, always_one),
                           link.type  = "conditional",
                           link.args  = conditions)

## Simulating a tree using this trait
treats(stop.rule = list(max.living = 200),
       traits    = conditional)


[Package treats version 1.1.6 Index]