Add Data to OM
To condition our OM with catch-at-age (CAA) and catch-at-length (CAL) data, we create a blank Data object:
Data <- new('Data')and populate the Year, CAA, and CAL slots with our observed data:
# years - must be length(OM@nyears)
Data@Year <- RealData@Year 
# must be the same as OM@maxage
Data@MaxAge <- RealData@MaxAge
# 'real' CAA (can be patchy)
Data@CAA <- RealData@CAA[1,,,drop=FALSE] 
# an array with dimensions c(1, OM@nyears, OM@maxage+1)
dim(Data@CAA)## [1]  1 50 16# length bins
Data@CAL_bins <- RealData@CAL_bins
Data@CAL_mids <- RealData@CAL_mids
# 'real' CAL (can be patchy)
Data@CAL <- RealData@CAL[1,,,drop=FALSE] 
# an array with dimensions c(1, OM@nyears, length(Data@CAL_mids))
dim(Data@CAL)## [1]  1 50 28The selectivity pattern for the CAA and CAL data can be added with the Data@Vuln_CAA and Data@Vuln_CAL slots:
- Data@Vuln_CAA: Optional vulnerability-at-age schedule for catch-at-age samples. Used to condition OM for closed-loop simulation testing. Replaces the fleet selectivity schedule in the OM used to generate CAA samples. Matrix with dimensions nsim x MaxAge+1 .
- Data@Vuln_CAL: Optional vulnerability-at-length schedule for catch-at-length samples. Used to condition OM for closed-loop simulation testing. Replaces the fleet selectivity schedule in the OM used to generate CAL samples. Matrix with dimensions nsim x length(CAL_mids) .
These selectivity patterns are used to generate the CAA and CAL data in the simulation.
Note that in the case of real data, nsim is always 1 (only one version of the real data!).
We add the Data object to the cpars slot:
OM <- new('OM', Albacore, Generic_IncE, Generic_Obs, Perfect_Imp, nsim=4)
OM@cpars$Data <- DataWe also need to add the CAL_bins to cpars:
OM@cpars$CAL_bins <- Data@CAL_binsCondition Simulated Data
The observation model is conditioned on the index data when the historical spool-up period is simulated:
Hist <- Simulate(OM, silent=TRUE)We can now compare our simulated CAA data with our ‘real’ observed CAA data:
# The CAA data passed to the MPs (first 5 years and 3 age-classes only shown)
Hist@Data@CAA[,1:5,1:3]## , , 1
## 
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   21   28   21   11   11
## [2,]   21   28   21   11   11
## [3,]   21   28   21   11   11
## [4,]   21   28   21   11   11
## 
## , , 2
## 
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   28   28   39   39   28
## [2,]   28   28   39   39   28
## [3,]   28   28   39   39   28
## [4,]   28   28   39   39   28
## 
## , , 3
## 
##      [,1] [,2] [,3] [,4] [,5]
## [1,]   32    7   39   28   53
## [2,]   32    7   39   28   53
## [3,]   32    7   39   28   53
## [4,]   32    7   39   28   53# Our 'observed' CAA data (first 5 years and 3 age-classes only shown)
OM@cpars$Data@CAA[,1:5,1:3]##      [,1] [,2] [,3]
## [1,]   21   28   32
## [2,]   28   28    7
## [3,]   21   39   39
## [4,]   11   39   28
## [5,]   11   28   53# The CAL data passed to the MPs (first 5 years and 3 length-classes only shown)
Hist@Data@CAL[,1:5,1:3]## , , 1
## 
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    0    0    0    0    0
## [2,]    0    0    0    0    0
## [3,]    0    0    0    0    0
## [4,]    0    0    0    0    0
## 
## , , 2
## 
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    0    0    0    0    0
## [2,]    0    0    0    0    0
## [3,]    0    0    0    0    0
## [4,]    0    0    0    0    0
## 
## , , 3
## 
##      [,1] [,2] [,3] [,4] [,5]
## [1,]    0    0    0    0    0
## [2,]    0    0    0    0    0
## [3,]    0    0    0    0    0
## [4,]    0    0    0    0    0# Our 'observed' CAL data (first 5 years and 3 length-classes only shown)
OM@cpars$Data@CAL[,1:5,1:3]##      [,1] [,2] [,3]
## [1,]    0    0    0
## [2,]    0    0    0
## [3,]    0    0    0
## [4,]    0    0    0
## [5,]    0    0    0Note that the effective sample size in the observation model is NOT updated when CAA and CAL data are provided in the OM. That is, Obs@CAA_ESS, and Obs@CAL_ESS are not updated.
Obs@CAA_nsamp and Obs@CAL_nsamp are updated based on the mean observed sample size for the real data.