diff --git a/docs/Age_Survey.html b/docs/Age_Survey.html new file mode 100644 index 0000000..22ee5ed --- /dev/null +++ b/docs/Age_Survey.html @@ -0,0 +1,5572 @@ + + + + + + + + + + +Age sampling + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Age sampling

+
+ + + +
+ +
+
Author
+
+

Ianelli

+
+
+ + + +
+ + + +
+ + +
+

Summary

+

Due to short staffing issues for the age-and-growth program, the number of ages that can be determined for the EBS shelf survey has declined.
+The following presents a simple approach to evaluate the relative impact on proportions at age as a function of reductions from historical samples compared with the full set.

+

For the fishery data, similar implications are considered for the age compositions.

+
+
+

Survey

+

We downloaded the specimen file from survey data (downloaded for EBS shelf survey data from AKFIN answers). Note that the data on AKFIN only were available through 2022. These were then converted to a data frame for analysis.

+

The total samples over time, including those age-1 are shown in Figure 1. We then show the number of samples over time in Figure 2 by age.

+
+
+
+
+
+ +
+
+Figure 1: Number of pollock samples aged in the EBS shelf trawl survey by year, including those that were age-1 for reference. The red line is the mean number of samples over time. The blue dots are the number of age-1 samples. +
+
+
+
+
+
+
+
+
+ +
+
+Figure 2: Number of pollock samples aged in the EBS shelf trawl survey by year and age. +
+
+
+
+
+
+

Resampling evaluations

+

We resampled the available historical data to evaluate the impact of reduced samples on the age composition.
+We sampled at different levels from 0.25, 0.5,…, 0.9 and examined the plots (Figure 3). For display we examined the distributions of the computed proportions by age under these levels of reductions.

+

These plots were also created for some of the younger ages (Figure 4).

+
+
+

Initial conclusions

+

In answer to the response of whether the age composition is impacted by the reduced samples, the answer is yes. A reduction in the number of samples to about 60% of historical sampling levels should be acceptable for assessment purposes. However, we caution that any refinement in the spatio-temporal stratification of the survey for age compositions would suffer higher levels of uncertainty.

+
+
+
+
+
+ +
+
+Figure 3: Comparisons of the age composition for pollock in the EBS shelf trawl survey for ages 5-8 for cohorts since 2010. Note that the panel labels correspond to the age (top) and year (second line) of the data shown in the plot. The proportion is the number of samples at a given age divided by the total number of samples for a given year. +
+
+
+
+
+
+
+
+
+
+ +
+
+Figure 4: Comparisons of the age composition for pollock in the EBS shelf trawl survey for ages 1-3 for cohorts since 2016. Note that the panel labels correspond to the age (top) and year (second line) of the data shown in the plot. The proportion is the number of samples at a given age divided by the total number of samples for a given year. +
+
+
+
+
+ +
+
+ +
+ + +
+ + + + + + \ No newline at end of file diff --git a/docs/Age_Survey.qmd b/docs/Age_Survey.qmd new file mode 100644 index 0000000..2a9efc3 --- /dev/null +++ b/docs/Age_Survey.qmd @@ -0,0 +1,159 @@ +--- +title: "Age sampling" +author: "Ianelli" +lightbox: true +format: + html: + embed-resources: true + toc: true +editor_options: + chunk_output_type: console +--- + +# Summary + +Due to short staffing issues for the age-and-growth program, the number of ages +that can be determined for the EBS shelf survey has declined. +The following presents a simple approach to evaluate the relative impact on proportions +at age as a function of reductions from historical samples compared with the full +set. + +For the fishery data, similar implications are considered for the age compositions. + +# Survey +We downloaded the specimen file from survey data (downloaded for EBS +shelf survey data from AKFIN answers). **Note that the data on AKFIN only were +available through 2022.** These were then converted to a data frame for analysis. + +The total samples over time, including those age-1 are shown in @fig-fig1. +We then show the number of samples over time in @fig-fig2 by age. + +```{r startup} +#| echo: false +#| warning: false + +library(here) +library(janitor) +library(tidyverse) + +plus_age <- 13 +#survey <- read_csv(here("doc","data","race_specimen.csv")) |> clean_names() |> filter(!is.na(age_years)) |> mutate(age=as.factor(ifelse(age_years>plus_age,plus_age,age_years))) +#saveRDS(survey,here("doc","data","survey.rds")) +#save(survey,file = here("doc","data","survey.Rdata")) +load(here("data/survey.Rdata")) +#rm(survey) +#survey <- readRDS(here("doc","data","survey.rds")) + +#glimpse(survey) +``` + +```{r} +#| echo: false +#| label: fig-fig1 +#| warning: false +#| fig-cap: "Number of pollock samples aged in the EBS shelf trawl survey by year, including those that were age-1 for reference. The red line is the mean number of samples over time. The blue dots are the number of age-1 samples." +mnN <- survey |> filter(age_years>0,!is.na(age_years)) |> group_by(year) |> tally() |> + summarise(sum(n)) |> pull() +nyrs <- survey |> filter(age_years>0,!is.na(age_years)) |> group_by(year) |> length() +mnN <- mnN/nyrs +p1 <- survey |> filter(age_years>0,!is.na(age_years)) |> + group_by(year) |> tally() |> rbind(data.frame(year=2020,n=0)) |> arrange(year) |> + ggplot(aes(x=year,y=n)) + + geom_path(color="red",size=2,stat='identity') + geom_hline(yintercept=mnN) + + geom_point(color="black",size=2,stat='identity') + + geom_point(data= survey |> filter(age_years==1) |> group_by(year) |> tally(), color="blue",size=3) + + ggtitle("Number of EBS pollock aged by year in survey (blue dots=N age 1)") + ggthemes::theme_few() + ylim(0,NA) +plotly::ggplotly(p1) +``` + +```{r} +#| echo: false +#| label: fig-fig2 +#| warning: false +#| fig-cap: "Number of pollock samples aged in the EBS shelf trawl survey by year and age." + +p2 <- survey |> filter(age_years>0,!is.na(age_years)) |> group_by(year,age) |> tally() |> + ggplot(aes(x=age,y=n,fill=age)) + geom_bar(stat='identity') + + facet_wrap(.~year) + ggthemes::theme_few(base_size=8) +p2 +``` + + +## Resampling evaluations + +We resampled the available historical data to evaluate the impact of reduced samples on the age composition. +We sampled at different levels from 0.25, 0.5,..., 0.9 and examined the plots (@fig-fig3). For display we examined +the distributions of the computed proportions by age under these levels of reductions. + +These plots were also created for some of the younger ages (@fig-fig4). + +## Initial conclusions + +In answer to the response of whether the age composition is impacted by the reduced samples, the answer is yes. A reduction in +the number of samples to about 60% of historical sampling levels should be acceptable +for assessment purposes. However, we caution that any refinement in the spatio-temporal stratification of the survey +for age compositions would suffer higher levels of uncertainty. + + +```{r viol1} +#| echo: false +#| label: fig-fig3 +#| warning: false +#| fig-cap: "Comparisons of the age composition for pollock in the EBS shelf trawl survey for ages 5-8 for cohorts since 2010. Note that the panel labels correspond to the age (top) and year (second line) of the data shown in the plot. The proportion is the number of samples at a given age divided by the total number of samples for a given year. " + +nsims <- 100 +df1 <- NULL +do_samples<-FALSE + +if (do_samples) { + for (j in c(.25, .5, .6, .7, .8, .9)) { + reduction <- j + for (i in 1:nsims) { + df1 <- rbind(survey |> filter(age_years>0,!is.na(age_years)) |> slice_sample(prop=reduction) |> + mutate(age=as.numeric(age_years)) |> + group_by(year,age) |> tally() |> mutate(Year=as.factor(year),anntotal=sum(n)) |> + ungroup() |> group_by(year,age) |> summarise(prop=sum(n)/anntotal,.groups='drop') |> + ungroup() |> mutate(red=j,sim=i) ,df1) + + } + print(j) + } +} +#save(df1,file = here("doc","data","samples.Rdata")) +#rm(df1) +load(here("data/samples.Rdata")) +# compute base proportions + +#p3 <- df1 |> filter(year >2018, age %in% 1:3) |> +p3 <- df1 |> filter(year >2017, age %in% 5:8) |> + mutate(cohort=as.factor(year-age) ,reduction=as.factor(red), age=as.factor(age)) |> ggplot(aes(x=reduction,y=prop,fill=cohort)) + + geom_violin(color = NA) + facet_wrap(age~year,scales="fixed") + ylim(0,NA) + + ylab("proportion") + ggthemes::theme_few(base_size=9); p3 +#plotly::ggplotly(p3) + +``` +```{r younger} +#| echo: false +#| label: fig-fig4 +#| warning: false +#| fig-cap: "Comparisons of the age composition for pollock in the EBS shelf trawl survey for ages 1-3 for cohorts since 2016. Note that the panel labels correspond to the age (top) and year (second line) of the data shown in the plot. The proportion is the number of samples at a given age divided by the total number of samples for a given year. " +p4 <- df1 |> filter(year >2018, age %in% 1:3) |> + mutate(cohort=as.factor(year-age) ,reduction=as.factor(red), age=as.factor(age)) |> + ggplot(aes(x=reduction,y=prop,fill=cohort,color=NULL)) + + geom_violin(color = NA) + facet_wrap(age~year,scales="fixed") + ylim(0,NA) + + ylab("proportion") + ggthemes::theme_few(base_size=9); p4 + +#reduction <- 0.6 +#p4 <- survey |> filter(age_years>0,!is.na(age_years)) |> slice_sample(prop=reduction) |> + #group_by(year,age) |> tally() |> mutate(year=as.factor(year),anntotal=sum(n)) |> + #ungroup() |> group_by(year,age) |> summarise(prop=sum(n)/anntotal) |> ungroup() |> + #ggplot(aes(x=age,y=prop,fill=year)) + geom_bar(stat='identity') + facet_wrap(.~year) + + #ggthemes::theme_few() +#p4 + #mutate(prop=n/sum(n)) |> ungroup() |> select(-n) |> + #pivot_wider(names_from=age,values_from=prop) |> + #mutate(year=as.factor(year)) |> +#p3$data +``` + +