Skip to contents

Estimate the required sample size for the within subject standard deviation in a repeatability or reproducibility study.

Usage

sd_within_ss(n, m, precision, conf_level = 0.95)

Arguments

n

An integer for the number of subjects.

m

An integer for the number of observations per subject.

precision

A numeric for the relative precision around the standard deviation.

conf_level

A numeric for the confidence level.

Value

list

Details

Assumptions:

  • the within-subject standard deviation is the same throughout the range

  • to estimate the standard error, the distribution of observations within the subject is Normal

  • there are equal numbers of observations on each subject

References

https://www-users.york.ac.uk/~mb55/meas/sizerep.htm

https://www-users.york.ac.uk/~mb55/meas/seofsw.htm

Bland JM, Altman DG (1996). “Statistics Notes: Measurement error.” BMJ, 313(7059), 744–744. doi:10.1136/bmj.313.7059.744 .

Examples

#----------------------------------------------------------------------------
# sd_within_ss() examples
#----------------------------------------------------------------------------
library(bkstat)

sd_within_ss(m = 11, precision = 0.1)
#> $n
#>   chosen_m chosen_precision required_n
#> 1       11              0.1         20
#> 
sd_within_ss(n = 20, m = 11)
#> $precision
#>   chosen_n chosen_m relative_precision
#> 1       20       11          0.0979982
#> 
sd_within_ss(m = 5, precision = 0.1)
#> $n
#>   chosen_m chosen_precision required_n
#> 1        5              0.1         49
#> 
sd_within_ss(n = 5, m = 11, precision = 0.1)
#> $n
#>   chosen_m chosen_precision required_n
#> 1       11              0.1         20
#> 
#> $m
#>   chosen_n chosen_precision required_m
#> 1        5              0.1         40
#> 
#> $precision
#>   chosen_n chosen_m relative_precision
#> 1        5       11          0.1959964
#> 

res <- expand.grid(
  n = seq(from = 10, to = 50, by = 5),
  m = seq(from = 2, to = 5, by = 1),
  precision = seq(from = 0.1, to = 0.25, by = 0.05)
) |>
  dplyr::rowwise() |>
  dplyr::mutate(
    sd_within_ss(n, m, precision)$n,
    sd_within_ss(n, m, precision)$m,
    sd_within_ss(n, m, precision)$precision,
  ) |>
  dplyr::select(n, m, precision, required_n, required_m, relative_precision)

res
#> # A tibble: 144 × 6
#> # Rowwise: 
#>        n     m precision required_n required_m relative_precision
#>    <dbl> <dbl>     <dbl>      <dbl>      <dbl>              <dbl>
#>  1    10     2       0.1        193         21              0.438
#>  2    15     2       0.1        193         14              0.358
#>  3    20     2       0.1        193         11              0.310
#>  4    25     2       0.1        193          9              0.277
#>  5    30     2       0.1        193          8              0.253
#>  6    35     2       0.1        193          7              0.234
#>  7    40     2       0.1        193          6              0.219
#>  8    45     2       0.1        193          6              0.207
#>  9    50     2       0.1        193          5              0.196
#> 10    10     3       0.1         97         21              0.310
#> # ℹ 134 more rows