chisq_test_ind_response {nrba} | R Documentation |
Test the independence of survey response and auxiliary variables
Description
Tests whether response status among eligible sample cases is independent of categorical auxiliary variables, using a Chi-Square test with Rao-Scott's second-order adjustment. If the data include cases known to be ineligible or who have unknown eligibility status, the data are subsetted to only include respondents and nonrespondents known to be eligible.
Usage
chisq_test_ind_response(
survey_design,
status,
status_codes = c("ER", "EN", "UE", "IE"),
aux_vars
)
Arguments
survey_design |
A survey design object created with the |
status |
A character string giving the name of the variable representing response/eligibility status.
The |
status_codes |
A named vector, with four entries named 'ER', 'EN', 'IE', and 'UE'. |
aux_vars |
A list of names of auxiliary variables. |
Details
Please see svychisq for details of how the Rao-Scott second-order adjusted test is conducted.
Value
A data frame containing the results of the Chi-Square test(s) of independence between response status and each auxiliary variable.
If multiple auxiliary variables are specified, the output data contains one row per auxiliary variable.
The columns of the output dataset include:
-
auxiliary_variable
: The name of the auxiliary variable tested
-
statistic
: The value of the test statistic
-
ndf
: Numerator degrees of freedom for the reference distribution
-
ddf
: Denominator degrees of freedom for the reference distribution
-
p_value
: The p-value of the test of independence
-
test_method
: Text giving the name of the statistical test -
variance_method
: Text describing the method of variance estimation
References
Rao, JNK, Scott, AJ (1984) "On Chi-squared Tests For Multiway Contigency Tables with Proportions Estimated From Survey Data" Annals of Statistics 12:46-60.
Examples
# Create a survey design object ----
library(survey)
data(involvement_survey_srs, package = "nrba")
involvement_survey <- svydesign(
weights = ~BASE_WEIGHT,
id = ~UNIQUE_ID,
data = involvement_survey_srs
)
# Test whether response status varies by race or by sex ----
test_results <- chisq_test_ind_response(
survey_design = involvement_survey,
status = "RESPONSE_STATUS",
status_codes = c(
"ER" = "Respondent",
"EN" = "Nonrespondent",
"UE" = "Unknown",
"IE" = "Ineligible"
),
aux_vars = c("STUDENT_RACE", "STUDENT_SEX")
)
print(test_results)