R 中的显着性测试,确定单个变量中一列中的比例是否与另一列中显着不同

发布于 2024-12-18 08:40:16 字数 1005 浏览 3 评论 0原文

我确信这是 R 中的一个简单命令,但由于某种原因,我无法找到解决方案。

我正在尝试在 R 中运行一堆交叉表(使用 table() 命令),每个选项卡都有两列(处理和不处理)。我想知道所有行的列之间的差异是否显着不同(这些行是调查中的一些答案选择)。我对整体意义不感兴趣,只对比较治疗与不治疗的交叉表感兴趣。

这种类型的分析在 SPSS 中非常简单(下面的链接说明了我正在谈论的内容),但我似乎无法在 R 中使用它。你知道我可以做到这一点吗?

http://help.vovici.net/robohelp/robohelp/server/general/ projects_fhpro/survey_workbench_MX/Significance_testing.htm

编辑: 这是 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?

http://help.vovici.net/robohelp/robohelp/server/general/projects_fhpro/survey_workbench_MX/Significance_testing.htm

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

阳光①夏 2024-12-25 08:40:16

我认为您正在寻找的函数是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.

零時差 2024-12-25 08:40:16

使用您的示例,chisq.testprop.test (在本例中等效):

> chisq.test(Questiontab)

        Pearson's Chi-squared test

data:  Questiontab 
X-squared = 1.6667, df = 2, p-value = 0.4346

Warning message:
In chisq.test(Questiontab) : Chi-squared approximation may be incorrect
> prop.test(Questiontab)

        3-sample test for equality of proportions without continuity
        correction

data:  Questiontab 
X-squared = 1.6667, df = 2, p-value = 0.4346
alternative hypothesis: two.sided 
sample estimates:
   prop 1    prop 2    prop 3 
0.6666667 0.5000000 0.2500000 

Warning message:
In prop.test(Questiontab) : Chi-squared approximation may be incorrect

注意警告;这些测试不一定适合如此小的数量。

Using your example, either the chisq.test or prop.test (equivalent in this case):

> chisq.test(Questiontab)

        Pearson's Chi-squared test

data:  Questiontab 
X-squared = 1.6667, df = 2, p-value = 0.4346

Warning message:
In chisq.test(Questiontab) : Chi-squared approximation may be incorrect
> prop.test(Questiontab)

        3-sample test for equality of proportions without continuity
        correction

data:  Questiontab 
X-squared = 1.6667, df = 2, p-value = 0.4346
alternative hypothesis: two.sided 
sample estimates:
   prop 1    prop 2    prop 3 
0.6666667 0.5000000 0.2500000 

Warning message:
In prop.test(Questiontab) : Chi-squared approximation may be incorrect

Note the warning; these tests aren't necessarily appropriate for such small numbers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文