简体   繁体   中英

The use of prop.test in R

I need some clarification about the use of the prop.test command in R.

Please see the below example:

pill <- matrix(c(122,478,99,301), nrow=2, byrow=TRUE)
dimnames(pill) <- list(c("Pill", "Placebo"), c("Positive", "Negative"))

pill
        Positive Negative
Pill         122      478
Placebo       99      301

prop.test(pill, correct=F)

The last line of code in the above example returns a p-value of 0.09914.

However, when we enter the above values directly, we get a completely different p-value:

prop.test(x=c(122/600,99/400), n=c(600,400), correct=F)

The above line of code returns a p-value of 0.8382.

Why does that happen?

Don't divide by the numbers in the group. That would produce a substantially diminished sample size which severely affects the p-value.:

prop.test(x=c(122,99), n=c(600,400), correct=F)

    2-sample test for equality of proportions without continuity
    correction

data:  c(122, 99) out of c(600, 400)
X-squared = 2.7194, df = 1, p-value = 0.09914
alternative hypothesis: two.sided
95 percent confidence interval:
 -0.097324375  0.008991042
sample estimates:
   prop 1    prop 2 
0.2033333 0.2475000 

You should have noticed the strange results for the estimated proportions with your call:

      prop 1       prop 2 
0.0003388889 0.0006187500 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM