p.SMUFASA: Simultaneous maximum unified fatty acid signature analysis

View source: R/All_SimultaneousEst_MUFASA_Code.R

p.SMUFASAR Documentation

Simultaneous maximum unified fatty acid signature analysis

Description

Returns SMUFASA calibration coefficient estimates and an average diet among a sample of predators.

Usage

p.SMUFASA(pred.mat, prey.mat, FC, ext.fa)

Arguments

pred.mat

matrix containing the FA signatures of the predators.

prey.mat

matrix containing FA signatures from each prey group. The first column must index the prey group. prey.mat is the prey database.

FC

vector of fat content of length equal to the number of prey groups or species.

ext.fa

subset of fatty acids to be used to obtain estimates.

Details

Calibration coefficients (CCs) are not supplied but are instead estimated. While one overall diet is computed, the CCs can be used in p.QFASA or p.MUFASA to estimate individual diet estimates.

Value

A list with components:

Cal_Estimates

A vector of estimated calibration coefficients common to all predators. The k th value corresponds to the k th fatty acid. The estimates sum to the number of fatty acids.

Diet_Estimate

A vector of estimates of the average diet among the predators. The estimates are expressed as proportions summing to one.

Var_Epsilon

Optimized values of error variance.

nll

Negative log likelihood values. As per solnp documentation, nll is "Vector of function values during optimization with last one the value at the optimal".

Examples

## This example takes some time to run.
## Please uncomment code below to run.

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

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

## Prey
## Extracting a small number of species to speed up calculations for the example.
#data(preyFAs)
#prey.matrix = preyFAs[,-c(1,3)]
#spec.red <-c("capelin", "herring", "mackerel", "pilchard", "sandlance")
#spec.red <- sort(spec.red)
#prey.red <- prey.matrix %>% filter(Species %in% spec.red)

## Fat content
#FC = preyFAs[,c(2,3)]
#FC = FC %>%  arrange(Species)
#FC.vec = tapply(FC$lipid,FC$Species,mean,na.rm=TRUE)
#FC.red <- FC.vec[spec.red]

#out <- p.SMUFASA(predator.matrix, prey.red, FC.red, fa.set)

#out$Cal_Estimates


QFASA documentation built on Sept. 11, 2024, 8:08 p.m.