Description Usage Arguments Value Examples
Calculates test utilization rate normalization (Y”), using daily site level data. Y (tests/adjusted active instruments) is calculated for each InstrumentVersion, then Y' prime is calculated to adjust all means to FA1.5. The weighted average of these Y' is taken, and three week moving average applied.
1 2 3 4 5 6 7 |
df |
Dataframe with columns of "date", "InstrumentVersion", "daily_TUR_rp" (number of RP tests that day), "daily_TUR_all" (number of all tests that day), "n_active" (active instruments). |
group_vars |
columns to group by. Unquoted names of columns enclosed in vars(). Must at least include InstrumentVersion (which would then result in a national level TURN) |
site_info |
NULL or dataframe (if additonal group_vars are needed). must contain a SiteID column, so that it can be merged with df. Additional columns (e.g. Region) need to be present in the site_info dataframe to be used as group_vars. |
means |
NULL or named vector of means. The vector needs to be length of three giving the means of Y (tests/adjusted active instrument) for the FA1.5, FA2.0 and Torch system (with those names provided as names of elements in the vector). Leave as NULL when calculating National level TURN, because then the means are calculated internally in this function. |
return_means |
logical, whether to return vector of means of Y (tests/adjusted active instrument). If true, output is a list with first element being the output dataframe, the second being named vector of means (which can then be used as an input to this function when calculating regional TURN) |
Dataframe or list. The dataframe contains the following columns: epiweek, epiyear, InstrumentVersion (the instrument version, or 'all' for all instruments combined, or all_adj for which the Y_prime column is the weighted average of all the Y_prime for the other instruments or what we are calling Y”), epi_TUR_rp (number of RP test that week), epi_TUR_all (number of all tests that week) , n_active (number of active instruments), epi_n_days (number of days that week), epidate (calander date of the middle of the epidemiological week), sum_rp_long (number of rp tests within 1 year), sum_all_long (number of all tests within 1 year), prop_rp (proportion RP tests = sum_rp_long/sum_all_long), n_active_adj (number of active instruments*prop_rp), Y (rp tests/adjust active instruments), Y_prime (Y adjusted to mean of FA1.5, or when InstrumentVersion == all_adj, this is the weighted average of Y prime for the other instruments), Y_prime_3wma (3 week moving average applied to Y_prime).
If a list is returned (i.e. return_means = TRUE) the first element is the aformentioned dataframe, the second element is the vector of mean Y for each instrument version.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | l <- calc_TURN(TUR_dat, return_means = TRUE)
# mean of Y for each instrument version
means <- l$means
# data frame containg national turn
national_turn <- l$df
# plot of final TURN curve
# plot(Y_prime_3wma ~ epidate,
# data = national_turn[national_turn$InstrumentVersion == "all_adj", ],
# type = "l")
# calculating TURN by region
state_turn <- calc_TURN(TUR_dat,
group_vars = dplyr::vars(InstrumentVersion, Region),
site_info = get_site_info(rp_raw),
means = means)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.