View source: R/get_cumulative_estimates.R
get_cumulative_estimates | R Documentation |
Calculates estimates of a mean/proportion which are cumulative with respect to a predictor variable, such as week of data collection or number of contact attempts. This can be useful for examining whether estimates are affected by decisions such as whether to extend the data collection period or make additional contact attempts.
get_cumulative_estimates(
survey_design,
y_var,
y_var_type = NULL,
predictor_variable
)
survey_design |
A survey design object created with the |
y_var |
Name of a variable whose mean or proportion is to be estimated. |
y_var_type |
Either |
predictor_variable |
Name of a variable for which cumulative estimates of |
A dataframe of cumulative estimates. The first column–whose name matches predictor_variable
–gives
describes the values of predictor_variable
for which a given estimate was computed.
The other columns of the result include the following:
outcome |
The name of the variable for which estimates are computed |
outcome_category |
For a categorical variable, the category of that variable |
estimate |
The estimated mean or proportion. |
std_error |
The estimated standard error |
respondent_sample_size |
The number of cases used to produce the estimate (excluding missing values) |
See Maitland et al. (2017) for an example of a level-of-effort analysis based on this method.
Maitland, A. et al. (2017). A Nonresponse Bias Analysis of the Health Information National Trends Survey (HINTS). Journal of Health Communication 22, 545-553. doi:10.1080/10810730.2017.1324539
# 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"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.