message(paste0("Starting modelComparisons.ModelFits.ZCs.All.Rmd. \n\tfleets=",params$ModelFitsZCs$fleets))
    ##input model list
    Models<-params$Models;
    doc_type<-params$doc_type;
    fleets<-params$ModelFitsZCs$fleets;
    plot1stObs<-params$ModelFitsZCs$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);

Model fits to size composition data

Fits to the size composition data available to the model(s) are presented in this section. 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.

Mean survey size compositions

  message("starting plotFits.SurveyMeanSizeComps")
  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

Fishery retained catch mean size compositions

  message("starting plotFits.MeanFisheryRetainedCatchSizeComps")
  plts<-rCompTCMs::compareFits.MeanSizeComps(Models,
                                             fleets=fleets,
                                             fleet.type="fishery",
                                             catch.type="retained",
                                             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

\clearpage

Fishery total catch mean size compositions

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

\blandscape

Survey size composition residuals

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.

  message("starting plotFits.SurveyZCsBubblePlotsM")
  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;}
  # message("starting plotFits.SurveyZCsBubblePlotsMM")
  # 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;}
  message("starting plotFits.SurveyZCsBubblePlotsF")
  mdfr<-rCompTCMs::extractFits.ZScores.PrNatZ(Models,
                                              fleets=fleets,
                                              fleet.type="survey",
                                              catch.type="index",
                                              residuals.type='pearsons',
                                              verbose=FALSE);
  #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;}
  # message("starting plotFits.SurveyZCsBubblePlotsMF")
  # 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;}

Effective Ns for survey size compositions

  message("starting plotFits.SurveyEffectiveNs")
  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 index catch size compositions from the ",captions[i],".");}
  for (plt in plts) {print(plt); fig<-fig+1;}

Fishery retained catch size composition residuals

Pearsons 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.

  message("starting plotFits.FisheryRetainedCatchZCsBubblePlots")
  plts<-rCompTCMs::compareFits.ZScores.PrNatZ(Models,
                                              fleets=fleets,
                                              fleet.type="fishery",
                                              catch.type="retained",
                                              residuals.type='pearsons',
                                              showPlot=FALSE,
                                              verbose=FALSE);
  captions<-wtsUtilities::getCaptionsFromGGPlotList(plts);
  for (plt in plts) {print(plt); fig<-fig+1;}
  rm(plt,plts);

Effective Ns for retained catch size compositions

  message("starting plotFits.RetainedCatchEffectiveNs")
  plts<-rCompTCMs::compareFits.EffectiveNs(Models,
                                           fleets=fleets,
                                           fleet.type="fishery",
                                           category="retained",
                                           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]," fishery.");}
  for (plt in plts) {print(plt); fig<-fig+1;}

Fishery total catch size composition residuals

  message("starting plotFits.FisheryTotalCatchZCsBubblePlots")
  plts<-rCompTCMs::compareFits.ZScores.PrNatZ(Models,
                                              fleets=fleets,
                                              fleet.type="fishery",
                                              catch.type="total",
                                              residuals.type='pearsons',
                                              showPlot=FALSE,
                                              verbose=FALSE);
  captions<-wtsUtilities::getCaptionsFromGGPlotList(plts);
  for (plt in plts) {print(plt); fig<-fig+1;}
  rm(plt,plts);

Effective Ns for total catch size compositions

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

\elandscape



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