Free Statistics

of Irreproducible Research!

Author's title

Author*The author of this computation has been verified*
R Software Modulerwasp_chi_squared_tests.wasp
Title produced by softwareChi-Squared Test, McNemar Test, and Fisher Exact Test
Date of computationTue, 14 Dec 2010 19:28:00 +0000
Cite this page as followsStatistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?v=date/2010/Dec/14/t1292354790mpmjh1xtqmevjwi.htm/, Retrieved Thu, 02 May 2024 22:34:06 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=110088, Retrieved Thu, 02 May 2024 22:34:06 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact101
Family? (F = Feedback message, R = changed R code, M = changed R Module, P = changed Parameters, D = changed Data)
-     [Chi-Squared Test, McNemar Test, and Fisher Exact Test] [science paper] [2010-12-14 14:35:09] [9894f466352df31a128e82ec8d720241]
-         [Chi-Squared Test, McNemar Test, and Fisher Exact Test] [science paper] [2010-12-14 19:28:00] [09489ba95453d3f5c9e6f2eaeda915af] [Current]
Feedback Forum

Post a new message
Dataseries X:
Africanelephant     6654.000 5712.000 -999.0 -999.0   3.3  38.6  645.0    3    5    3
Africangiantpouchedrat  1.000  6.600   6.3   2.0   8.3   4.5  42.0    3    1    3
ArcticFox         3.385  44.500 -999.0 -999.0  12.5  14.0  60.0    1    1    1
Arcticgroundsquirrel    .920  5.700 -999.0 -999.0  16.5 -999.0  25.0    5    2    3
Asianelephant      2547.000 4603.000   2.1   1.8   3.9  69.0  624.0    3    5    4
Baboon           10.550 179.500   9.1   .7   9.8  27.0  180.0    4    4    4
Bigbrownbat        .023   .300  15.8   3.9  19.7  19.0  35.0    1    1    1
Braziliantapir      160.000 169.000   5.2   1.0   6.2  30.4  392.0    4    5    4
Cat             3.300  25.600  10.9   3.6  14.5  28.0  63.0    1    2    1
Chimpanzee         52.160 440.000   8.3   1.4   9.7  50.0  230.0    1    1    1
Chinchilla          .425  6.400  11.0   1.5  12.5   7.0  112.0    5    4    4
Cow            465.000 423.000   3.2   .7   3.9  30.0  281.0    5    5    5
Deserthedgehog       .550  2.400   7.6   2.7  10.3 -999.0 -999.0    2    1    2
Donkey          187.100 419.000 -999.0 -999.0   3.1  40.0  365.0    5    5    5
EasternAmericanmole    .075  1.200   6.3   2.1   8.4   3.5  42.0    1    1    1
Echidna           3.000  25.000   8.6   .0   8.6  50.0  28.0    2    2    2
Europeanhedgehog      .785  3.500   6.6   4.1  10.7   6.0  42.0    2    2    2
Galago            .200  5.000   9.5   1.2  10.7  10.4  120.0    2    2    2
Genet            1.410  17.500   4.8   1.3   6.1  34.0 -999.0    1    2    1
Giantarmadillo      60.000  81.000  12.0   6.1  18.1   7.0 -999.0    1    1    1
Giraffe          529.000 680.000 -999.0   .3 -999.0  28.0  400.0    5    5    5
Goat            27.660 115.000   3.3   .5   3.8  20.0  148.0    5    5    5
Goldenhamster        .120  1.000  11.0   3.4  14.4   3.9  16.0    3    1    2
Gorilla          207.000 406.000 -999.0 -999.0  12.0  39.3  252.0    1    4    1
Grayseal         85.000 325.000   4.7   1.5   6.2  41.0  310.0    1    3    1
Graywolf         36.330 119.500 -999.0 -999.0  13.0  16.2  63.0    1    1    1
Groundsquirrel       .101  4.000  10.4   3.4  13.8   9.0  28.0    5    1    3
Guineapig         1.040  5.500   7.4   .8   8.2   7.6  68.0    5    3    4
Horse           521.000 655.000   2.1   .8   2.9  46.0  336.0    5    5    5
Jaguar          100.000 157.000 -999.0 -999.0  10.8  22.4  100.0    1    1    1
Kangaroo          35.000  56.000 -999.0 -999.0 -999.0  16.3  33.0    3    5    4
Lessershorttailedshrew  .005   .140   7.7   1.4   9.1   2.6  21.5    5    2    4
Littlebrownbat       .010   .250  17.9   2.0  19.9  24.0  50.0    1    1    1
Man            62.000 1320.000   6.1   1.9   8.0  100.0  267.0    1    1    1
Molerat           .122  3.000   8.2   2.4  10.6 -999.0  30.0    2    1    1
Mountainbeaver       1.350  8.100   8.4   2.8  11.2 -999.0  45.0    3    1    3
Mouse            .023   .400  11.9   1.3  13.2   3.2  19.0    4    1    3
Muskshrew          .048   .330  10.8   2.0  12.8   2.0  30.0    4    1    3
N.Aericanopossum     1.700  6.300  13.8   5.6  19.4   5.0  12.0    2    1    1
Ninebandedarmadillo    3.500  10.800  14.3   3.1  17.4   6.5  120.0    2    1    1
Okapi           250.000 490.000 -999.0   1.0 -999.0  23.6  440.0    5    5    5
Owlmonkey          .480  15.500  15.2   1.8  17.0  12.0  140.0    2    2    2
Patasmonkey        10.000 115.000  10.0   .9  10.9  20.2  170.0    4    4    4
Phanlanger         1.620  11.400  11.9   1.8  13.7  13.0  17.0    2    1    2
Pig            192.000 180.000   6.5   1.9   8.4  27.0  115.0    4    4    4
Rabbit           2.500  12.100   7.5   .9   8.4  18.0  31.0    5    5    5
Raccoon           4.288  39.200 -999.0 -999.0  12.5  13.7  63.0    2    2    2
Rat             .280  1.900  10.6   2.6  13.2   4.7  21.0    3    1    3
Redfox           4.235  50.400   7.4   2.4   9.8   9.8  52.0    1    1    1
Rhesusmonkey        6.800 179.000   8.4   1.2   9.6  29.0  164.0    2    3    2
Rockhyrax(Heterob)    .750  12.300   5.7   .9   6.6   7.0  225.0    2    2    2
Rockhyrax(Procavihab)  3.600  21.000   4.9   .5   5.4   6.0  225.0    3    2    3
Roedeer          14.830  98.200 -999.0 -999.0   2.6  17.0  150.0    5    5    5
Sheep           55.500 175.000   3.2   .6   3.8  20.0  151.0    5    5    5
Slowloris         1.400  12.500 -999.0 -999.0  11.0  12.7  90.0    2    2    2
Starnosedmole       .060  1.000   8.1   2.2  10.3   3.5 -999.0    3    1    2
Tenrec            .900  2.600  11.0   2.3  13.3   4.5  60.0    2    1    2
Treehyrax         2.000  12.300   4.9   .5   5.4   7.5  200.0    3    1    3
Treeshrew          .104  2.500  13.2   2.6  15.8   2.3  46.0    3    2    2
Vervet           4.190  58.000   9.7   .6  10.3  24.0  210.0    4    3    4
Wateropossum        3.500  3.900  12.8   6.6  19.4   3.0  14.0    2    1    1
Yellowbelliedmarmot    4.050  17.000 -999.0 -999.0 -999.0  13.0  38.0    3    1    1




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time1 seconds
R Server'RServer@AstonUniversity' @ vre.aston.ac.uk
R Engine error message
Error in as.vector(data) : object 'Africanelephant' not found
Calls: array -> as.vector
Execution halted

\begin{tabular}{lllllllll}
\hline
Summary of computational transaction \tabularnewline
Raw Input & view raw input (R code)  \tabularnewline
Raw Output & view raw output of R engine  \tabularnewline
Computing time & 1 seconds \tabularnewline
R Server & 'RServer@AstonUniversity' @ vre.aston.ac.uk \tabularnewline
R Engine error message & 
Error in as.vector(data) : object 'Africanelephant' not found
Calls: array -> as.vector
Execution halted
\tabularnewline \hline \end{tabular} %Source: https://freestatistics.org/blog/index.php?pk=110088&T=0

[TABLE]
[ROW][C]Summary of computational transaction[/C][/ROW]
[ROW][C]Raw Input[/C][C]view raw input (R code) [/C][/ROW]
[ROW][C]Raw Output[/C][C]view raw output of R engine [/C][/ROW]
[ROW][C]Computing time[/C][C]1 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'RServer@AstonUniversity' @ vre.aston.ac.uk[/C][/ROW]
[ROW][C]R Engine error message[/C][C]
Error in as.vector(data) : object 'Africanelephant' not found
Calls: array -> as.vector
Execution halted
[/C][/ROW] [/TABLE] Source: https://freestatistics.org/blog/index.php?pk=110088&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=110088&T=0

As an alternative you can also use a QR Code:  

The GUIDs for individual cells are displayed in the table below:

Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time1 seconds
R Server'RServer@AstonUniversity' @ vre.aston.ac.uk
R Engine error message
Error in as.vector(data) : object 'Africanelephant' not found
Calls: array -> as.vector
Execution halted



Parameters (Session):
par1 = 4 ; par2 = 5 ; par3 = Pearson Chi-Squared ;
Parameters (R input):
par1 = 4 ; par2 = 5 ; par3 = Pearson Chi-Squared ; par4 = ; par5 = ; par6 = ; par7 = ; par8 = ; par9 = ; par10 = ; par11 = ; par12 = ; par13 = ; par14 = ; par15 = ; par16 = ; par17 = ; par18 = ; par19 = ; par20 = ;
R code (references can be found in the software module):
library(vcd)
cat1 <- as.numeric(par1) #
cat2<- as.numeric(par2) #
simulate.p.value=FALSE
if (par3 == 'Exact Pearson Chi-Squared by Simulation') simulate.p.value=TRUE
x <- t(x)
(z <- array(unlist(x),dim=c(length(x[,1]),length(x[1,]))))
(table1 <- table(z[,cat1],z[,cat2]))
(V1<-dimnames(y)[[1]][cat1])
(V2<-dimnames(y)[[1]][cat2])
bitmap(file='pic1.png')
assoc(ftable(z[,cat1],z[,cat2],row.vars=1,dnn=c(V1,V2)),shade=T)
dev.off()
load(file='createtable')
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Tabulation of Results',ncol(table1)+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,paste(V1,' x ', V2),ncol(table1)+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, ' ', 1,TRUE)
for(nc in 1:ncol(table1)){
a<-table.element(a, colnames(table1)[nc], 1, TRUE)
}
a<-table.row.end(a)
for(nr in 1:nrow(table1) ){
a<-table.element(a, rownames(table1)[nr], 1, TRUE)
for(nc in 1:ncol(table1) ){
a<-table.element(a, table1[nr, nc], 1, FALSE)
}
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable.tab')
(cst<-chisq.test(table1, simulate.p.value=simulate.p.value) )
if (par3 == 'McNemar Chi-Squared') {
(cst <- mcnemar.test(table1))
}
if (par3=='Fisher Exact Test') {
(cst <- fisher.test(table1))
}
if ((par3 != 'McNemar Chi-Squared') & (par3 != 'Fisher Exact Test')) {
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Tabulation of Expected Results',ncol(table1)+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a,paste(V1,' x ', V2),ncol(table1)+1,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, ' ', 1,TRUE)
for(nc in 1:ncol(table1)){
a<-table.element(a, colnames(table1)[nc], 1, TRUE)
}
a<-table.row.end(a)
for(nr in 1:nrow(table1) ){
a<-table.element(a, rownames(table1)[nr], 1, TRUE)
for(nc in 1:ncol(table1) ){
a<-table.element(a, round(cst$expected[nr, nc], digits=2), 1, FALSE)
}
a<-table.row.end(a)
}
a<-table.end(a)
table.save(a,file='mytable1.tab')
}
a<-table.start()
a<-table.row.start(a)
a<-table.element(a,'Statistical Results',2,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
a<-table.element(a, cst$method, 2,TRUE)
a<-table.row.end(a)
a<-table.row.start(a)
if (par3=='Pearson Chi-Squared') a<-table.element(a, 'Pearson Chi Square Statistic', 1, TRUE)
if (par3=='Exact Pearson Chi-Squared by Simulation') a<-table.element(a, 'Exact Pearson Chi Square Statistic', 1, TRUE)
if (par3=='McNemar Chi-Squared') a<-table.element(a, 'McNemar Chi Square Statistic', 1, TRUE)
if (par3=='Fisher Exact Test') a<-table.element(a, 'Odds Ratio', 1, TRUE)
if (par3=='Fisher Exact Test') {
if ((ncol(table1) == 2) & (nrow(table1) == 2)) {
a<-table.element(a, round(cst$estimate, digits=2), 1,FALSE)
} else {
a<-table.element(a, '--', 1,FALSE)
}
} else {
a<-table.element(a, round(cst$statistic, digits=2), 1,FALSE)
}
a<-table.row.end(a)
if(!simulate.p.value){
if(par3!='Fisher Exact Test') {
a<-table.row.start(a)
a<-table.element(a, 'Degrees of Freedom', 1, TRUE)
a<-table.element(a, cst$parameter, 1,FALSE)
a<-table.row.end(a)
}
}
a<-table.row.start(a)
a<-table.element(a, 'P value', 1, TRUE)
a<-table.element(a, round(cst$p.value, digits=2), 1,FALSE)
a<-table.row.end(a)
a<-table.end(a)
table.save(a,file='mytable2.tab')