I have some problems concerning the svytest
function of the survey
package. My goal is to perform a simple t-test of the hypothesis: Lower-educated people have greater concerns over the immigration of immigrants. The dependent variable is coded as a binary variable (0|1)
, and the independent as a numerical value (1 = lowest possible education
, 4 = highest possible education
).
Columns: 8
$ ID <dbl> 57385, 157633, 169289, 172583, ~
$ weights <dbl> 0.274958, 0.110605, 0.090035, 0~
$ state <chr> "Bayern", "Bayern", "Rheinland-~
$ region <fct> West, West, West, West, East, W~
$ education <dbl> 3, 4, 4, 3, 4, 3, 4, 4, 2, 1, 3~
$ opinion_refugee <dbl> 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0~
$ number_clusters <dbl> 16, 16, 16, 16, 16, 16, 16, 16,~
$ total_resp_state <int> 192, 192, 45, 29, 36, 189, 45, ~
I created a svydesign-object
as usual and run the following code:
test <- svyttest(opinion_refugee ~ education, refugee_data_obj)
print('Estimate')
test$estimate
print('Confidence Interval')
test$conf.int
print('P Value')
test$p.value
But I receive the following error:
Error in svyttest.default(opinion_refugee ~ education, refugee_data_obj) : group must be binary