1
$\begingroup$

I'd wish to know how is calculated p-value in a fisher.test using as alternative hypothesis a two.sided distribution. It looks to me that R firstly find whether the odd ratio is greater or less than 1, then calculate the p-value for the corrisponding case and then multiply it by 2 to obtain the two.sided case.

This is my contingency table:

mytable <- rbind(c(57248,52891),c(51367,50307))

This is the output from a two.sided test:

> fisher.test(mytable,alternative='two.sided')

Fisher's Exact Test for Count Data

data:  mytable
p-value = 2.086e-11
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 1.042062 1.078306
sample estimates:
odds ratio 
  1.060024 

And here from a greater test:

> fisher.test(mytable,alternative='greater')

    Fisher's Exact Test for Count Data

data:  mytable
p-value = 1.066e-11
alternative hypothesis: true odds ratio is greater than 1
95 percent confidence interval:
 1.044927      Inf
sample estimates:
odds ratio 
  1.060024 
$\endgroup$
1
  • $\begingroup$ Look at the code. Type the function name with no parentheses at the console. (Your supposition is wrong.) $\endgroup$
    – DWin
    Commented May 14, 2015 at 18:38

1 Answer 1

1
$\begingroup$

According to R's help file:

Two-sided tests are based on the probabilities of the tables, and take as ‘more extreme’ all tables with probabilities less than or equal to that of the observed table, the p-value being the sum of such probabilities.

Though the two-sided p-values are usually twice the one-sided p-values, it isn't true for smaller counts.

> mytable <- rbind(c(57,52),c(51,50))
> fisher.test(mytable,alternative='two.sided')

Fisher's Exact Test for Count Data

data:  mytable
p-value = 0.8902
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 0.6032305 1.9145967
sample estimates:
odds ratio 
  1.074292 

> fisher.test(mytable,alternative='greater')

Fisher's Exact Test for Count Data

data:  mytable
p-value = 0.4513
alternative hypothesis: true odds ratio is greater than 1
95 percent confidence interval:
 0.6579587       Inf
sample estimates:
odds ratio 
  1.074292 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.