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 computationMon, 22 Oct 2012 13:01:19 -0400
Cite this page as followsStatistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?v=date/2012/Oct/22/t13509253029ummer02vqynsmn.htm/, Retrieved Fri, 03 May 2024 22:40:26 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=181790, Retrieved Fri, 03 May 2024 22:40:26 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact49
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] [] [2012-10-22 17:01:19] [6a75692d68b560ebf35260ff627da44a] [Current]
Feedback Forum

Post a new message
Dataseries X:
12	'A'
11	'C'
14	'B'
12	'C'
21	'A'
12	'D'
22	'D'
11	'B'
10	'B'
13	'A'
10	'D'
8	'B'
15	'B'
14	'A'
10	'A'
14	'C'
14	'C'
11	'A'
10	'A'
13	'C'
7	'C'
14	'D'
12	'A'
14	'A'
11	'C'
9	'C'
11	'B'
15	'A'
14	'C'
13	'C'
9	'D'
15	'C'
10	'D'
11	'A'
13	'D'
8	'C'
20	'D'
12	'C'
10	'D'
10	'C'
9	'C'
14	'C'
8	'C'
14	'C'
11	'D'
13	'B'
9	'A'
11	'B'
15	'A'
11	'C'
10	'A'
14	'D'
18	'C'
14	'A'
11	'C'
12	'C'
13	'B'
9	'B'
10	'B'
15	'B'
20	'D'
12	'B'
12	'B'
14	'B'
13	'D'
11	'A'
17	'B'
12	'D'
13	'A'
14	'A'
13	'B'
15	'A'
13	'A'
10	'A'
11	'D'
19	'D'
13	'A'
17	'D'
13	'D'
9	'D'
11	'B'
10	'A'
9	'A'
12	'C'
12	'B'
13	'D'
13	'A'
12	'B'
15	'C'
22	'C'
13	'B'
15	'C'
13	'A'
15	'D'
10	'D'
11	'B'
16	'B'
11	'D'
11	'B'
10	'B'
10	'B'
16	'B'
12	'A'
11	'D'
16	'A'
19	'C'
11	'B'
16	'A'
15	'B'
24	'A'
14	'B'
15	'C'
11	'A'
15	'C'
12	'B'
10	'C'
14	'A'
13	'A'
9	'B'
15	'B'
15	'A'
14	'D'
11	'A'
8	'A'
11	'D'
11	'C'
8	'C'
10	'A'
11	'B'
13	'C'
11	'C'
20	'C'
10	'A'
15	'D'
12	'A'
14	'D'
23	'D'
14	'B'
16	'B'
11	'B'
12	'B'
10	'B'
14	'B'
12	'B'
12	'D'
11	'D'
12	'D'
13	'B'
11	'D'
19	'C'
12	'A'
17	'A'
9	'A'
12	'A'
19	'B'
18	'D'
15	'C'
14	'A'
11	'B'
9	'C'
18	'B'
16	'B'




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time3 seconds
R Server'George Udny Yule' @ yule.wessa.net

\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 & 3 seconds \tabularnewline
R Server & 'George Udny Yule' @ yule.wessa.net \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=181790&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]3 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'George Udny Yule' @ yule.wessa.net[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=181790&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=181790&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 time3 seconds
R Server'George Udny Yule' @ yule.wessa.net







Tabulation of Results
Depression x Seperated
ABCD
107524
1151067
126744
137534
146554
154462
162400
171101
180111
190121
200012
211000
220011
230001
241000
70010
81130
93232

\begin{tabular}{lllllllll}
\hline
Tabulation of Results \tabularnewline
Depression  x  Seperated \tabularnewline
  & A & B & C & D \tabularnewline
10 & 7 & 5 & 2 & 4 \tabularnewline
11 & 5 & 10 & 6 & 7 \tabularnewline
12 & 6 & 7 & 4 & 4 \tabularnewline
13 & 7 & 5 & 3 & 4 \tabularnewline
14 & 6 & 5 & 5 & 4 \tabularnewline
15 & 4 & 4 & 6 & 2 \tabularnewline
16 & 2 & 4 & 0 & 0 \tabularnewline
17 & 1 & 1 & 0 & 1 \tabularnewline
18 & 0 & 1 & 1 & 1 \tabularnewline
19 & 0 & 1 & 2 & 1 \tabularnewline
20 & 0 & 0 & 1 & 2 \tabularnewline
21 & 1 & 0 & 0 & 0 \tabularnewline
22 & 0 & 0 & 1 & 1 \tabularnewline
23 & 0 & 0 & 0 & 1 \tabularnewline
24 & 1 & 0 & 0 & 0 \tabularnewline
7 & 0 & 0 & 1 & 0 \tabularnewline
8 & 1 & 1 & 3 & 0 \tabularnewline
9 & 3 & 2 & 3 & 2 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=181790&T=1

[TABLE]
[ROW][C]Tabulation of Results[/C][/ROW]
[ROW][C]Depression  x  Seperated[/C][/ROW]
[ROW][C] [/C][C]A[/C][C]B[/C][C]C[/C][C]D[/C][/ROW]
[C]10[/C][C]7[/C][C]5[/C][C]2[/C][C]4[/C][/ROW]
[C]11[/C][C]5[/C][C]10[/C][C]6[/C][C]7[/C][/ROW]
[C]12[/C][C]6[/C][C]7[/C][C]4[/C][C]4[/C][/ROW]
[C]13[/C][C]7[/C][C]5[/C][C]3[/C][C]4[/C][/ROW]
[C]14[/C][C]6[/C][C]5[/C][C]5[/C][C]4[/C][/ROW]
[C]15[/C][C]4[/C][C]4[/C][C]6[/C][C]2[/C][/ROW]
[C]16[/C][C]2[/C][C]4[/C][C]0[/C][C]0[/C][/ROW]
[C]17[/C][C]1[/C][C]1[/C][C]0[/C][C]1[/C][/ROW]
[C]18[/C][C]0[/C][C]1[/C][C]1[/C][C]1[/C][/ROW]
[C]19[/C][C]0[/C][C]1[/C][C]2[/C][C]1[/C][/ROW]
[C]20[/C][C]0[/C][C]0[/C][C]1[/C][C]2[/C][/ROW]
[C]21[/C][C]1[/C][C]0[/C][C]0[/C][C]0[/C][/ROW]
[C]22[/C][C]0[/C][C]0[/C][C]1[/C][C]1[/C][/ROW]
[C]23[/C][C]0[/C][C]0[/C][C]0[/C][C]1[/C][/ROW]
[C]24[/C][C]1[/C][C]0[/C][C]0[/C][C]0[/C][/ROW]
[C]7[/C][C]0[/C][C]0[/C][C]1[/C][C]0[/C][/ROW]
[C]8[/C][C]1[/C][C]1[/C][C]3[/C][C]0[/C][/ROW]
[C]9[/C][C]3[/C][C]2[/C][C]3[/C][C]2[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=181790&T=1

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

As an alternative you can also use a QR Code:  

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

Tabulation of Results
Depression x Seperated
ABCD
107524
1151067
126744
137534
146554
154462
162400
171101
180111
190121
200012
211000
220011
230001
241000
70010
81130
93232







Tabulation of Expected Results
Depression x Seperated
ABCD
104.895.114.223.78
117.67.956.575.88
125.75.964.934.41
135.165.44.463.99
145.435.684.694.2
154.354.543.753.36
161.631.71.411.26
170.810.850.70.63
180.810.850.70.63
191.091.140.940.84
200.810.850.70.63
210.270.280.230.21
220.540.570.470.42
230.270.280.230.21
240.270.280.230.21
70.270.280.230.21
81.361.421.171.05
92.722.842.352.1

\begin{tabular}{lllllllll}
\hline
Tabulation of Expected Results \tabularnewline
Depression  x  Seperated \tabularnewline
  & A & B & C & D \tabularnewline
10 & 4.89 & 5.11 & 4.22 & 3.78 \tabularnewline
11 & 7.6 & 7.95 & 6.57 & 5.88 \tabularnewline
12 & 5.7 & 5.96 & 4.93 & 4.41 \tabularnewline
13 & 5.16 & 5.4 & 4.46 & 3.99 \tabularnewline
14 & 5.43 & 5.68 & 4.69 & 4.2 \tabularnewline
15 & 4.35 & 4.54 & 3.75 & 3.36 \tabularnewline
16 & 1.63 & 1.7 & 1.41 & 1.26 \tabularnewline
17 & 0.81 & 0.85 & 0.7 & 0.63 \tabularnewline
18 & 0.81 & 0.85 & 0.7 & 0.63 \tabularnewline
19 & 1.09 & 1.14 & 0.94 & 0.84 \tabularnewline
20 & 0.81 & 0.85 & 0.7 & 0.63 \tabularnewline
21 & 0.27 & 0.28 & 0.23 & 0.21 \tabularnewline
22 & 0.54 & 0.57 & 0.47 & 0.42 \tabularnewline
23 & 0.27 & 0.28 & 0.23 & 0.21 \tabularnewline
24 & 0.27 & 0.28 & 0.23 & 0.21 \tabularnewline
7 & 0.27 & 0.28 & 0.23 & 0.21 \tabularnewline
8 & 1.36 & 1.42 & 1.17 & 1.05 \tabularnewline
9 & 2.72 & 2.84 & 2.35 & 2.1 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=181790&T=2

[TABLE]
[ROW][C]Tabulation of Expected Results[/C][/ROW]
[ROW][C]Depression  x  Seperated[/C][/ROW]
[ROW][C] [/C][C]A[/C][C]B[/C][C]C[/C][C]D[/C][/ROW]
[C]10[/C][C]4.89[/C][C]5.11[/C][C]4.22[/C][C]3.78[/C][/ROW]
[C]11[/C][C]7.6[/C][C]7.95[/C][C]6.57[/C][C]5.88[/C][/ROW]
[C]12[/C][C]5.7[/C][C]5.96[/C][C]4.93[/C][C]4.41[/C][/ROW]
[C]13[/C][C]5.16[/C][C]5.4[/C][C]4.46[/C][C]3.99[/C][/ROW]
[C]14[/C][C]5.43[/C][C]5.68[/C][C]4.69[/C][C]4.2[/C][/ROW]
[C]15[/C][C]4.35[/C][C]4.54[/C][C]3.75[/C][C]3.36[/C][/ROW]
[C]16[/C][C]1.63[/C][C]1.7[/C][C]1.41[/C][C]1.26[/C][/ROW]
[C]17[/C][C]0.81[/C][C]0.85[/C][C]0.7[/C][C]0.63[/C][/ROW]
[C]18[/C][C]0.81[/C][C]0.85[/C][C]0.7[/C][C]0.63[/C][/ROW]
[C]19[/C][C]1.09[/C][C]1.14[/C][C]0.94[/C][C]0.84[/C][/ROW]
[C]20[/C][C]0.81[/C][C]0.85[/C][C]0.7[/C][C]0.63[/C][/ROW]
[C]21[/C][C]0.27[/C][C]0.28[/C][C]0.23[/C][C]0.21[/C][/ROW]
[C]22[/C][C]0.54[/C][C]0.57[/C][C]0.47[/C][C]0.42[/C][/ROW]
[C]23[/C][C]0.27[/C][C]0.28[/C][C]0.23[/C][C]0.21[/C][/ROW]
[C]24[/C][C]0.27[/C][C]0.28[/C][C]0.23[/C][C]0.21[/C][/ROW]
[C]7[/C][C]0.27[/C][C]0.28[/C][C]0.23[/C][C]0.21[/C][/ROW]
[C]8[/C][C]1.36[/C][C]1.42[/C][C]1.17[/C][C]1.05[/C][/ROW]
[C]9[/C][C]2.72[/C][C]2.84[/C][C]2.35[/C][C]2.1[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=181790&T=2

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

As an alternative you can also use a QR Code:  

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

Tabulation of Expected Results
Depression x Seperated
ABCD
104.895.114.223.78
117.67.956.575.88
125.75.964.934.41
135.165.44.463.99
145.435.684.694.2
154.354.543.753.36
161.631.71.411.26
170.810.850.70.63
180.810.850.70.63
191.091.140.940.84
200.810.850.70.63
210.270.280.230.21
220.540.570.470.42
230.270.280.230.21
240.270.280.230.21
70.270.280.230.21
81.361.421.171.05
92.722.842.352.1







Statistical Results
Pearson's Chi-squared test
Pearson Chi Square Statistic42.12
Degrees of Freedom51
P value0.81

\begin{tabular}{lllllllll}
\hline
Statistical Results \tabularnewline
Pearson's Chi-squared test \tabularnewline
Pearson Chi Square Statistic & 42.12 \tabularnewline
Degrees of Freedom & 51 \tabularnewline
P value & 0.81 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=181790&T=3

[TABLE]
[ROW][C]Statistical Results[/C][/ROW]
[ROW][C]Pearson's Chi-squared test[/C][/ROW]
[ROW][C]Pearson Chi Square Statistic[/C][C]42.12[/C][/ROW]
[ROW][C]Degrees of Freedom[/C][C]51[/C][/ROW]
[ROW][C]P value[/C][C]0.81[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=181790&T=3

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

As an alternative you can also use a QR Code:  

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

Statistical Results
Pearson's Chi-squared test
Pearson Chi Square Statistic42.12
Degrees of Freedom51
P value0.81



Parameters (Session):
par1 = 1 ; par2 = 2 ; par3 = Pearson Chi-Squared ;
Parameters (R input):
par1 = 1 ; par2 = 2 ; par3 = Pearson Chi-Squared ;
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')