bias.all: Calculate bias correction for confidence intervals from...

bias.allR Documentation

Calculate bias correction for confidence intervals from beta.meths.CI.

Description

Calculate bias correction for confidence intervals from beta.meths.CI.

Usage

bias.all(
  p.mat,
  prey.mat,
  cal.mat = rep(1, length(ext.fa)),
  fat.cont = rep(1, nrow(prey.mat)),
  R.bias,
  noise,
  nprey,
  specify.noise,
  dist.meas,
  ext.fa
)

Arguments

p.mat

matrix containing the fatty acid signatures of the predators.

prey.mat

matrix containing a representative fatty acid signature

cal.mat

matrix of calibration factors where the i th column is to be used with the i th predator. If modelling is to be done without calibration coefficients, simply pass a vector or matrix of ones.

fat.cont

prey fat content

R.bias

bootstrap replicates

noise

noise

nprey

number of prey

specify.noise

noise

dist.meas

distance measure

ext.fa

subset of FA's to use.

Value

Row 1 is Lambda CI, row 2 is Lambda skew, and row 3 is Beta CI

Examples

## Fatty Acids
data(FAset)
fa.set = as.vector(unlist(FAset))

## Predators
data(predatorFAs)
tombstone.info = predatorFAs[,1:4]
predator.matrix = predatorFAs[, fa.set]
npredators = nrow(predator.matrix)

## Prey
prey.sub = preyFAs[, fa.set]
prey.sub = prey.sub / apply(prey.sub, 1, sum)
group = as.vector(preyFAs$Species)
prey.matrix.full = cbind(group,prey.sub)
prey.matrix = MEANmeth(prey.matrix.full)

## Calibration Coefficients
data(CC)
cal.vec = CC[CC$FA %in% fa.set, 2]
cal.mat = replicate(npredators, cal.vec)

# Note: uncomment examples to run. CRAN tests fail because execution time > 5 seconds
# diet.est <- p.QFASA(predator.mat = predator.matrix,
#                     prey.mat = prey.matrix,
#                     cal.mat = cal.mat,
#                     dist.meas = 2,
#                     start.val = rep(1,nrow(prey.matrix)),
#                     ext.fa = fa.set)[['Diet Estimates']]
#
# bias <- bias.all(p.mat = diet.est,
#                  prey.mat = prey.matrix.full,
#                  cal.mat = cal.mat,
#                  R.bias = 10,
#                  noise = 0,
#                  nprey = 50,
#                  dist.meas = 2,
#                  ext.fa = fa.set)


QFASA documentation built on Nov. 17, 2023, 1:08 a.m.