Hey Rick,
In case anyone is interested here is a quick R script to get numbers at age variance by age for a series of years. As it requires the model to be rerun for each year I built it using snowfall to speed up processing. One should change the starter file to ensure the model is being rerun using the par file and change the .ctl file being used is named "new.ctl", and in the "control.ss_new" file to include a stddev reporting line and age line. Also assumes one is using ss.exe. This is not generalized and anyone using it may need to edit it for their own use. I'm guessing this could be easily generalized for r4ss with little effort if others find this useful.
## Function to report the variance of the numbers at age by year from ss 3.30 for a single year
VAR1<-function(year=1978,file1=file,dir2=dir1,age1=age){
require(stringr)
setwd(dir2)
list.of.files=list.files(dir2)
setwd('..')
dir.create(paste0("Year_",year))
new.dir<-paste0(getwd(),"/Year_",year)
setwd(dir2)
file.copy(from=list.of.files,to=new.dir)
setwd(new.dir)
res<-readLines(file1)
nline=length(res)
res[nline-3]<-paste0("0 0 0 0 0 0 -1 ",year," 1")
res[nline-2]<-paste0(age1)
writeLines(res,"new.ctl")
system("ss.exe",show.output.on.console = F)
std=readLines("ss.std")
nline=length(std)
varage<-c(year,as.numeric(str_split(std[nline-3]," ")[[1]][18]),as.numeric(str_split(std[nline-3]," ")[[1]][19]))
return(varage)
}
## Function to report the variance of the numbers at age for a series of years using parallel computing for ss 3.30 models
NAGE_VAR<-function(dir1=getwd(),file="control.ss_new",age=3,years=1978:2019,cpu=4) {
require(snowfall)
sfInit( parallel=TRUE, cpus=cpu )
sfExportAll()
age3<-sfSapply(years,VAR1)
sfStop()
return(t(age3))
}