1. Appendix

1.1 Stock Profiles Jon

1.2 Fishery Profiles Oliver

1.3 Database Tables

All the input and output data for a calibration is located in an Access database titled “CalibrationSupport_xx.mdb”, where the “xx” signifies a name/date that uniquely identifies the calibration. An effort was made to capture nearly all input data and manipulations in the database and program code for documentation and reproducibility purposes.

Table Description

Input tables are ‘blue’, output tables are ‘green’, and legacy tables that are no longer used are ‘white’.

Calibration Database Table Descriptions

AEQs

AEQTable<-as.data.frame(read.csv("objects/AEQ.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:AEQTable)",
                      "Adult Equivalent Values",
                      "</caption>"),
                      "</p>")

(#tab:AEQTable)Adult Equivalent Values

AEQTable

Base Period Cohort Sizes

BPCohortTable<-as.data.frame(read.csv("objects/BaseCohort.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:BPCohortTable)",
                      "Base Period Cohort Sizes",
                      "</caption>"),
                      "</p>")

(#tab:BPCohortTable)Base Period Cohort Sizes

BPCohortTable

Base Period Exploitation Rates

BPRate<-as.data.frame(read.csv("objects/BaseExploitationRate.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:BPRate)",
                      "Base Period Exploitation Rates",
                      "</caption>"),
                      "</p>")

(#tab:BPRate)Base Period Exploitation Rates

BPRate

Base Period Marked Catches

MrkCatch<-as.data.frame(read.csv("objects/BasePeriodCatch.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:MrkCatch)",
                      "Base Period Marked Catches",
                      "</caption>"),
                      "</p>")

(#tab:MrkCatch)Base Period Marked Catches

MrkCatch

Base Period Total Catches

TotalCatch<-as.data.frame(read.csv("objects/BasePeriodCatch_Tot.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:TotalCatch)",
                      "Base Period Total Catches (Marked + Unmarked)",
                      "</caption>"),
                      "</p>")

(#tab:TotalCatch)Base Period Total Catches (Marked + Unmarked)

TotalCatch

Base Period Marked Escapements

MrkEscape<-as.data.frame(read.csv("objects/BPEscapements.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:MrkEscape)",
                      "Base Period Marked Escapements",
                      "</caption>"),
                      "</p>")

(#tab:MrkEscape)Base Period Marked Escapements

MrkEscape

Base Period Total Escapements

TotalEscape<-as.data.frame(read.csv("objects/BPEscapements_Tot.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:TotalEscape)",
                      "Base Period Total Escapements (Marked + Unmarked)",
                      "</caption>"),
                      "</p>")

(#tab:TotalEscape)Base Period Total Escapements (Marked + Unmarked)

TotalEscape

Coded-Wire-Tag Adjustments for Sinclair Inlet (Area 10E)

Sinclair<-as.data.frame(read.csv("objects/CWT 10E adjustments.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:Sinclair)",
                      "Sinclair Inlet CWT Adjustments",
                      "</caption>"),
                      "</p>")

(#tab:Sinclair)Sinclair Inlet CWT Adjustments

Sinclair

Out-of-Base CWTs for White River

WhiteOOB<-as.data.frame(read.csv("objects/CWT_WhiteOOB.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:WhieOOB)",
                      "White River Out-of-Base CWT Recoveries",
                      "</caption>"),
                      "</p>")

(#tab:WhieOOB)White River Out-of-Base CWT Recoveries

WhiteOOB

Coded-Wire-Tag Recovery Data

CWTAll<-as.data.frame(read.csv("objects/CWTAll.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:CWTAll)",
                      "Coded-Wire-Tag Recovery Data",
                      "</caption>"),
                      "</p>")

(#tab:CWTAll)Coded-Wire-Tag Recovery Data

CWTAll

Coded-Wire-Tags for South Puget Sound Surrogate Method

CWTSPS<-as.data.frame(read.csv("objects/CWTforSPS_SurroagteMethod.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:CWTSPS)",
                      "South Sound Coded-Wire-Tags",
                      "</caption>"),
                      "</p>")

(#tab:CWTSPS)South Sound Coded-Wire-Tags

CWTSPS

Coded-Wire-Tags to Impute Age 5 Recoveries

CWTAge5<-as.data.frame(read.csv("objects/CWTImputedAge5.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:CWTAge5)",
                      "Coded-Wire-Tags to Impute Age 5 Recoveries",
                      "</caption>"),
                      "</p>")

(#tab:CWTAge5)Coded-Wire-Tags to Impute Age 5 Recoveries

CWTAge5

Coded-Wire-Tags Recoveries for Strait of Juan de Fuca (JDF)

CWTJDF<-as.data.frame(read.csv("objects/CWTJDFSurrogate071816.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:CWTJDF)",
                      "JDF Surrogate CWTs",
                      "</caption>"),
                      "</p>")

(#tab:CWTJDF)JDF Surrogate CWTs

CWTJDF

Base Period Coded-Wire-Tags Recoveries Merged with Out-Of-Base Recoveries

CWTMerged<-as.data.frame(read.csv("objects/CWTOOBMerged.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:CWTMerged)",
                      "Base Period CWTs Merged with Out-Of-Base Recoveries",
                      "</caption>"),
                      "</p>")

(#tab:CWTMerged)Base Period CWTs Merged with Out-Of-Base Recoveries

CWTMerged

FRAM Chinook Fisheries

Fish<-as.data.frame(read.csv("objects/Fishery.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:Fish)",
                      "JDF Surrogate CWTs",
                      "</caption>"),
                      "</p>")

(#tab:Fish)JDF Surrogate CWTs

Fish

Marked Fishery Model Stock Proportions

MSP<-as.data.frame(read.csv("objects/FisheryModelStockProportion.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:MSP)",
                      "Marked Model Stock Proportions",
                      "</caption>"),
                      "</p>")

(#tab:MSP)Marked Model Stock Proportions

MSP

Total (Marked + Unmarked) Fishery Model Stock Proportions

MSPTot<-as.data.frame(read.csv("objects/FisheryModelStockProportion_Tot.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:MSPTot)",
                      "Total (Marked + Unmarked) Model Stock Proportions",
                      "</caption>"),
                      "</p>")

(#tab:MSPTot)Total (Marked + Unmarked) Model Stock Proportions

MSPTot

Fishery Scalers

FishScaler<-as.data.frame(read.csv("objects/FishScalar.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:FishScaler)",
                      "Fishery Scalers",
                      "</caption>"),
                      "</p>")

(#tab:FishScaler)Fishery Scalers

FishScaler

Von Bertalaffy Growth Parameters

VBGrowth<-as.data.frame(read.csv("objects/Growth.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:VBGrowth)",
                      "Von Bertalaffy Growth Parameters",
                      "</caption>"),
                      "</p>")

(#tab:VBGrowth)Von Bertalaffy Growth Parameters

VBGrowth

Instructions for Imputing Surrogate CWT Recoveries

CWTSurrogate<-as.data.frame(read.csv("objects/ImputeRecoveries.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:CWTSurrogate)",
                      "Instructions for Imputing Surrogate CWT Recoveries",
                      "</caption>"),
                      "</p>")

(#tab:CWTSurrogate)Instructions for Imputing Surrogate CWT Recoveries

CWTSurrogate

Incidental Mortality Rates

Incidental<-as.data.frame(read.csv("objects/IncidentalRate.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:Incidental)",
                      "Incidental Mortality Rates",
                      "</caption>"),
                      "</p>")

(#tab:Incidental)Incidental Mortality Rates

Incidental

Maturation Rates

MatRate<-as.data.frame(read.csv("objects/MaturationRate.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:MatRate)",
                      "Maturation Rates",
                      "</caption>"),
                      "</p>")

(#tab:MatRate)Maturation Rates

MatRate

Natural Mortality Rates

NatRate<-as.data.frame(read.csv("objects/NaturalMortality.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:NatRate)",
                      "Natural Mortality Rates",
                      "</caption>"),
                      "</p>")

(#tab:NatRate)Natural Mortality Rates

NatRate

Marked Non-Retention Chinook Encounters

NR<-as.data.frame(read.csv("objects/NonRetention.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:NR)",
                      "Marked Non-Retention Chinook Encounters",
                      "</caption>"),
                      "</p>")

(#tab:NR)Marked Non-Retention Chinook Encounters

NR

Total (Marked + Unmarked) Non-Retention Chinook Encounters

NRTot<-as.data.frame(read.csv("objects/NonRetention_Tot.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:NRTot)",
                      "Total (Marked + Unmarked) Non-Retention Chinook Encounters",
                      "</caption>"),
                      "</p>")

(#tab:NRTot)Total (Marked + Unmarked) Non-Retention Chinook Encounters

NRTot

Sublegal Mortality Rates

SLRate<-as.data.frame(read.csv("objects/ShakerMortRate.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:SLRate)",
                      "Sublegal Mortality Rates",
                      "</caption>"),
                      "</p>")

(#tab:SLRate)Sublegal Mortality Rates

SLRate

Minimum Size Limits

SizeL<-as.data.frame(read.csv("objects/SizeLimits.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:SizeL)",
                      "Minimum Size Limits",
                      "</caption>"),
                      "</p>")

(#tab:SizeL)Minimum Size Limits

SizeL

FRAM Chinook Stocks

Stocks<-as.data.frame(read.csv("objects/Stocks.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:Stocks)",
                      "Maturation Rates",
                      "</caption>"),
                      "</p>")

(#tab:Stocks)Maturation Rates

Stocks

Run Summary Information

Run<-as.data.frame(read.csv("objects/SummaryInfo.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:Run)",
                      "Run Summary Information",
                      "</caption>"),
                      "</p>")

(#tab:Run)Run Summary Information

Run

Surrogate Fishery Base Period Exploitation Rates

SurrogateBPER<-as.data.frame(read.csv("objects/SurrogateFishBPER.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:SurrogateBPER)",
                      "Surrogate Fishery Base Period Exploitation Rates",
                      "</caption>"),
                      "</p>")

(#tab:SurrogateBPER)Surrogate Fishery Base Period Exploitation Rates

SurrogateBPER

Target Encounter Rates

TargetER<-as.data.frame(read.csv("objects/TargetEncounterRates.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:TargetER)",
                      "Target Encounter Rates",
                      "</caption>"),
                      "</p>")

(#tab:TargetER)Target Encounter Rates

TargetER

Terminal Fishery Flags

TermFlags<-as.data.frame(read.csv("objects/TerminalFisheryFlag.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:TermFlags)",
                      "Terminal Fishery Flags",
                      "</caption>"),
                      "</p>")

(#tab:TermFlags)Terminal Fishery Flags

TermFlags

FRAM Time Steps

TimeSteps<-as.data.frame(read.csv("objects/TimeStep.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:TimeSteps)",
                      "FRAM Time Steps",
                      "</caption>"),
                      "</p>")

(#tab:TimeSteps)FRAM Time Steps

TimeSteps

Base Period Update Log

Log<-as.data.frame(read.csv("objects/UpdateLog.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:Log)",
                      "Base Period Update Log",
                      "</caption>"),
                      "</p>")

(#tab:Log)Base Period Update Log

Log

CWT Weighting

Weighting<-as.data.frame(read.csv("objects/Weighting.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:Weighting)",
                      "CWT Weighting",
                      "</caption>"),
                      "</p>")

(#tab:Weighting)CWT Weighting

Weighting

White River Maturation Rates

WhiteMatR<-as.data.frame(read.csv("objects/WhiteMatRate.csv"), header = TRUE)|>
     DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  rownames = FALSE,
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:WhiteMatR)",
                      "White River Maturation Rates",
                      "</caption>"),
                      "</p>")

(#tab:WhiteMatR)White River Maturation Rates

WhiteMatR

1.4 Length-At-Age Distribution Parmeters

lengthtable<-as.data.frame(read.csv("objects/Length at Age.csv", header = TRUE))|>
  DT::datatable(filter = 'top',
                extensions = 'Buttons',
                options = list(
                  dom = 'Bfrtip',
                  buttons = c('copy', 'csv', 'excel', 'pdf', 'print')))

cat("<p>", paste0("<caption>",
                      "(#tab:LAge)",
                      "Length-At-Age Distribution Parameters
Stage 1 analysis results. Maximum likelihood estimates of the mean, SD, and CV of fork length (FL, mm) by age (in months) for stock-time estimation strata for which sufficient records occurred to estimate distributional parameters (N = 20). Note, the two suspected outliers that were included in VBGF estimation but not in the CV function analysis are denoted by ‘**’; columns ‘Age’ and ‘Mean FL (cm)’ are the values used for fitting VBGFs.",
                      "</caption>"),
                      "</p>")

(#tab:LAge)Length-At-Age Distribution Parameters Stage 1 analysis results. Maximum likelihood estimates of the mean, SD, and CV of fork length (FL, mm) by age (in months) for stock-time estimation strata for which sufficient records occurred to estimate distributional parameters (N = 20). Note, the two suspected outliers that were included in VBGF estimation but not in the CV function analysis are denoted by ’**’; columns ‘Age’ and ‘Mean FL (cm)’ are the values used for fitting VBGFs.

lengthtable

1.4 WinBUGS Code for Fitting Growth Functions

##WinBUGS code for VB Growth fxn  #####
### Specs for FRAM VBGF parameter estimation: 
## N = 3 chains, thinned to 1 in 50
## N = 31k total interations (1k initial, 30k thereafter, summarize 5001+)
model 
{
    # priors
    mu.a0~dnorm(0, 0.001) # Mean hyperparameter for a0
    mu.Linf~dnorm(0, 0.001) # Mean hyperparameter for Linf
    mu.k~dnorm(0, 0.001) # Mean hyperparameter for k
    sigma.a0~dunif(0, 10000) # SD hyperparameter for a0
    sigma.Linf~dunif(0, 10000) # SD hyperparameter for Linf
    sigma.k~dunif(0, 10000) # SD hyperparameter for k
    sigma~dunif(0, 10000) # Residual standard deviation
    tau.a0 <- 1/(sigma.a0*sigma.a0)
    tau.Linf <- 1/(sigma.Linf*sigma.Linf)
    tau.k <- 1/(sigma.k*sigma.k)
    tau <- 1/(sigma*sigma) # Residual precision

    # hierarchical parmeters
    for (i in 1:P) {
        Linf[i]~dnorm(mu.Linf, tau.Linf) 
        k[i]~dnorm(mu.k, tau.k)#I(0,)
        a0[i]~dnorm(mu.a0, tau.a0) 
    }

    # likelihood
    for (i in 1:N) {
        li[i] ~ dnorm(Lai[i],tau)
        Lai[i]<-Linf[pop[i]]*(1-exp(-k[pop[i]]*(ai[i]-a0[pop[i]])))  
        # Observation-level GOF calcs
        pred[i] <- Lai[i]
        rep_li[i] ~ dnorm(pred[i], tau)   #simulate perfect dataset
        rep_resid[i] <- rep_li[i]-pred[i]   #calc resid for simulated data
        resid[i] <- li[i] - pred[i]   #calc resid for actual data
        sq[i] <- pow(resid[i],2)  #calc squared resids for actual data                              sq_new[i] <- pow(rep_resid[i],2)   #calc squared resids for simulated data
    }
    # Dataset-level GOF calcs
    fit<-sum(sq[]) #sum squared resids for actual data
    fit_new<-sum(sq_new[]) #sum squared resids for simulated data
    test<-step(fit_new-fit) #determine which is greater (0s and 1s)
    bpvalue<-mean(test) #mean of 0,1 gives Bayesian P-value
}   

# inits
list(a0=c(-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5,-5), k=c(0.03,0.03,0.03,0.03,0.03,0.03,0.03,0.03,0.03,0.03,0.03,0.03,0.03), Linf=c(950,950,950,950,950,950,950,950,950,950,950,950,950),mu.a0=-5,mu.k=0.03,mu.Linf=950,sigma.a0=1,sigma.Linf=1,sigma.k=1,sigma=1)

#data -- also must load secondary data file (Appendix A) with stock-month means
list(N=164, P=13) #n is 165 observations (0 indexed) and 13 stock aggregates