# Create an example survey design
# with a variable representing number of contact attempts
library(survey)
data(involvement_survey_srs, package = "nrba")
survey_design <- svydesign(
weights = ~BASE_WEIGHT,
id = ~UNIQUE_ID,
fpc = ~N_STUDENTS,
data = involvement_survey_srs
)
# Cumulative estimates from respondents for average student age ----
get_cumulative_estimates(
survey_design = survey_design |>
subset(RESPONSE_STATUS == "Respondent"),
y_var = "STUDENT_AGE",
y_var_type = "numeric",
predictor_variable = "CONTACT_ATTEMPTS"
)
# Cumulative estimates from respondents for proportions of categorical variable ----
get_cumulative_estimates(
survey_design = survey_design |>
subset(RESPONSE_STATUS == "Respondent"),
y_var = "WHETHER_PARENT_AGREES",
y_var_type = "categorical",
predictor_variable = "CONTACT_ATTEMPTS"
)
Run the code above in your browser using DataLab