关于svytest包的survey函数,我有一些问题。我的目标是对这一假设进行简单的t检验:受教育程度较低的人更关心移民的移民问题。因变量编码为二进制变量(0|1),独立变量编码为数值(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, ~我像往常一样创建了一个svydesign-object,并运行了以下代码:
test <- svyttest(opinion_refugee ~ education, refugee_data_obj)
print('Estimate')
test$estimate
print('Confidence Interval')
test$conf.int
print('P Value')
test$p.value但我收到以下错误:
Error in svyttest.default(opinion_refugee ~ education, refugee_data_obj) : group must be binary发布于 2021-12-20 15:09:27
是的,这是svyttest()函数的一个问题。我只能使用二进制变量作为分组变量。
作为一种解决方案,我可以两者兼而有之,要么将变量重新编码为二进制变量,要么使用其他类型的回归测试。
在调查包中,可以使用svyglm()函数。例如,对于其他实例,如果依赖项具有多个数值,或者当依赖项为二进制时,则可以将家庭指定为高斯。
https://stackoverflow.com/questions/70360555
复制相似问题