Generate Adjusted and Unadjusted Service Counts by Year
Source:R/1c_adjust_generate_adjustment_values.R
generate_adjustment_values.Rdgenerate_adjustment_values calculates yearly unadjusted and adjusted service counts
for each indicator within a cd_data dataset, applying the specified adjustment type.
It provides a comparison of raw and adjusted values for analysis purposes.
Usage
generate_adjustment_values(
.data,
adjustment = c("default", "custom", "none"),
k_factors = NULL
)Arguments
- .data
A
cd_datadataframe containing service data for adjustments.- adjustment
A character string specifying the adjustment type:
"default": Applies preset k-factors (e.g., 0.25) for each indicator group."custom": Uses user-specifiedk_factorsvalues for each indicator group."none": Skips adjustments, returning only the raw data.
- k_factors
A named numeric vector of custom k-factor values between 0 and 1 for each indicator group (e.g.,
c(anc = 0.3, idelv = 0.2, ...)). Required ifadjustment = "custom".
Value
A cd_adjustment_values tibble containing:
Columns for unadjusted values, suffixed with
_raw.Columns for adjusted values, suffixed with
_adj.A
yearcolumn indicating the year of each count.
Details
This function performs the following steps:
Data Validation: Ensures
.datais of thecd_dataclass andadjustmentis correctly specified.Unadjusted Summation: Calculates the yearly sums of unadjusted service counts.
Adjusted Summation: Applies
adjust_service_data()to compute adjusted values, then calculates the yearly sums.Combining Results: Merges unadjusted and adjusted yearly counts for comparison.
See also
adjust_service_data() for the detailed adjustment function.
Examples
if (FALSE) { # \dontrun{
# Generate adjustment values with default k-factors
adjustment_values_default <- generate_adjustment_values(data, adjustment = "default")
# Generate adjustment values with custom k-factors
custom_k <- c(anc = 0.3, idelv = 0.2, pnc = 0.35, vacc = 0.4, opd = 0.3, ipd = 0.25)
adjustment_values_custom <-
generate_adjustment_values(data, adjustment = "custom", k_factors = custom_k)
# Generate unadjusted values only
unadjusted_values <- generate_adjustment_values(data, adjustment = "none")
} # }