Skip to content

Commit

Permalink
Merge pull request #39 from nutriverse/dev
Browse files Browse the repository at this point in the history
update usage section of README
  • Loading branch information
ernestguevarra authored Dec 18, 2024
2 parents 21d8591 + 1225fb7 commit 8875ce9
Show file tree
Hide file tree
Showing 2 changed files with 221 additions and 2 deletions.
87 changes: 87 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ knitr::opts_chunk$set(
[![R build status](https://github.com/nutriverse/anthrocheckr/workflows/test-coverage/badge.svg)](https://github.com/nutriverse/anthrocheckr/actions)
[![Codecov test coverage](https://codecov.io/gh/nutriverse/anthrocheckr/branch/main/graph/badge.svg)](https://app.codecov.io/gh/nutriverse/anthrocheckr?branch=main)
[![CodeFactor](https://www.codefactor.io/repository/github/nutriverse/anthrocheckr/badge)](https://www.codefactor.io/repository/github/nutriverse/anthrocheckr)
[![DOI](https://zenodo.org/badge/162917178.svg)](https://zenodo.org/badge/latestdoi/162917178)
<!-- badges: end -->

Ensuring the precision and accuracy of measurements is critical when collecting anthropometric data. Anthropometrists are usually tested for precision and accuracy of measurement through standardisation tests performed prior to anthropometric data collection. This package provides functions to calculate inter- and intra-observer technical error of measurement (TEM) to assess precision of measurements.
Expand Down Expand Up @@ -56,8 +57,94 @@ install.packages(

## Usage

### Calculate intra-observer and/or inter-observer summaries

The *mean*, *standard deviation*, and *maximum difference in measurements* are the requisite summary measures for various anthropometric measurement standardisations tests. These can be calculated as follows:

```{r mean-summary}
## Intra-observer mean for weight ----
weight_df <- subset(smartStdLong, subset = measure_type == "weight")
calculate_mean(weight_df$measure_value, index = weight_df$observer)
```

```{r sd-summary}
## Intra-observer sd for weight ----
calculate_sd(weight_df$measure_value, index = weight_df$observer)
```

```{r max-diff-summary}
## Intra-observer max difference for weight ----
weight_df_wide <- tidyr::pivot_wider(
weight_df,
names_from = c(measure_type, measure_round),
values_from = measure_value, names_sep = "_"
)
calculate_max(
abs(weight_df_wide$weight_1 - weight_df_wide$weight_2),
index = weight_df_wide$observer
)
```

### Calculate intra-observer and inter-observer technical error of measurement (TEM)

```{r calculate-inter-tem, eval = FALSE}
## Inter-observer max difference for weight ----
weight_df_wide <- tidyr::pivot_wider(
weight_df,
names_from = c(measure_type, measure_round),
values_from = measure_value, names_sep = "_"
)
inter_tem <- calculate_tem(
abs(weight_df_wide$weight_1 - weight_df_wide$weight_2),
n = nrow(weight_df_wide)
)
```

which gives

```{r calculate-inter-tem-show, echo = FALSE}
calculate_tem(
abs(weight_df_wide$weight_1 - weight_df_wide$weight_2),
n = nrow(weight_df_wide)
)
```


```{r calculate-intra-tem, eval = FALSE}
## Intra-observer max difference for weight ----
weight_df_wide <- tidyr::pivot_wider(
weight_df,
names_from = c(measure_type, measure_round),
values_from = measure_value, names_sep = "_"
)
intra_tem <- calculate_tem_cohort(
df = weight_df_wide, m1 = "weight_1", m2 = "weight_2",
index = "observer", n = nrow(weight_df_wide)
)
```

which gives

```{r calculate-intra-tem-show, echo = FALSE}
calculate_tem_cohort(
df = weight_df_wide, m1 = "weight_1", m2 = "weight_2",
index = "observer", n = nrow(weight_df_wide)
)
```

### Calculating relative technical error of measurement

```{r calculate-relative-tem}
mean_weight <- calculate_mean(
weight_df$measure_value, index = weight_df$observer
)
calculate_relative_tem(intra_tem$tem, mean_weight$mean)
```

## Citation

Expand Down
136 changes: 134 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ status](https://github.com/nutriverse/anthrocheckr/workflows/test-coverage/badge
[![Codecov test
coverage](https://codecov.io/gh/nutriverse/anthrocheckr/branch/main/graph/badge.svg)](https://app.codecov.io/gh/nutriverse/anthrocheckr?branch=main)
[![CodeFactor](https://www.codefactor.io/repository/github/nutriverse/anthrocheckr/badge)](https://www.codefactor.io/repository/github/nutriverse/anthrocheckr)
[![DOI](https://zenodo.org/badge/162917178.svg)](https://zenodo.org/badge/latestdoi/162917178)
<!-- badges: end -->

Ensuring the precision and accuracy of measurements is critical when
Expand Down Expand Up @@ -62,6 +63,136 @@ install.packages(

## Usage

### Calculate intra-observer and/or inter-observer summaries

The *mean*, *standard deviation*, and *maximum difference in
measurements* are the requisite summary measures for various
anthropometric measurement standardisations tests. These can be
calculated as follows:

``` r
## Intra-observer mean for weight ----
weight_df <- subset(smartStdLong, subset = measure_type == "weight")

calculate_mean(weight_df$measure_value, index = weight_df$observer)
#> index mean
#> 1 0 14.655
#> 2 1 14.410
#> 3 2 14.560
#> 4 3 14.580
#> 5 4 14.545
#> 6 5 14.285
#> 7 6 14.650
#> 8 7 14.665
#> 9 8 14.650
#> 10 9 14.650
#> 11 10 14.615
```

``` r
## Intra-observer sd for weight ----
calculate_sd(weight_df$measure_value, index = weight_df$observer)
#> index sd
#> 1 0 1.793988
#> 2 1 1.742926
#> 3 2 1.753913
#> 4 3 1.757870
#> 5 4 1.743703
#> 6 5 2.024657
#> 7 6 1.764116
#> 8 7 1.691861
#> 9 8 1.810932
#> 10 9 1.735238
#> 11 10 1.699311
```

``` r
## Intra-observer max difference for weight ----
weight_df_wide <- tidyr::pivot_wider(
weight_df,
names_from = c(measure_type, measure_round),
values_from = measure_value, names_sep = "_"
)

calculate_max(
abs(weight_df_wide$weight_1 - weight_df_wide$weight_2),
index = weight_df_wide$observer
)
#> index max_diff
#> 1 0 0.2
#> 2 1 0.8
#> 3 2 0.3
#> 4 3 0.2
#> 5 4 0.5
#> 6 5 6.2
#> 7 6 0.5
#> 8 7 0.4
#> 9 8 0.4
#> 10 9 0.4
#> 11 10 0.9
```

### Calculate intra-observer and inter-observer technical error of measurement (TEM)

``` r
## Inter-observer max difference for weight ----
weight_df_wide <- tidyr::pivot_wider(
weight_df,
names_from = c(measure_type, measure_round),
values_from = measure_value, names_sep = "_"
)

inter_tem <- calculate_tem(
abs(weight_df_wide$weight_1 - weight_df_wide$weight_2),
n = nrow(weight_df_wide)
)
```

which gives

#> [1] 0.4507065

``` r
## Intra-observer max difference for weight ----
weight_df_wide <- tidyr::pivot_wider(
weight_df,
names_from = c(measure_type, measure_round),
values_from = measure_value, names_sep = "_"
)

intra_tem <- calculate_tem_cohort(
df = weight_df_wide, m1 = "weight_1", m2 = "weight_2",
index = "observer", n = nrow(weight_df_wide)
)
```

which gives

#> observer tem
#> 1 0 0.02430862
#> 2 1 0.10180195
#> 3 2 0.03567530
#> 4 3 0.01906925
#> 5 4 0.05090097
#> 6 5 0.41849297
#> 7 6 0.04156047
#> 8 7 0.03089572
#> 9 8 0.03437758
#> 10 9 0.03302891
#> 11 10 0.08867715

### Calculating relative technical error of measurement

``` r
mean_weight <- calculate_mean(
weight_df$measure_value, index = weight_df$observer
)

calculate_relative_tem(intra_tem$tem, mean_weight$mean)
#> [1] 0.1658725 0.7064674 0.2450227 0.1307905 0.3499551 2.9295973
#> [7] 0.2836892 0.2106766 0.2346593 0.2254533 0.6067543
```

## Citation

If you find the `{anthrocheckr}` package useful please cite using the
Expand All @@ -72,8 +203,9 @@ follows:
citation("anthrocheckr")
#> To cite anthrocheckr in publications use:
#>
#> Ernest Guevarra (2024). _anthrocheckr: An Implementation of Anthropometric
#> Measurement Standardisation Tests_. R package version 0.0.0.9000,
#> Ernest Guevarra (2024). _anthrocheckr: An Implementation of
#> Anthropometric Measurement Standardisation Tests_. R
#> package version 0.0.0.9000,
#> <https://nutriverse.io/anthrocheckr/>.
#>
#> A BibTeX entry for LaTeX users is
Expand Down

0 comments on commit 8875ce9

Please sign in to comment.