Skip to content

Commit

Permalink
Use WRA in national stats
Browse files Browse the repository at this point in the history
  • Loading branch information
langbart committed Jan 4, 2024
1 parent 534c410 commit b628d01
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
Binary file modified .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions data-raw/get-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ RDI_tab <-

timor_population <-
readr::read_csv(system.file("timor_census_2022.csv", package = "timor.nutrients")) %>%
dplyr::filter(!gender == "Total") %>%
dplyr::filter(gender == "Female") %>%
dplyr::group_by(region) %>%
dplyr::filter(age > 5) %>%
dplyr::filter(age > 14 & age < 50) %>%
dplyr::summarise(population = sum(count, na.rm = T)) %>%
dplyr::add_row(region = "All", population = sum(.$population)) %>%
dplyr::ungroup()
Expand Down
Binary file modified data/timor_population.rda
Binary file not shown.
10 changes: 5 additions & 5 deletions docs/highlight.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h1>
<div id="header">
<h1 class="title">Modelling scenarios for nutrient-sensitive fisheries management</h1>
<p class="author"><em>Lorenzo Longobardi</em></p>
<p class="date"><em>Last update: 2023-12-27</em></p>
<p class="date"><em>Last update: 2024-01-04</em></p>
</div>
<div id="content" class="section level1 hasAnchor" number="1">
<h1><span class="header-section-number">1</span> Content<a href="index.html#content" class="anchor-section" aria-label="Anchor link to header"></a></h1>
Expand Down
8 changes: 4 additions & 4 deletions docs/profiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ <h3><span class="header-section-number">5.2.1</span> Clusters<a href="profiles.h
</div>
<p>The PERMANOVA analyses (Table 5.1) revealed statistically significant differences between clusters, suggesting robust groupings based on the nutrient profiles. The pseudo-F statistics were remarkably high in all cases, indicating strong differentiation between clusters. Specifically, the R² values were 0.87, 0.88, 0.84, and 0.80 for Atauro AG, Atauro GN, Mainland AG, and Mainland GN respectively, indicating that between 80% to 88% of the variance in nutrient concentrations was explained by the clusters. The high R² values underscore the distinctness of the clusters, reinforcing the validity of the K-means clustering.</p>
<p>These findings were consistent across all the datasets, with p-values below 0.001, providing clear evidence to reject the null hypothesis of no difference between clusters. Hence, the PERMANOVA results robustly support the effectiveness of the K-means algorithm in capturing meaningful patterns in nutrient profiles.</p>
<div class="reactable html-widget html-fill-item" id="htmlwidget-cd1d0ededa98ea9daf18" style="width:auto;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-cd1d0ededa98ea9daf18">{"x":{"tag":{"name":"Reactable","attribs":{"data":{"subset":["atauro_AG","atauro_AG","atauro_AG","atauro_GN","atauro_GN","atauro_GN","mainland_AG","mainland_AG","mainland_AG","mainland_GN","mainland_GN","mainland_GN"],"term":["clusters","Residual","Total","clusters","Residual","Total","clusters","Residual","Total","clusters","Residual","Total"],"df":[4,4522,4526,4,8543,8547,4,6688,6692,4,10433,10437],"SumOfSqs":[10296.92,1543.73,11840.64,12071.28,1712.98,13784.26,16953.41,3325.36,20278.77,12220.31,2999.88,15220.2],"R2":[0.87,0.13,1,0.88,0.12,1,0.84,0.16,1,0.8,0.2,1],"statistic":[7540.63,"NA","NA",15050.53,"NA","NA",8524.22,"NA","NA",10624.96,"NA","NA"],"p.value":["< 0.001",null,null,"< 0.001",null,null,"< 0.001",null,null,"< 0.001",null,null]},"columns":[{"id":"subset","name":"subset","type":"character","align":"center","minWidth":120},{"id":"term","name":"term","type":"character","align":"center"},{"id":"df","name":"df","type":"numeric","align":"center"},{"id":"SumOfSqs","name":"SumOfSqs","type":"numeric","align":"center"},{"id":"R2","name":"R2","type":"numeric","align":"center"},{"id":"statistic","name":"statistic","type":"numeric","align":"center"},{"id":"p.value","name":"p.value","type":"character","align":"center"}],"groupBy":["subset"],"pagination":false,"defaultExpanded":true,"theme":{"color":"#222222","backgroundColor":"#ffffff","borderColor":"#dddddd","borderWidth":"1px","stripedColor":"#dddddd","highlightColor":"#f0f0f0","cellPadding":5,"tableStyle":{"fontSize":14,"borderBottom":"3px solid #222222"},"headerStyle":{"borderWidth":"3px","paddingTop":"12px","verticalAlign":"bottom","textAlign":"bottom","background":"#ffffff","textTransform":"uppercase","borderColor":"#222222","color":"#000000","&:hover":{"background":"#dddddd"},"&[aria-sort='ascending'], &[aria-sort='descending']":{"background":"#5b5e5f","color":"#ffffff"},"borderColor.1":"#333","fontSize":12},"groupHeaderStyle":{"&:not(:empty)":{"paddingBottom":"3px","verticalAlign":"bottom","textAlign":"bottom","backgroundColor":"#ffffff","textTransform":"uppercase","fontSize":12,"color":"#222222"}},"rowSelectedStyle":{"backgroundColor":"#dddddd"},"cellStyle":{"display":"flex","flexDirection":"column","justifyContent":"center"},"inputStyle":{"backgroundColor":"#ffffff","color":"#222222"},"searchInputStyle":{"textTransform":"uppercase","color":"#222222","fontSize":"14px"},"paginationStyle":{"textTransform":"uppercase","fontSize":"14px"},"pageButtonStyle":{"textTransform":"uppercase","fontSize":"14px"}},"dataKey":"d3709fe0b2631e78160e9af712467b91"},"children":[]},"class":"reactR_markup"},"evals":[],"jsHooks":[]}</script>
<div class="reactable html-widget html-fill-item" id="htmlwidget-bb7f3bb398f1334b3f2c" style="width:auto;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-bb7f3bb398f1334b3f2c">{"x":{"tag":{"name":"Reactable","attribs":{"data":{"subset":["atauro_AG","atauro_AG","atauro_AG","atauro_GN","atauro_GN","atauro_GN","mainland_AG","mainland_AG","mainland_AG","mainland_GN","mainland_GN","mainland_GN"],"term":["clusters","Residual","Total","clusters","Residual","Total","clusters","Residual","Total","clusters","Residual","Total"],"df":[4,4522,4526,4,8543,8547,4,6688,6692,4,10433,10437],"SumOfSqs":[10296.92,1543.73,11840.64,12071.28,1712.98,13784.26,16953.41,3325.36,20278.77,12220.31,2999.88,15220.2],"R2":[0.87,0.13,1,0.88,0.12,1,0.84,0.16,1,0.8,0.2,1],"statistic":[7540.63,"NA","NA",15050.53,"NA","NA",8524.22,"NA","NA",10624.96,"NA","NA"],"p.value":["< 0.001",null,null,"< 0.001",null,null,"< 0.001",null,null,"< 0.001",null,null]},"columns":[{"id":"subset","name":"subset","type":"character","align":"center","minWidth":120},{"id":"term","name":"term","type":"character","align":"center"},{"id":"df","name":"df","type":"numeric","align":"center"},{"id":"SumOfSqs","name":"SumOfSqs","type":"numeric","align":"center"},{"id":"R2","name":"R2","type":"numeric","align":"center"},{"id":"statistic","name":"statistic","type":"numeric","align":"center"},{"id":"p.value","name":"p.value","type":"character","align":"center"}],"groupBy":["subset"],"pagination":false,"defaultExpanded":true,"theme":{"color":"#222222","backgroundColor":"#ffffff","borderColor":"#dddddd","borderWidth":"1px","stripedColor":"#dddddd","highlightColor":"#f0f0f0","cellPadding":5,"tableStyle":{"fontSize":14,"borderBottom":"3px solid #222222"},"headerStyle":{"borderWidth":"3px","paddingTop":"12px","verticalAlign":"bottom","textAlign":"bottom","background":"#ffffff","textTransform":"uppercase","borderColor":"#222222","color":"#000000","&:hover":{"background":"#dddddd"},"&[aria-sort='ascending'], &[aria-sort='descending']":{"background":"#5b5e5f","color":"#ffffff"},"borderColor.1":"#333","fontSize":12},"groupHeaderStyle":{"&:not(:empty)":{"paddingBottom":"3px","verticalAlign":"bottom","textAlign":"bottom","backgroundColor":"#ffffff","textTransform":"uppercase","fontSize":12,"color":"#222222"}},"rowSelectedStyle":{"backgroundColor":"#dddddd"},"cellStyle":{"display":"flex","flexDirection":"column","justifyContent":"center"},"inputStyle":{"backgroundColor":"#ffffff","color":"#222222"},"searchInputStyle":{"textTransform":"uppercase","color":"#222222","fontSize":"14px"},"paginationStyle":{"textTransform":"uppercase","fontSize":"14px"},"pageButtonStyle":{"textTransform":"uppercase","fontSize":"14px"}},"dataKey":"d3709fe0b2631e78160e9af712467b91"},"children":[]},"class":"reactR_markup"},"evals":[],"jsHooks":[]}</script>
<p>Table 5.1: Results of PERMANOVA analysis assessing the homogeneity of nutrient profiles within fishing trip clusters. The analysis was conducted across four datasets: Atauro with all gears (atauro_AG), Atauro with gill nets (atauro_GN), Mainland with all gears (mainland_AG), and Mainland with gill nets (mainland_GN). For each dataset, the term ‘clusters’ represents the within-group sum of squares (SUMOFSQS), which measures the variance within the nutritional profiles, while ‘Residual’ represents the variance between nutritional profiles Degrees of Freedom (DF), R-squared values (R2), and associated statistics indicate the strength and significance of the clustering. The R2 value quantifies the proportion of variance explained by the clusters.</p>
</div>
<div id="xgboost-model" class="section level3 hasAnchor" number="5.2.2">
Expand All @@ -201,8 +201,8 @@ <h3><span class="header-section-number">5.2.2</span> XGBoost model<a href="profi
Figure 5.3: Receiver Operating Characteristic (ROC) Curves for evaluating the performance of a cluster-based XGBoost classification model across four distinct fishing datasets: Atauro with all gears (a), Atauro with gill nets (b), Mainland with all gears (c), and Mainland with gill nets (d). Each curve represents one of the five clusters obtained from the classification, with different colors marking each cluster. Data points on the curves indicate the trade-off between sensitivity (true positive rate) and 1-specificity (false positive rate) for each cluster. The proximity of the curves to the top-left corner reflects the accuracy of the model in classifying the nutritional profiles into the correct clusters.
</p>
</div>
<div class="reactable html-widget html-fill-item" id="htmlwidget-b64ce874e0ad4a6ce18b" style="width:auto;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-b64ce874e0ad4a6ce18b">{"x":{"tag":{"name":"Reactable","attribs":{"data":{"metric":["roc_auc","accuracy","kap","sens","spec","ppv","npv","mcc","j_index","bal_accuracy","detection_prevalence","precision","recall","f_meas"],"Atauro AG":[0.91,0.68,0.58,0.62,0.92,0.63,0.93,0.6,0.53,0.77,0.2,0.63,0.62,0.58],"Atauro GN":[0.92,0.76,0.66,0.73,0.94,0.73,0.93,0.67,0.66,0.83,0.2,0.73,0.73,0.71],"Mainland AG":[0.7,0.42,0.21,0.36,0.84,0.46,0.86,0.24,0.2,0.6,0.2,0.46,0.36,0.35],"Mainland GN":[0.84,0.67,0.51,0.59,0.9,0.66,0.91,0.52,0.49,0.75,0.2,0.66,0.59,0.59]},"columns":[{"id":"metric","name":"metric","type":"character","align":"center","minWidth":120},{"id":"Atauro AG","name":"Atauro AG","type":"numeric","align":"center"},{"id":"Atauro GN","name":"Atauro GN","type":"numeric","align":"center"},{"id":"Mainland AG","name":"Mainland AG","type":"numeric","align":"center"},{"id":"Mainland GN","name":"Mainland GN","type":"numeric","align":"center"}],"pagination":false,"defaultExpanded":true,"theme":{"color":"#222222","backgroundColor":"#ffffff","borderColor":"#dddddd","borderWidth":"1px","stripedColor":"#dddddd","highlightColor":"#f0f0f0","cellPadding":5,"tableStyle":{"fontSize":14,"borderBottom":"3px solid #222222"},"headerStyle":{"borderWidth":"3px","paddingTop":"12px","verticalAlign":"bottom","textAlign":"bottom","background":"#ffffff","textTransform":"uppercase","borderColor":"#222222","color":"#000000","&:hover":{"background":"#dddddd"},"&[aria-sort='ascending'], &[aria-sort='descending']":{"background":"#5b5e5f","color":"#ffffff"},"borderColor.1":"#333","fontSize":12},"groupHeaderStyle":{"&:not(:empty)":{"paddingBottom":"3px","verticalAlign":"bottom","textAlign":"bottom","backgroundColor":"#ffffff","textTransform":"uppercase","fontSize":12,"color":"#222222"}},"rowSelectedStyle":{"backgroundColor":"#dddddd"},"cellStyle":{"display":"flex","flexDirection":"column","justifyContent":"center"},"inputStyle":{"backgroundColor":"#ffffff","color":"#222222"},"searchInputStyle":{"textTransform":"uppercase","color":"#222222","fontSize":"14px"},"paginationStyle":{"textTransform":"uppercase","fontSize":"14px"},"pageButtonStyle":{"textTransform":"uppercase","fontSize":"14px"}},"dataKey":"aeca06704838ec81a3eb516d1a80f6ad"},"children":[]},"class":"reactR_markup"},"evals":[],"jsHooks":[]}</script>
<div class="reactable html-widget html-fill-item" id="htmlwidget-14cfc8ef927acc7c76b4" style="width:auto;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-14cfc8ef927acc7c76b4">{"x":{"tag":{"name":"Reactable","attribs":{"data":{"metric":["roc_auc","accuracy","kap","sens","spec","ppv","npv","mcc","j_index","bal_accuracy","detection_prevalence","precision","recall","f_meas"],"Atauro AG":[0.91,0.68,0.58,0.62,0.92,0.63,0.93,0.6,0.53,0.77,0.2,0.63,0.62,0.58],"Atauro GN":[0.92,0.76,0.66,0.73,0.94,0.73,0.93,0.67,0.66,0.83,0.2,0.73,0.73,0.71],"Mainland AG":[0.7,0.42,0.21,0.36,0.84,0.46,0.86,0.24,0.2,0.6,0.2,0.46,0.36,0.35],"Mainland GN":[0.84,0.67,0.51,0.59,0.9,0.66,0.91,0.52,0.49,0.75,0.2,0.66,0.59,0.59]},"columns":[{"id":"metric","name":"metric","type":"character","align":"center","minWidth":120},{"id":"Atauro AG","name":"Atauro AG","type":"numeric","align":"center"},{"id":"Atauro GN","name":"Atauro GN","type":"numeric","align":"center"},{"id":"Mainland AG","name":"Mainland AG","type":"numeric","align":"center"},{"id":"Mainland GN","name":"Mainland GN","type":"numeric","align":"center"}],"pagination":false,"defaultExpanded":true,"theme":{"color":"#222222","backgroundColor":"#ffffff","borderColor":"#dddddd","borderWidth":"1px","stripedColor":"#dddddd","highlightColor":"#f0f0f0","cellPadding":5,"tableStyle":{"fontSize":14,"borderBottom":"3px solid #222222"},"headerStyle":{"borderWidth":"3px","paddingTop":"12px","verticalAlign":"bottom","textAlign":"bottom","background":"#ffffff","textTransform":"uppercase","borderColor":"#222222","color":"#000000","&:hover":{"background":"#dddddd"},"&[aria-sort='ascending'], &[aria-sort='descending']":{"background":"#5b5e5f","color":"#ffffff"},"borderColor.1":"#333","fontSize":12},"groupHeaderStyle":{"&:not(:empty)":{"paddingBottom":"3px","verticalAlign":"bottom","textAlign":"bottom","backgroundColor":"#ffffff","textTransform":"uppercase","fontSize":12,"color":"#222222"}},"rowSelectedStyle":{"backgroundColor":"#dddddd"},"cellStyle":{"display":"flex","flexDirection":"column","justifyContent":"center"},"inputStyle":{"backgroundColor":"#ffffff","color":"#222222"},"searchInputStyle":{"textTransform":"uppercase","color":"#222222","fontSize":"14px"},"paginationStyle":{"textTransform":"uppercase","fontSize":"14px"},"pageButtonStyle":{"textTransform":"uppercase","fontSize":"14px"}},"dataKey":"aeca06704838ec81a3eb516d1a80f6ad"},"children":[]},"class":"reactR_markup"},"evals":[],"jsHooks":[]}</script>
<p>Table 5.2: Performance Metrics for XGBoost Model Across Fishing Data Subsets. This table provides a comprehensive overview of the predictive performance of an XGBoost classification model for four distinct subsets of fishing data: Atauro with all gears (ATAURO AG), Atauro with gill nets (ATAURO GN), Mainland with all gears (MAINLAND AG), and Mainland with gill nets (MAINLAND GN). Key performance indicators include ROC-AUC (area under the receiver operating characteristic curve), accuracy, Kappa (kap), sensitivity (sens), specificity (spec), positive predictive value (ppv), negative predictive value (npv), Matthew’s correlation coefficient (mcc), Youden’s J index (j_index), balanced accuracy (bal_accuracy), detection prevalence, precision, recall, and F measure (f_meas). The metrics collectively reflect the model’s ability to discriminate between nutritional profiles, its overall accuracy, and the balance between the sensitivity and specificity for each subset.</p>
<p><br />
The analysis of SHAP values (see <a href="simple.html#simple">ML model explanation</a>) from gill net models (Figure 5.4), which provide insights into how different factors influence predictions in an XGBoost model, shows how mesh size and habitat together predict nutrient profiles in the Atauro region. It’s found that smaller mesh sizes, specifically below 40 mm, are closely linked with a higher likelihood of predicting nutrient profile NP3 across various habitats like reefs and beaches. These smaller sizes also have a lesser association with NP4, particularly when fishing occurs in deeper waters. In contrast, mesh sizes around 50mm are predominantly associated with nutrient profile NP2 in similar environments, with mangroves also playing a role.</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/search_index.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs_book/02-nation_stats.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Timor-Est SSF nutritional scenario

The table uses the [EC dataset][data] and summarizes the main statistics on nutrient supply for each region. Below is a description of each table' column:
The table uses the [EC dataset][data] and summarizes the main statistics on nutrient supply for each region related to **WRA**, the number of woman of reproductive age (15-49 years old). Below is a description of each table' column:

- **MUNICIPALITY (POPULATION)**: Municipality and number of people \> 5 years old in 2022.
- **MUNICIPALITY (POPULATION)**: Municipality and WRA number in 2022.

- **NUTRIENT**: Nutrient of reference

Expand All @@ -18,7 +18,7 @@ The table uses the [EC dataset][data] and summarizes the main statistics on nutr

The 20% of RNIs values was take as reference in consideration of the fact that [an 'adequate diet' is expected to comprise 5 food group](https://www.fao.org/documents/card/en/c/cc4576en). RNIs were then converted from grams to kg (dividing by 1000) and the requirements was calculated as: $\frac{Anuual\ supply\ (kg)}{(RNI\times 0.20) \ / 1000} /365$

- **POPULATION MEETING RNI REQUIREMENTS**: Percentage of the population meeting the RNI requirements in each municipality: $\frac{Number\ of\ people\ supplied\ daily}{Municipality\ population} \times 100$
- **POPULATION MEETING RNI REQUIREMENTS**: Percentage of the WRA population meeting the RNI requirements in each municipality: $\frac{Number\ of\ people\ supplied\ daily}{Municipality\ population} \times 100$

```{r echo=FALSE, message=FALSE, warning=FALSE}
color_pal <- c("#f5fcdf", "#f2fbd2", "#c9ecb4", "#93d3ab", "#35b0ab")
Expand Down

0 comments on commit b628d01

Please sign in to comment.