Skip to content

Commit

Permalink
revise function doc 4
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszaba committed Oct 12, 2024
1 parent 1a1b1e0 commit a1ce73b
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 41 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
^pkgdown$
^doc$
^Meta$
^data-raw$
2 changes: 1 addition & 1 deletion R/age.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ compute_age_in_months <- function (surv_date, birth_date) {
}

#'
#' Process age
#' Wrangle age
#'
#' @description
#' `process_age()` helps you to get the variable age in the format needed for
Expand Down
7 changes: 3 additions & 4 deletions R/case_definitions.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#'
#' Define if an observation is wasted on the basis of the criteria
#' of WFHZ, absolute MUAC values and combined case-definition
#' Wasting case-definition based on WFHZ, MFAZ, MUAC and Combined criteria
#'
#' @param df A data frame containing the required variables.
#'
Expand Down Expand Up @@ -223,8 +222,8 @@ define_wasting <- function(df, zscore = NULL, muac = NULL, edema = NULL,
}

#'
#' Classify wasting into severe or moderate wasting for use in SMART MUAC tool
#' weighting approach
#' Classify wasting into severe or moderate wasting to be used in the
#' SMART MUAC tool weighting approach
#'
#' @param muac A numeric vector holding absolute MUAC values (in mm).
#'
Expand Down
57 changes: 32 additions & 25 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#' A sample data of district level SMART surveys with location anonymised
#'
#' @description
#' `anthro.01` is a two-stage cluster-based survey with probability of the
#' selection of the clusters proportional to the size of the population. The
#' survey employed the SMART methodology. Data was anonymised for confidentiality.
#' `anthro.01` is a two-stage cluster-based survey with probability of selection
#' of clusters proportional to the size of the population. The survey employed
#' the SMART methodology.
#'
#' @format A tibble of 1,191 rows and 11 columns.
#'
Expand All @@ -22,6 +22,8 @@
#' | *edema* | Edema, "n" = no, "y" = yes |
#' | *muac* | Mid-upper arm circumference (mm) |
#'
#' @source Anonymous
#'
#' @examples
#' anthro.01
#'
Expand All @@ -33,20 +35,10 @@
#'
#' @description
#' `anthro.02` is about a household budget survey conducted in Mozambique in
#' 2019/2020, known as IOF (*Inquérito ao Orçamento Familiar* in Portuguese).
#' The data is publicly available [here](https://mozdata.ine.gov.mz/index.php/catalog/88#metadata-data_access).
#' The survey had a module on nutrition with anthropometric measurements taken
#' from children age 0-59 months for weight-for-height and 6-59 months for MUAC.
#'
#' *IOF* is a two-stage cluster-based survey, representative at
#' province level (admin 2), with probability of the selection of the clusters
#' proportional to the size of the population. Its data collection spans for a
#' period of 12 months, with anthropometric measurements
#' taken during that period too. Read the [Bureau of Statistic's website on
#' IOF](https://mozdata.ine.gov.mz/index.php/catalog/88#metadata-sampling) for
#' more details.
#'
#' `anthro.02` has already been wrangled using this package's utilities.
#' 2019/2020, known as IOF (*Inquérito ao Orçamento Familiar* in Portuguese).*IOF*
#' is a two-stage cluster-based survey, representative at province level (admin 2),
#' with probability of the selection of the clusters proportional to the size of
#' the population. Its data collection spans for a period of 12 months.
#'
#' @format A tibble of 2,267 rows and 14 columns.
#'
Expand All @@ -67,6 +59,11 @@
#' | *mfaz* | MUAC-for-age z-scores with 3 decimal places |
#' | *flag_mfaz* | Flagged observations. 1=flagged, 0=not flagged |
#'
#' @source Mozambique National Institute of Statistics. The data is publicly
#' available at <https://mozdata.ine.gov.mz/index.php/catalog/88#metadata-data_access>.
#' Data was wrangled using this package's wranglers. Details about survey design
#' can be gotten from: <https://mozdata.ine.gov.mz/index.php/catalog/88#metadata-sampling>
#'
#' @examples
#' anthro.02
#'
Expand All @@ -79,12 +76,12 @@
#' @description
#' `anthro.03` contains survey data of four districts. Each district's dataset
#' presents distinct data quality scenarios that requires tailored prevalence
#' analysis approach. Two districts show a problematic WFHZ standard deviation
#' analysis approach: two districts show a problematic WFHZ standard deviation
#' whilst the remaining are all within range.
#'
#' This sample data demonstrates the use of prevalence functions on multi-area
#' survey data, where variations in the standard deviation ratings exist.
#' As a result, different analytical approaches are required for each area
#' survey data, where there is variations in the standard deviation rating.
#' As a result, different analyses approaches are required for each area
#' to ensure accurate estimation.
#'
#' @format A tibble of 943 x 9.
Expand All @@ -101,6 +98,8 @@
#' | *edema* | Edema, "n" = no, "y" = yes |
#' | *muac* | Mid-upper arm circumference (mm) |
#'
#' @source Anonymous
#'
#' @examples
#' anthro.03
#'
Expand All @@ -113,12 +112,12 @@
#' A sample data of a community-based sentinel site from an anonymized location
#'
#' @description
#' `anthro.04` was generated from a community-based sentinel site survey
#' conducted across three provinces. Each province's dataset presents distinct
#' data quality scenarios, requiring tailored prevalence analysis.
#' "Province 3" has problematic MFAZ standard deviation and age ratio tests.
#' `anthro.04` was generated from a community-based sentinel site conducted
#' across three provinces. Each province's dataset presents distinct
#' data quality scenarios, requiring tailored prevalence analysis:
#' "Province 3" has problematic MFAZ standard deviation and age ratio tests;
#' "Province 2" shows a problematic age ratio but acceptable MFAZ standard
#' deviation. Lastly, "Province 1" has both tests within acceptable ranges.
#' deviation; lastly, "Province 1" has both tests within acceptable ranges.
#'
#' This sample data demonstrates the use of prevalence functions on multi-area
#' survey data, where variations in the standard deviation ratings exist.
Expand All @@ -138,6 +137,8 @@
#' | *mfaz* | MUAC-for-age z-scores with 3 decimal places |
#' | *flag_mfaz* | Flagged observations. 1=flagged, 0=not flagged |
#'
#' @source Anonymous
#'
#' @examples
#' anthro.04
#'
Expand All @@ -159,6 +160,8 @@
#' | *wfhz* | MUAC-for-age z-scores with 3 decimal places |
#' | *flag_wfhz* | Flagged observations. 1=flagged, 0=not flagged |
#'
#' @source Anonymous
#'
#' @examples
#' wfhz.01
#'
Expand All @@ -178,6 +181,8 @@
#' | *edema* | Edema, "n" = no, "y" = yes |
#' | *muac* | Mid-upper arm circumference (mm) |
#'
#' @source Anonymous
#'
#' @examples
#' mfaz.01
#'
Expand All @@ -197,6 +202,8 @@
#' | *mfaz* | MUAC-for-age z-scores with 3 decimal places |
#' | *flag_mfaz* | Flagged observations. 1=flagged, 0=not flagged |
#'
#' @source Anonymous
#'
#' @examples
#' mfaz.02
#'
Expand Down
15 changes: 7 additions & 8 deletions R/prevalence_combined.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#'
#' Compute combined prevalence of acute malnutrition
#' Compute combined prevalence of wasting
#'
#' @rdname combined_prevalence
#'
Expand Down Expand Up @@ -66,14 +66,13 @@ compute_pps_based_combined_prevalence <- function(df,
#' Compute prevalence of wasting on the basis of the combined case-definition
#'
#' @description
#' `compute_combined_prevalence()` is a handy function for calculating the
#' combined prevalence of wasting also in with the complex sample design
#' properties inherent to surveys.
#' `compute_combined_prevalence()` is a handy function for calculating the prevalence
#' of combined wasting in accordance with the complex sample design properties
#' inherent to surveys.
#'
#' @param df A data frame object returned by [process_muac_data()] and [process_wfhz_data()].
#' Both wranglers need to be used to prepare data to be used
#' `compute_combined_prevalence()`. The order of which comes first does not matter,
#' however, since the muac data processor transforms MUAC values into centimeters, those
#' Both wranglers need to be used sequentially. The order of use does not matter,
#' however, since muac wrangler transforms MUAC values into centimeters, those
#' need to be put back into millimeter. This can be achieved my using [recode_muac()] inside
#' [dplyr::mutate()] or [base::transform()].
#'
Expand All @@ -91,7 +90,7 @@ compute_pps_based_combined_prevalence <- function(df,
#' @returns A table with the descriptive statistics about wasting.
#'
#' @details
#' The concept of "combined flags" is introduced in this function. It consists of
#' A concept of "combined flags" is introduced in this function. It consists of
#' taking the `flag_wfhz` and `flag_mfaz` vectors, generated from the MUAC and
#' WFHZ wranglers, and checking if any value in either vector is flagged. If flagged,
#' the value is marked as a flag in the "cflags" vector; otherwise, it is not flagged
Expand Down
4 changes: 2 additions & 2 deletions R/prevalence_muac.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#' basis of age ratio and standard deviation test results
#'
#' @description
#' This is a helper function that gives instruction to the main prevalence
#' analysis function on the analysis approach to follow in a given area of
#' This is a helper function that gives instruction, to the main MUAC prevalence
#' analysis function, on the analysis approach to follow in a given area of
#' analysis on the basis of the quality of the age ratio test and the standard
#' deviation.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/prevalence_wfhz.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#'
#' Compute the prevalence of wasting on the basis of WFHZ or MFAZ or MUAC
#' Compute the prevalence of wasting on the basis of WFHZ, MFAZ and MUAC
#'
#' @description
#' The prevalence is calculated in accordance with the complex sample design
Expand Down
Binary file added R/sysdata.rda
Binary file not shown.
2 changes: 2 additions & 0 deletions data-raw/DATASET.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Internal data ----
usethis::use_data(wfhz.01, mfaz.01, mfaz.02, internal = TRUE, overwrite = TRUE)

0 comments on commit a1ce73b

Please sign in to comment.