0

I would like to perform a stratified fisher test.

I've tried with tabulate without success.

These are my data:

> db$site
    [1] 2 2 2 3 1 1 1 1 1 1 1 1 1 1 2 3 1 1 1 1 1 1 1 1 2 2 3 3 1 1 3 1 2 1 1 2 1 1 1 1 1 3 1 1 1 1 1 3 1
 [50] 2 1 1 3 3 3 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 1 3 3 1
 [99] 3 1 1 1 1 1 1 1 3 3 1 1 1 1 1 3 2 1 1 1 1 1 3 3 1 3 3 3 3 1 3 1 3 3 1 3 1 1 3 3 3 2 3 3 3 3 1 3 3
[148] 3 2 3 3 1 3 1 3 3 3 3 3 3 1 3 3 3 1 3 3 1 3 1 1 1 1 1 1 1 3 2 1 3 2 2 2 3 2 3 2 2 2 2 2 2 2 2 3 2
[197] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 3 1 3 2 1 2 3 1 3 3 1 1 1 1 3 3 3 1 3 2 2 1 3 1 2 3 1
[246] 1 1 1 1 1 2 3 2 1 2 3 3 3 1 1 2 3 2 3 3 3 2 2 1 3 2 3 1 1 3 3 2 1 1 1 1 1 2 1 1 2 2 1 2 3 3 1 1 1
[295] 3 2 2 3 1 1 2 2 2 3 3 2 1 3 1 2 1 3 1 1 3 1 1 3 2 2 2 2 2 1 3 1 1 2 3 3 3 1 3 1 3 2 3 1 1 1 3 3 3
[344] 3 1 2 2 2 3 1 3 1 1 3 1 3 2 1 3 2 2 2 2 2 2 2
Levels: 1 2 3

> db$phq_cat
  [1] 1 2 2 3 1 2 2 2 1 1 1 2 1 1 1 2 2 1 2 1 3 2 1 1 1 5 1 2 3 2 3 1 2 4 2 1 1 2 2 1 1 1 1 2 1 2 2 2 2
 [50] 2 1 3 1 2 3 2 2 2 3 2 1 1 3 2 2 2 2 2 3 1 1 2 3 2 2 5 3 1 3 1 2 3 2 2 3 3 1 3 1 1 2 2 1 2 2 1 2 4
 [99] 1 1 2 2 2 2 2 1 3 2 2 1 1 3 2 1 2 2 2 1 3 2 2 3 2 1 1 1 2 2 2 2 1 3 1 3 2 2 1 2 2 2 2 1 1 3 2 2 1
[148] 3 2 4 1 2 1 2 3 1 3 2 2 2 2 2 2 1 2 2 2 2 2 2 1 1 1 1 1 3 3 2 1 1 3 2 2 3 3 2 4 2 2 2 3 2 1 4 1 2
[197] 3 1 2 2 2 2 3 2 3 3 3 3 5 1 3 2 3 1 3 3 3 2 2 1 2 2 1 3 4 4 2 1 2 2 3 4 3 3 2 1 2 4 1 1 2 1 3 2 3
[246] 3 1 1 2 2 3 3 1 1 4 3 2 1 1 2 2 2 2 1 2 2 2 3 1 1 2 4 1 1 2 3 3 2 1 1 1 2 5 1 2 3 2 2 3 1 1 3 3 1
[295] 3 5 2 1 1 1 2 2 1 1 1 4 4 2 1 1 2 1 2 3 1 2 1 2 4 1 1 1 3 1 4 1 1 1 1 4 3 1 2 1 3 3 3 1 2 1 3 1 1
[344] 2 1 1 2 2 2 1 4 2 2 1 4 1 1 4 2 1 4 2 3 2 1 1
Levels: 1 2 3 4 5

>  db$area
  [1] 3    1    1    0    3    2    5    3    1    3    3    3    1    5    4    0    3    5    5   
 [20] 1    3    2    3    1    3    3    0    0    3    3    0    1    3    1    3    3    3    3   
 [39] 3    3    3    0    1    2    2    2    2    0    2    1    1    1    0    0    0    3    3   
 [58] 3    3    4    3    3    3    3    3    1    3    3    0    3    3    5    3    2    3    5   
 [77] 5    3    3    3    3    5    3    2    5    3    3    3    2    0    0    0    0    0    5   
 [96] 0    0    3    0    3    5    3    3    3    1    3    0    0    3    3    2    1    3    0   
[115] 3    2    5    2    5    1    0    0    5    0    0    0    0    1    0    1    0    0    3   
[134] 0    3    3    0    0    0    3    0    0    0    0    3    0    0    0    3    0    0    2   
[153] 0    3    0    0    0    0    0    0    3    0    0    0    3    0    0    3    0    5    3   
[172] 5    3    3    3    3    0    2    3    0    3    2    3    0    3    0    3    2    5    3   
[191] 2    3    5    5    0    3    5    3    2    3    3    3    3    2    2    3    1    3    3   
[210] 3    3    3    5    3    3    3    3    3    0    3    0    3    2    1    0    3    0    0   
[229] 5    3    3    1    0    0    0    3    0    5    1    3    0    3    3    0    1    5    5   
[248] 3    1    3    5    0    2    3    2    0    0    0    3    3    5    0    3    0    0    0   
[267] 3    3    3    0    3    0    3    4    0    0    3    3    3    3    5    5    3    3    1   
[286] 3    1    2    3    0    0    5    3    1    0    5    3    0    3    3    3    2    3    0   
[305] 0    <NA> 3    0    3    5    5    0    5    3    0    3    1    0    5    3    3    3    2   
[324] <NA> 0    3    5    1    0    0    0    5    0    5    0    5    0    3    3    3    0    0   
[343] 0    0    2    3    3    3    0    5    0    3    3    0    3    0    5    1    0    3    3   
[362] 2    3    3    3    3   
Levels: 0 1 2 3 4 5
library(survival)
library(Exact)
library(plyr)

b<-tabulate(db$site, db$phq_cat, db$area,  tests=c("fisher"))

I obtain this error message:

Error in tabulate(db$site, db$phq_cat, db$area, tests = c("fisher")) : unused arguments (db$AREEDISCIPL, tests = c("fisher"))

How cain I handle this?

I also would like to perform stratified wilcoxon rank sum test. Is there a way?

Thank you!

UseR10085
  • 7,120
  • 3
  • 24
  • 54
ArTu
  • 431
  • 4
  • 20
  • 1
    you have not loaded the package with `tabulate` – rawr Feb 04 '21 at 06:25
  • I didn't write it but I did, package ```base``` – ArTu Feb 04 '21 at 13:37
  • then why do you say [here](https://stats.stackexchange.com/questions/507937/stratified-fisher-test-in-r) that it is from the `uwIntroStats` package? also the other comment tells you the problem is that the base function is the wrong one and does not support the arguments you are using in `tabulate` – rawr Feb 04 '21 at 20:52
  • oh, yes this's right! Well, the ```uwIntroStats``` package is no more available... there's an other way to do this? Thak you! – ArTu Feb 05 '21 at 23:36

0 Answers0