R 中的显着性测试,确定单个变量中一列中的比例是否与另一列中显着不同
我确信这是 R 中的一个简单命令,但由于某种原因,我无法找到解决方案。
我正在尝试在 R 中运行一堆交叉表(使用 table() 命令),每个选项卡都有两列(处理和不处理)。我想知道所有行的列之间的差异是否显着不同(这些行是调查中的一些答案选择)。我对整体意义不感兴趣,只对比较治疗与不治疗的交叉表感兴趣。
这种类型的分析在 SPSS 中非常简单(下面的链接说明了我正在谈论的内容),但我似乎无法在 R 中使用它。你知道我可以做到这一点吗?
编辑: 这是 R 中关于我的意思的示例:
treatmentVar <-c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1) # treatment is 1 or 0
question1 <-c(1,2,2,3,1,1,2,2,3,1,1,2,2,3,1,3) #choices available are 1, 2, or 3
Questiontab <- table(question1, treatmentVar)
Questiontab
我有这样的表 ^ (按treatmentVar 上的列百分比),我想看看从治疗 0 开始的每个问题选择(行)之间是否存在显着差异治疗1。所以在上面的例子中,我想知道4和2(第1行)、3和3(第2行)以及1和3(第3行)之间是否存在显着差异。因此,在此示例中,问题 1 的选择可能与选择 1 和 3 存在显着差异(因为差异为 2),但选择 2 的差异则不然,因为差异为零。最终,我试图确定这种意义。我希望这有帮助。
谢谢!
I'm sure this is an easy command in R, but for some reason, I'm having trouble finding a solution.
I'm trying to run a bunch of crosstabs (using the table() command) in R, and each tab has two columns (treatment and no treatment). I would like to know if the difference between the columns are significantly different for each other for all rows (the rows are a handful of answer choices from a survey). I'm not interested in overall significance, only within the crosstab comparing treatment vs. no treatment.
This type of analysis is very easy in SPSS (link below to illustrate what I'm talking about), but I can't seem to get it working in R. Do you know I can do this?
EDITED:
Here is an example of in R about what I mean:
treatmentVar <-c(0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1) # treatment is 1 or 0
question1 <-c(1,2,2,3,1,1,2,2,3,1,1,2,2,3,1,3) #choices available are 1, 2, or 3
Questiontab <- table(question1, treatmentVar)
Questiontab
I have tables like this ^ (percentaged by column on the treatmentVar), and I would like to see if there is a significant difference between each question choice (rows) going from treatment 0 to treatment 1. So in the example above, I would want to know if there is a significant difference between 4 and 2 (row 1), 3 and 3 (row 2), and 1 and 3 (row 3). So in this example, the choices for question1 might be significantly difference for choices 1 and 3 (because the difference is 2) but the difference for choice 2 isn't because the difference is zero. Ultimately, I'm trying to determine this type of significance. I hope that helps.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在寻找的函数是pairwise.prop.test()。有关示例,请参阅
?pairwise.prop.test
。I think the function you're looking for is
pairwise.prop.test()
. See?pairwise.prop.test
for an example.使用您的示例,
chisq.test
或prop.test
(在本例中等效):注意警告;这些测试不一定适合如此小的数量。
Using your example, either the
chisq.test
orprop.test
(equivalent in this case):Note the warning; these tests aren't necessarily appropriate for such small numbers.