I have attached the original problem and the responsed I received to date.
Hin
I am trying to apply Fisher's exact test to test the independence of two
methods of intubation (method 1 and method 2). Success is represented as 1,
while failure is 0.
method1<-1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
method2<-0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0
fisher.test(method1,method2)
Error in fisher.test(method1, method2): both categories must have at least
two levels.
Dumped
As far as I understand, Fisher's exact test deals with zero-cell phenomenon.
Ref:
1. Sidney Siegel, NJ Castellan Jr. Nonparametric statistics for the
behavioral sciences (2nd edition) pp.103-109. McGraw Hill 1988.
2. A. Agresti Categorical data analysis. pp.60 Wliey 1990.
My question is whether the algorithm fisher.test() in S-plus is wrong, or
am I missing an important point?
-------------------------------------------------------------------------
BOTH categories must have at least two levels.
your method 1 has only one level.
Coen
-------------------------------------------------------------------------
Try the effect of including a missing value (method1=0,method2=NA):
method1<-scan()
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
method2<- scan()
0 0 0 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 1 0 NA
fisher.test(method1, method2)
Equivalently, but without the warning message,
mm <- table(method1,method2)
fisher.test(mm)
Either way, the fisher.test function correctly returns the p-value of 1
(i.e. the given table is unique for the given row and column marginals).
Maybe what you want is the McNemar test. Does method 1 do better
than method 2 (ignore ties)? In the 15 cases where one method is better
than the other (ignoring the 5 tied cases), the scores are 15 to 0 in favour
of method1. Using a simple sign test, with n=15, the significance level
is 1 in 2^15 (one-tail) or 2 in 2^15 (two-tail).
Bob Henery
Statistics Dept.
Strathclyde Univ.
---------------------------------------------------------------------------
I think the problem arises from how you represented the method1 data to
Splus. Both method1 and method2 should be factors with the same levels.
Try the following:
> method2<-as.factor(c(0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
1, 0))
> method1 <- factor(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ,1
,1),levels=levels(method2))
> fisher.test(method1,method2)
This produces the following result:
Fisher's exact test
data: method1 and method2
p-value = 1
alternative hypothesis: two.sided
William R. (Bill) Gillespie VP Pharmacokinetic R&D
GloboMax LLC phone: 410-782-2204
7250 Parkway Dr., Suite 430 FAX: 410-712-0737
Hanover, MD 21076 Email: gillespw@globomax.com
------------------------------------------------------------------------------
no doubt when you created the factor "method1" you just did
method1 <- factor(method1)
I'd guess that you want the levels attribute to recognize that there are two
levels.
try
method1 <- factor(x,c(0,1))
or if that fails
method1 <- factor(c(x,0))[1:n]
where n is the length of your dataset.
----------------------------------------------------------------------------
--- >Since the categorical test is a contingency table design, you need the >frequency for each of the outcomes by each of the methods. > >Using your data I think the following will provide the desired >output. Try to set up the problem as follows; > > test outcome > number of success number of failures >method 1 20 0 >method 2 5 15 > > > > >> x <- c(20,5, 0, 15) >> x_array(x,c(2,2)) >> x > [,1] [,2] >[1,] 20 0 >[2,] 5 15 > >> fisher.test(x) > > Fisher's exact test > >data: x >p-value = 0 >alternative hypothesis: two.sided > > > >Hope this helps >Steve Friedman
----------------------------------------------------------------------- This message was distributed by s-news@wubios.wustl.edu. To unsubscribe send e-mail to s-news-request@wubios.wustl.edu with the BODY of the message: unsubscribe s-news