# Load example data
data(involvement_survey_srs, package = "nrba")
involvement_survey_srs[["RESPONSE_STATUS"]] <- sample(1:4, size = 5000, replace = TRUE)
# Calculate overall response rates
involvement_survey_srs %>%
calculate_response_rates(
status = "RESPONSE_STATUS",
status_codes = c("ER" = 1, "EN" = 2, "IE" = 3, "UE" = 4),
weights = "BASE_WEIGHT",
rr_formula = "RR3",
elig_method = "CASRO-overall"
)
# Calculate response rates by subgroup
library(dplyr)
involvement_survey_srs %>%
group_by(STUDENT_RACE, STUDENT_SEX) %>%
calculate_response_rates(
status = "RESPONSE_STATUS",
status_codes = c("ER" = 1, "EN" = 2, "IE" = 3, "UE" = 4),
weights = "BASE_WEIGHT",
rr_formula = "RR3",
elig_method = "CASRO-overall"
)
# Compare alternative approaches for handling of cases with unknown eligiblity
involvement_survey_srs %>%
group_by(STUDENT_RACE) %>%
calculate_response_rates(
status = "RESPONSE_STATUS",
status_codes = c("ER" = 1, "EN" = 2, "IE" = 3, "UE" = 4),
rr_formula = "RR3",
elig_method = "CASRO-overall"
)
involvement_survey_srs %>%
group_by(STUDENT_RACE) %>%
calculate_response_rates(
status = "RESPONSE_STATUS",
status_codes = c("ER" = 1, "EN" = 2, "IE" = 3, "UE" = 4),
rr_formula = "RR3",
elig_method = "CASRO-subgroup"
)
involvement_survey_srs %>%
group_by(STUDENT_RACE) %>%
calculate_response_rates(
status = "RESPONSE_STATUS",
status_codes = c("ER" = 1, "EN" = 2, "IE" = 3, "UE" = 4),
rr_formula = "RR3",
elig_method = "specified",
e = 0.5
)
involvement_survey_srs %>%
transform(e_by_email = ifelse(PARENT_HAS_EMAIL == "Has Email", 0.75, 0.25)) %>%
group_by(PARENT_HAS_EMAIL) %>%
calculate_response_rates(
status = "RESPONSE_STATUS",
status_codes = c("ER" = 1, "EN" = 2, "IE" = 3, "UE" = 4),
rr_formula = "RR3",
elig_method = "specified",
e = "e_by_email"
)
Run the code above in your browser using DataLab