Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code in vignette gives short_group warning that appears incorrect #224

Open
francisbarton opened this issue Aug 7, 2024 · 1 comment

Comments

@francisbarton
Copy link
Contributor

As seen in deviations.Rmd.

Each group has 12 points as can be seen in the output from summary() below.

However the warning message still appears, suggesting that "some groups have... < 12 observations".

reprex:

NHSRdatasets::ae_attendances |>
  dplyr::summarise(across("attendances", sum), .by = "period") |>
  NHSRplotthedots::ptd_spc(
    value_field = "attendances",
    date_field = "period",
    rebase = as.Date(c("2017-04-01", "2018-04-01"))
  ) |>
  summary()
#> Warning in ptd_add_short_group_warnings(.): Some groups have 'n < 12'
#> observations. These have trial limits, which will be revised with each
#> additional observation until 'n = fix_after_n_points' has been reached.
#> Plot the Dots SPC options:
#> ===================================
#> value_field:          'attendances'
#> date_field:           'period'
#> facet_field:          not set
#> rebase:               '2017-04-01'
#> rebase:               '2018-04-01'
#> fix_after_n_points:   not set
#> improvement_direction:'increase'
#> target:               not set
#> trajectory:           not set
#> screen_outliers:      'TRUE'
#> -----------------------------------
#> # A tibble: 3 × 9
#>   rebase_group mean_col     lpl    upl     n common_cause special_cause_improv…¹
#>          <dbl>    <dbl>   <dbl>  <dbl> <int>        <int>                  <int>
#> 1            0 1946858.  1.64e6 2.25e6    12           12                      0
#> 2            1 1985843.  1.73e6 2.24e6    12           12                      0
#> 3            2 2068915.  1.81e6 2.33e6    12           12                      0
#> # ℹ abbreviated name: ¹​special_cause_improvement
#> # ℹ 2 more variables: special_cause_concern <int>, variation_type <chr>

Created on 2024-08-08 with reprex v2.1.1

Should the warning say <= 12 or is it being incorrectly triggered?

@francisbarton
Copy link
Contributor Author

francisbarton commented Aug 7, 2024

The code that generates the warning is in ptd_add_short_group_warnings.R:

warning_threshold = getOption("ptd_spc.warning_threshold", 13))

As 12 < 13, the warning is being triggered by groups where n = 12. Either the fallback value here needs to be set to 12, or the warning needs to say that:

Some groups have 'n <= 12' observations

or (more accurately, given the code above):

Some groups have 'n < 13' observations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant