Generalises the approach in https://github.com/richfitz/wood
R Makefile
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
R
inst/extdata
man
tests
vignettes
.Rbuildignore
.gitignore
.travis.yml
DESCRIPTION
LICENSE
Makefile
NAMESPACE
README.md
traitfill.Rproj

README.md

traitfill

Build Status Coverage Status

This R package is for leveraging taxonomic information to impute the values of a binary trait for species with missing data. The approach is described in FitzJohn et al. 2014 (Journal of Ecology) and originally implemented here.

The easiest way to install the package is with devtools

## install.packages("devtools")
devtools::install_github("richfitz/traitfill")

The primary function of the package is also called traitfill. To demonstrate how it works, we will use the data from our woodiness study

library(traitfill)
wood <- load_wood()
res <- traitfill(wood, nrep=50, with_replacement=FALSE, names=c("H", "W"))
res

As described in FitzJohn et al. 2014, we consider two different sampling distributions for the traits:

  1. Sampling with replacement (with_replacement = TRUE in the traitfill function) in which trait values for missing taxa are drawn from a binomial distribution. If all the records in a genus are of one type, then this implies that the rest of the unsampled species also share this trait.

  2. Sampling without replacement (with_replacement = FALSE in the traitfill function) in which trait values for missing taxa are drawn from a hypergeometric distribution. Even if all trait records for a genus are of one type, we consider the possibility that there may be a species of the other type that we simply have not sampled. The probablility of this descreases as the proportion of taxa that are sampled increases.