Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Significance testing in R, determining if the proportion in one column is significantly different from the other column within the single variable

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!

like image 395
Captain Murphy Avatar asked Nov 28 '11 20:11

Captain Murphy


1 Answers

I think the function you're looking for is pairwise.prop.test(). See ?pairwise.prop.test for an example.

like image 80
John Colby Avatar answered Sep 24 '22 02:09

John Colby