SMUFASA Workflow Example"

Load Packages


Modeling Inputs

Prior to starting make sure that:

Fatty Acid Set

fa.set = as.vector(unlist(FAset))

Matrix of Predator FA Signatures

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

Matrix of Prey FA Signatures

prey.matrix = preyFAs[,-c(1,3)]

# Selecting 5 prey species to include <-c("capelin", "herring", "mackerel", "pilchard", "sandlance") <- sort( <- prey.matrix %>%
  filter(Species %in%

Prey Lipid Content

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


smufasa.est <- p.SMUFASA(predator.matrix,,, fa.set)

p.SMUFASA Output

The MUFASA output is a list with 4 components:

Calibration Coefficient Estimates

A vector of length equal to the number of FAs used and whose sum is the total number of FAs used. Thos is a set of calibration coefficients common to all predators used.

````r CalEst <- smufasa.est$Cal_Estimates

## Diet Estimates

The diet estimate vector returned by `p.SMUFASA` represents an overall common diet for all predators in `predator.matrix` . **Note**: If you wish to obtain diet estimates for each individual predator see the steps below.

DietEst <- smufasa.est$Diet_Estimates


This is a vector of the negative log likelihood values at each iteration of the optimizer.

````r nll <- smufasa.est$nll

## Var_Epsilon

This is the optimized diagonal values of the variance-covariance matrix of the errors. See reference in help file for details.
VarEps <- smufasa.est$Var_Epsilon

Obtaining Diet Estimates

Once a vector of calibration coefficients is obtained via p.SMUFASA you can pass this vector to p.QFASA or p.MUFASA to obtain individual diet estimates.


Q = p.QFASA(predator.matrix=predator.matrix, prey.matrix=prey.matrix, 
            cal.mat=CalEst, dist.meas=2, gamma=1,, 
            start.val=rep(1,nrow(, ext.fa=fa.set)

QFASA Diet Estimates:

DietEst.Q <- Q$'Diet Estimates'

See p.QFASA documnetation for further details.


M <- p.SMUFASA(predator.matrix,, cal.est,, fa.set)
DietEst.M <- M$Diet_Estimates

See p.MUFASA documnetation for further details.

Try the QFASA package in your browser

Any scripts or data that you put into this service are public.

QFASA documentation built on July 21, 2021, 1:06 a.m.