estimate.shiftvec: estimate.shiftvec

Description Usage Arguments Value Author(s) See Also Examples

View source: R/estimate.shiftvec.R

Description

Given two data frames, one containing isotopic measurements from some predator species, and another containing isotopic measurements from a collection of prey species, return num.samples samples of discrimination factors from predators to prey.

Usage

1
2
estimate.shiftvec(predator, prey, num.samples=1000, num.preysamples=1,
  pred.distinput=FALSE, prey.distinput=TRUE)

Arguments

predator

A data frame containing the isotopic measurements (presented as raw data or mean/standard deviation) from a predator species.

prey

A data frame containing the isotopic measurements (presented as raw data or mean/standard deviation) from a prey species.

num.samples

The number of samples of discrimination factors to produce.

num.preysamples

The number of samples to draw from each prey source when performing the estimation process.

pred.distinput

TRUE if the predator measurements are in mean/standard deviation form (see build.isotopeframe).

prey.distinput

TRUE if the prey measurements are in mean/standard deviation form (see build.isotopeframe).

Value

A matrix with num.samples rows, each of which contains one estimate discrimination factor.

Author(s)

Robert Robere

See Also

build.isotopeframe

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## normally input is read from a file via build.isotopeframe, but here
## we generate the input by hand
## we have three prey species: birds, mice, and bugs
## one predator species: cats
## we are measuring two isotopic values for each: %%C and %%N
## assume that all measurements are normally distributed
bird.samples <- as.data.frame(mvrnorm(n=25, mu=c(2, 2),
  Sigma=diag(c(1, 1), nrow=2)))
mice.samples <- as.data.frame(mvrnorm(n=25, mu=c(4, 4),
  Sigma=diag(c(1, 1), nrow=2)))
bugs.samples <- as.data.frame(mvrnorm(n=25, mu=c(2, 6),
  Sigma=diag(c(1, 1), nrow=2)))

## note that prey are collected into a single data frame, 
## as are the predators
## if number of samples differs from species to species,
## the data frame should be padded
## with NAs appropriately (this is done automatically when
## reading in from CSV)
pred.frame <- data.frame(cats=mvrnorm(n=20, mu=c(6, 6),
  Sigma=diag(c(1/2, 1/2), nrow=2)))
prey.frame = data.frame(bird=bird.samples, mice=mice.samples,
  bugs=bugs.samples)

## now estimate discrimination factors
## in applications, usually the prey measurements are given by mean/sd
## of corresponding gaussian, so we notify the function that we are
## actually providing samples in this example
estimate.shiftvec(pred.frame, prey.frame, num.samples=10,
  prey.distinput=FALSE) 

EDFIR documentation built on May 30, 2017, 3:38 a.m.