##input model list
    Models<-params$Models;
    fleets<-params$fleets;
    doc_type<-params$doc_type;
    plot1stObs<-params$plot1stObs;

    ##set appendix letter
    app="A";
    ##set knitr options for subsequent chunks
    knitr::opts_chunk$set(echo=FALSE, error=FALSE, message=FALSE, warning=FALSE, concordance=TRUE, fig.width=6.5, fig.height=7.0, dpi=300)

    ##set caption numbering
    if (!exists("fig")){
      fig<-1;#figures
      tbl<-0;#tables
    }

    cases<-names(Models);
    nCases<-length(cases);

\section{Introduction} Fits to survey size composition data available to the model(s) are presented in this section. Included are plots of mean fits to size compositions, Pearson's residuals as bubble plots, and effective sample sizes. Not all of the fits presented are necessarily included in the parameter optimization for each model; some fits to datasets for a particular model may be included for comparison purposes with other models which include those data in their optimization. The reader should consult the main assessment document to determine which fits are included in the optimization for any particular model.

\section{Mean survey size compositions}

  plts<-rCompTCMs::compareFits.MeanSizeComps(Models,
                                             fleets=fleets,
                                             fleet.type="survey",
                                             catch.type="index",
                                             facet_grid="x+m+s~.",
                                             plot1stObs=plot1stObs,
                                             showPlot=FALSE,
                                             verbose=FALSE);
  captions<-wtsUtilities::getCaptionsFromGGPlotList(plts);
  for (plt in plts) {print(plt); cat("\n\n"); fig<-fig+1;}
  rm(plt,plts);

\FloatBarrier

\begin{landscape}

\section{Residuals to survey size composition data}

Pearson's residuals are plotted for fits to size composition data. Symbol areas reflect the size of each residual, Extreme values (residuals larger than 4 in scale) are indicated with a red "X" to facilitate identification.

  mdfr<-rCompTCMs::extractFits.ZScores.PrNatZ(Models,
                                              fleets=fleets,
                                              fleet.type="survey",
                                              catch.type="index",
                                              residuals.type='pearsons',
                                              verbose=FALSE);
  #idx<-(mdfr$x=="male")&(mdfr$m=="immature");
  idx<-(mdfr$x=="male");
  plts<-rCompTCMs::compareFits.ZScores.PrNatZ(mdfr=mdfr[idx,],
                                              fleets=fleets,
                                              fleet.type="survey",
                                              catch.type="index",
                                              residuals.type='pearsons',
                                              showPlot=FALSE,verbose=FALSE);
  captions<-wtsUtilities::getCaptionsFromGGPlotList(plts);
  for (plt in plts) {print(plt); fig<-fig+1;}
  # mdfr<-rCompTCMs::extractFits.ZScores.PrNatZ(Models,
  #                                             fleet.type="survey",
  #                                             catch.type="index",
  #                                             residuals.type='pearsons',
  #                                             verbose=FALSE);
  # idx<-(mdfr$x=="male")&(mdfr$m=="mature");
  # plts<-rCompTCMs::compareFits.ZScores.PrNatZ(mdfr=mdfr[idx,],
  #                                             fleet.type="survey",
  #                                             catch.type="index",
  #                                             residuals.type='pearsons',
  #                                             showPlot=FALSE,
  #                                             verbose=FALSE);
  # captions<-wtsUtilities::getCaptionsFromGGPlotList(plts);
  # for (plt in plts) {print(plt); fig<-fig+1;}
  #idx<-(mdfr$x=="female")&(mdfr$m=="immature");
  idx<-(mdfr$x=="female");
  plts<-rCompTCMs::compareFits.ZScores.PrNatZ(mdfr=mdfr[idx,],
                                              fleets=fleets,
                                              fleet.type="survey",
                                              catch.type="index",
                                              residuals.type='pearsons',
                                              showPlot=FALSE,
                                              verbose=FALSE);
  captions<-wtsUtilities::getCaptionsFromGGPlotList(plts);
for (plt in plts) {print(plt); fig<-fig+1;}
  # mdfr<-rCompTCMs::extractFits.ZScores.PrNatZ(Models,
  #                                             fleet.type="survey",
  #                                             catch.type="index",
  #                                             residuals.type='pearsons',
  #                                             verbose=FALSE);
  # idx<-(mdfr$x=="female")&(mdfr$m=="mature");
  # plts<-rCompTCMs::compareFits.ZScores.PrNatZ(mdfr=mdfr[idx,],
  #                                             fleet.type="survey",
  #                                             catch.type="index",
  #                                             residuals.type='pearsons',
  #                                             showPlot=FALSE,
  #                                             verbose=FALSE);
  # captions<-wtsUtilities::getCaptionsFromGGPlotList(plts);
  # for (plt in plts) {print(plt); fig<-fig+1;}

\section{Effective sample sizes for survey size compositions}

  plts<-rCompTCMs::compareFits.EffectiveNs(Models,
                                           fleets=fleets,
                                           fleet.type="survey",
                                           category="index",
                                           showPlot=FALSE,
                                           verbose=FALSE)
  captions<-wtsUtilities::getCaptionsFromGGPlotList(plts);
  for (i in 1:length(captions)) {captions[i]<-
      paste0("Input and effective sample sizes from retained catch size compositions from the ",captions[i],".");}
  for (plt in plts) {print(plt); fig<-fig+1;}

\end{landscape}



wStockhausen/rCompTCMs documentation built on Sept. 12, 2023, 3:13 p.m.