#'
#'@title Get aggregate catch components in the objective function as a melted dataframe.
#'
#'@description Function to get aggregate catch components in the objective function as a melted dataframe.
#'
#'@param aggC - a list object reflecting an aggregate catch data source's contributions to the objective function
#'@param data.type - data type (abundance or biomass) of aggregated catch
#'@param verbose - flag (T/F) to print diagnostic info
#'
#'@return a melted dataframe
#'
#'@details The returned dataframe has columns named
#'"data.type", "fit.type", "nll.type", "year" (a dummy value = -1),
#'"sex", "maturity", "shell_condition", "variable", and "value".
#'
#'The "variable" column indicates whether the "value" is a weight ('wgt'),
#'negative log-likelihood ('nll'), or objective function value ('objfun').
#'
#'@export
#'
getObjFunValues.AggregateCatch<-function(aggC,
data.type='abundance',
verbose=FALSE){
mmdfr<-NULL;
for (n in 1:length(aggC$fits)){
f<-aggC$fits[[n]];
if (!is.null(f)){
dfrp<-data.frame(
data.type=data.type,
fit.type=aggC$fit.type,
nll.type=f$nll$nll.type,
year=-1,
sex=f$x,
maturity=f$m,
shell_condition=f$s,
wgt=f$nll$wgt,
nll=f$nll$nll,
objfun=f$nll$objfun,
stringsAsFactors=FALSE);
mdfr<-reshape2::melt(dfrp,measure.vars=c('wgt','nll','objfun'));
mmdfr<-rbind(mmdfr,mdfr);
}
}
return(mmdfr);
}
#mdfr.aggC<-getObjFunValues.AggregateCatch(aggC);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.