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 computationSat, 10 Nov 2012 04:52:24 -0500
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/Nov/10/t1352541252nofbdb31mkxg6ez.htm/, Retrieved Sat, 10 Dec 2022 05:36:18 +0000
Statistical Computations at FreeStatistics.org, Office for Research Development and Education, URL https://freestatistics.org/blog/index.php?pk=187268, Retrieved Sat, 10 Dec 2022 05:36:18 +0000
QR Codes:

Original text written by user:
IsPrivate?No (this computation is public)
User-defined keywords
Estimated Impact91
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] [Workshop 6 Softwa...] [2012-11-10 09:52:24] [66a849a05d67389f0588cabd76580e84] [Current]
Feedback Forum

Post a new message
Dataseries X:
41	38	13	12	14	12
39	32	16	11	18	11
30	35	19	15	11	14
31	33	15	6	12	12
34	37	14	13	16	21
35	29	13	10	18	12
39	31	19	12	14	22
34	36	15	14	14	11
36	35	14	12	15	10
37	38	15	6	15	13
38	31	16	10	17	10
36	34	16	12	19	8
38	35	16	12	10	15
39	38	16	11	16	14
33	37	17	15	18	10
32	33	15	12	14	14
36	32	15	10	14	14
38	38	20	12	17	11
39	38	18	11	14	10
32	32	16	12	16	13
32	33	16	11	18	7
31	31	16	12	11	14
39	38	19	13	14	12
37	39	16	11	12	14
39	32	17	9	17	11
41	32	17	13	9	9
36	35	16	10	16	11
33	37	15	14	14	15
33	33	16	12	15	14
34	33	14	10	11	13
31	28	15	12	16	9
27	32	12	8	13	15
37	31	14	10	17	10
34	37	16	12	15	11
34	30	14	12	14	13
32	33	7	7	16	8
29	31	10	6	9	20
36	33	14	12	15	12
29	31	16	10	17	10
35	33	16	10	13	10
37	32	16	10	15	9
34	33	14	12	16	14
38	32	20	15	16	8
35	33	14	10	12	14
38	28	14	10	12	11
37	35	11	12	11	13
38	39	14	13	15	9
33	34	15	11	15	11
36	38	16	11	17	15
38	32	14	12	13	11
32	38	16	14	16	10
32	30	14	10	14	14
32	33	12	12	11	18
34	38	16	13	12	14
32	32	9	5	12	11
37	32	14	6	15	12
39	34	16	12	16	13
29	34	16	12	15	9
37	36	15	11	12	10
35	34	16	10	12	15
30	28	12	7	8	20
38	34	16	12	13	12
34	35	16	14	11	12
31	35	14	11	14	14
34	31	16	12	15	13
35	37	17	13	10	11
36	35	18	14	11	17
30	27	18	11	12	12
39	40	12	12	15	13
35	37	16	12	15	14
38	36	10	8	14	13
31	38	14	11	16	15
34	39	18	14	15	13
38	41	18	14	15	10
34	27	16	12	13	11
39	30	17	9	12	19
37	37	16	13	17	13
34	31	16	11	13	17
28	31	13	12	15	13
37	27	16	12	13	9
33	36	16	12	15	11
37	38	20	12	16	10
35	37	16	12	15	9
37	33	15	12	16	12
32	34	15	11	15	12
33	31	16	10	14	13
38	39	14	9	15	13
33	34	16	12	14	12
29	32	16	12	13	15
33	33	15	12	7	22
31	36	12	9	17	13
36	32	17	15	13	15
35	41	16	12	15	13
32	28	15	12	14	15
29	30	13	12	13	10
39	36	16	10	16	11
37	35	16	13	12	16
35	31	16	9	14	11
37	34	16	12	17	11
32	36	14	10	15	10
38	36	16	14	17	10
37	35	16	11	12	16
36	37	20	15	16	12
32	28	15	11	11	11
33	39	16	11	15	16
40	32	13	12	9	19
38	35	17	12	16	11
41	39	16	12	15	16
36	35	16	11	10	15
43	42	12	7	10	24
30	34	16	12	15	14
31	33	16	14	11	15
32	41	17	11	13	11
32	33	13	11	14	15
37	34	12	10	18	12
37	32	18	13	16	10
33	40	14	13	14	14
34	40	14	8	14	13
33	35	13	11	14	9
38	36	16	12	14	15
33	37	13	11	12	15
31	27	16	13	14	14
38	39	13	12	15	11
37	38	16	14	15	8
33	31	15	13	15	11
31	33	16	15	13	11
39	32	15	10	17	8
44	39	17	11	17	10
33	36	15	9	19	11
35	33	12	11	15	13
32	33	16	10	13	11
28	32	10	11	9	20
40	37	16	8	15	10
27	30	12	11	15	15
37	38	14	12	15	12
32	29	15	12	16	14
28	22	13	9	11	23
34	35	15	11	14	14
30	35	11	10	11	16
35	34	12	8	15	11
31	35	8	9	13	12
32	34	16	8	15	10
30	34	15	9	16	14
30	35	17	15	14	12
31	23	16	11	15	12
40	31	10	8	16	11
32	27	18	13	16	12
36	36	13	12	11	13
32	31	16	12	12	11
35	32	13	9	9	19
38	39	10	7	16	12
42	37	15	13	13	17
34	38	16	9	16	9
35	39	16	6	12	12
35	34	14	8	9	19
33	31	10	8	13	18
36	32	17	15	13	15
32	37	13	6	14	14
33	36	15	9	19	11
34	32	16	11	13	9
32	35	12	8	12	18




Summary of computational transaction
Raw Inputview raw input (R code)
Raw Outputview raw output of R engine
Computing time4 seconds
R Server'Gwilym Jenkins' @ jenkins.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 & 4 seconds \tabularnewline
R Server & 'Gwilym Jenkins' @ jenkins.wessa.net \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=187268&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]4 seconds[/C][/ROW]
[ROW][C]R Server[/C][C]'Gwilym Jenkins' @ jenkins.wessa.net[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=187268&T=0

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=187268&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 time4 seconds
R Server'Gwilym Jenkins' @ jenkins.wessa.net







Tabulation of Results
Software x Happiness
78910111213141516171819
50000010000000
60010020120000
70101000002000
80010012231000
90010111112202
100000232322420
110011153562220
1210114167168201
130011021323100
140000300231100
150000103102010

\begin{tabular}{lllllllll}
\hline
Tabulation of Results \tabularnewline
Software  x  Happiness \tabularnewline
  & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 \tabularnewline
5 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \tabularnewline
6 & 0 & 0 & 1 & 0 & 0 & 2 & 0 & 1 & 2 & 0 & 0 & 0 & 0 \tabularnewline
7 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 2 & 0 & 0 & 0 \tabularnewline
8 & 0 & 0 & 1 & 0 & 0 & 1 & 2 & 2 & 3 & 1 & 0 & 0 & 0 \tabularnewline
9 & 0 & 0 & 1 & 0 & 1 & 1 & 1 & 1 & 1 & 2 & 2 & 0 & 2 \tabularnewline
10 & 0 & 0 & 0 & 0 & 2 & 3 & 2 & 3 & 2 & 2 & 4 & 2 & 0 \tabularnewline
11 & 0 & 0 & 1 & 1 & 1 & 5 & 3 & 5 & 6 & 2 & 2 & 2 & 0 \tabularnewline
12 & 1 & 0 & 1 & 1 & 4 & 1 & 6 & 7 & 16 & 8 & 2 & 0 & 1 \tabularnewline
13 & 0 & 0 & 1 & 1 & 0 & 2 & 1 & 3 & 2 & 3 & 1 & 0 & 0 \tabularnewline
14 & 0 & 0 & 0 & 0 & 3 & 0 & 0 & 2 & 3 & 1 & 1 & 0 & 0 \tabularnewline
15 & 0 & 0 & 0 & 0 & 1 & 0 & 3 & 1 & 0 & 2 & 0 & 1 & 0 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=187268&T=1

[TABLE]
[ROW][C]Tabulation of Results[/C][/ROW]
[ROW][C]Software  x  Happiness[/C][/ROW]
[ROW][C] [/C][C]7[/C][C]8[/C][C]9[/C][C]10[/C][C]11[/C][C]12[/C][C]13[/C][C]14[/C][C]15[/C][C]16[/C][C]17[/C][C]18[/C][C]19[/C][/ROW]
[C]5[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]1[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][/ROW]
[C]6[/C][C]0[/C][C]0[/C][C]1[/C][C]0[/C][C]0[/C][C]2[/C][C]0[/C][C]1[/C][C]2[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][/ROW]
[C]7[/C][C]0[/C][C]1[/C][C]0[/C][C]1[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]2[/C][C]0[/C][C]0[/C][C]0[/C][/ROW]
[C]8[/C][C]0[/C][C]0[/C][C]1[/C][C]0[/C][C]0[/C][C]1[/C][C]2[/C][C]2[/C][C]3[/C][C]1[/C][C]0[/C][C]0[/C][C]0[/C][/ROW]
[C]9[/C][C]0[/C][C]0[/C][C]1[/C][C]0[/C][C]1[/C][C]1[/C][C]1[/C][C]1[/C][C]1[/C][C]2[/C][C]2[/C][C]0[/C][C]2[/C][/ROW]
[C]10[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]2[/C][C]3[/C][C]2[/C][C]3[/C][C]2[/C][C]2[/C][C]4[/C][C]2[/C][C]0[/C][/ROW]
[C]11[/C][C]0[/C][C]0[/C][C]1[/C][C]1[/C][C]1[/C][C]5[/C][C]3[/C][C]5[/C][C]6[/C][C]2[/C][C]2[/C][C]2[/C][C]0[/C][/ROW]
[C]12[/C][C]1[/C][C]0[/C][C]1[/C][C]1[/C][C]4[/C][C]1[/C][C]6[/C][C]7[/C][C]16[/C][C]8[/C][C]2[/C][C]0[/C][C]1[/C][/ROW]
[C]13[/C][C]0[/C][C]0[/C][C]1[/C][C]1[/C][C]0[/C][C]2[/C][C]1[/C][C]3[/C][C]2[/C][C]3[/C][C]1[/C][C]0[/C][C]0[/C][/ROW]
[C]14[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]3[/C][C]0[/C][C]0[/C][C]2[/C][C]3[/C][C]1[/C][C]1[/C][C]0[/C][C]0[/C][/ROW]
[C]15[/C][C]0[/C][C]0[/C][C]0[/C][C]0[/C][C]1[/C][C]0[/C][C]3[/C][C]1[/C][C]0[/C][C]2[/C][C]0[/C][C]1[/C][C]0[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=187268&T=1

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=187268&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
Software x Happiness
78910111213141516171819
50000010000000
60010020120000
70101000002000
80010012231000
90010111112202
100000232322420
110011153562220
1210114167168201
130011021323100
140000300231100
150000103102010







Tabulation of Expected Results
Software x Happiness
78910111213141516171819
50.010.010.040.020.070.10.110.160.220.140.070.030.02
60.040.040.220.150.450.60.670.931.30.860.450.190.11
70.020.020.150.10.30.40.450.620.870.570.30.120.07
80.060.060.370.250.750.991.121.552.171.430.750.310.19
90.070.070.450.30.891.191.341.862.611.710.890.370.22
100.120.120.750.51.491.992.243.114.352.861.490.620.37
110.170.171.040.72.092.783.134.356.0942.090.870.52
120.30.31.791.193.584.775.377.4510.436.863.581.490.89
130.090.090.520.351.041.391.572.173.0421.040.430.26
140.060.060.370.250.750.991.121.552.171.430.750.310.19
150.050.050.30.20.60.80.891.241.741.140.60.250.15

\begin{tabular}{lllllllll}
\hline
Tabulation of Expected Results \tabularnewline
Software  x  Happiness \tabularnewline
  & 7 & 8 & 9 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 \tabularnewline
5 & 0.01 & 0.01 & 0.04 & 0.02 & 0.07 & 0.1 & 0.11 & 0.16 & 0.22 & 0.14 & 0.07 & 0.03 & 0.02 \tabularnewline
6 & 0.04 & 0.04 & 0.22 & 0.15 & 0.45 & 0.6 & 0.67 & 0.93 & 1.3 & 0.86 & 0.45 & 0.19 & 0.11 \tabularnewline
7 & 0.02 & 0.02 & 0.15 & 0.1 & 0.3 & 0.4 & 0.45 & 0.62 & 0.87 & 0.57 & 0.3 & 0.12 & 0.07 \tabularnewline
8 & 0.06 & 0.06 & 0.37 & 0.25 & 0.75 & 0.99 & 1.12 & 1.55 & 2.17 & 1.43 & 0.75 & 0.31 & 0.19 \tabularnewline
9 & 0.07 & 0.07 & 0.45 & 0.3 & 0.89 & 1.19 & 1.34 & 1.86 & 2.61 & 1.71 & 0.89 & 0.37 & 0.22 \tabularnewline
10 & 0.12 & 0.12 & 0.75 & 0.5 & 1.49 & 1.99 & 2.24 & 3.11 & 4.35 & 2.86 & 1.49 & 0.62 & 0.37 \tabularnewline
11 & 0.17 & 0.17 & 1.04 & 0.7 & 2.09 & 2.78 & 3.13 & 4.35 & 6.09 & 4 & 2.09 & 0.87 & 0.52 \tabularnewline
12 & 0.3 & 0.3 & 1.79 & 1.19 & 3.58 & 4.77 & 5.37 & 7.45 & 10.43 & 6.86 & 3.58 & 1.49 & 0.89 \tabularnewline
13 & 0.09 & 0.09 & 0.52 & 0.35 & 1.04 & 1.39 & 1.57 & 2.17 & 3.04 & 2 & 1.04 & 0.43 & 0.26 \tabularnewline
14 & 0.06 & 0.06 & 0.37 & 0.25 & 0.75 & 0.99 & 1.12 & 1.55 & 2.17 & 1.43 & 0.75 & 0.31 & 0.19 \tabularnewline
15 & 0.05 & 0.05 & 0.3 & 0.2 & 0.6 & 0.8 & 0.89 & 1.24 & 1.74 & 1.14 & 0.6 & 0.25 & 0.15 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=187268&T=2

[TABLE]
[ROW][C]Tabulation of Expected Results[/C][/ROW]
[ROW][C]Software  x  Happiness[/C][/ROW]
[ROW][C] [/C][C]7[/C][C]8[/C][C]9[/C][C]10[/C][C]11[/C][C]12[/C][C]13[/C][C]14[/C][C]15[/C][C]16[/C][C]17[/C][C]18[/C][C]19[/C][/ROW]
[C]5[/C][C]0.01[/C][C]0.01[/C][C]0.04[/C][C]0.02[/C][C]0.07[/C][C]0.1[/C][C]0.11[/C][C]0.16[/C][C]0.22[/C][C]0.14[/C][C]0.07[/C][C]0.03[/C][C]0.02[/C][/ROW]
[C]6[/C][C]0.04[/C][C]0.04[/C][C]0.22[/C][C]0.15[/C][C]0.45[/C][C]0.6[/C][C]0.67[/C][C]0.93[/C][C]1.3[/C][C]0.86[/C][C]0.45[/C][C]0.19[/C][C]0.11[/C][/ROW]
[C]7[/C][C]0.02[/C][C]0.02[/C][C]0.15[/C][C]0.1[/C][C]0.3[/C][C]0.4[/C][C]0.45[/C][C]0.62[/C][C]0.87[/C][C]0.57[/C][C]0.3[/C][C]0.12[/C][C]0.07[/C][/ROW]
[C]8[/C][C]0.06[/C][C]0.06[/C][C]0.37[/C][C]0.25[/C][C]0.75[/C][C]0.99[/C][C]1.12[/C][C]1.55[/C][C]2.17[/C][C]1.43[/C][C]0.75[/C][C]0.31[/C][C]0.19[/C][/ROW]
[C]9[/C][C]0.07[/C][C]0.07[/C][C]0.45[/C][C]0.3[/C][C]0.89[/C][C]1.19[/C][C]1.34[/C][C]1.86[/C][C]2.61[/C][C]1.71[/C][C]0.89[/C][C]0.37[/C][C]0.22[/C][/ROW]
[C]10[/C][C]0.12[/C][C]0.12[/C][C]0.75[/C][C]0.5[/C][C]1.49[/C][C]1.99[/C][C]2.24[/C][C]3.11[/C][C]4.35[/C][C]2.86[/C][C]1.49[/C][C]0.62[/C][C]0.37[/C][/ROW]
[C]11[/C][C]0.17[/C][C]0.17[/C][C]1.04[/C][C]0.7[/C][C]2.09[/C][C]2.78[/C][C]3.13[/C][C]4.35[/C][C]6.09[/C][C]4[/C][C]2.09[/C][C]0.87[/C][C]0.52[/C][/ROW]
[C]12[/C][C]0.3[/C][C]0.3[/C][C]1.79[/C][C]1.19[/C][C]3.58[/C][C]4.77[/C][C]5.37[/C][C]7.45[/C][C]10.43[/C][C]6.86[/C][C]3.58[/C][C]1.49[/C][C]0.89[/C][/ROW]
[C]13[/C][C]0.09[/C][C]0.09[/C][C]0.52[/C][C]0.35[/C][C]1.04[/C][C]1.39[/C][C]1.57[/C][C]2.17[/C][C]3.04[/C][C]2[/C][C]1.04[/C][C]0.43[/C][C]0.26[/C][/ROW]
[C]14[/C][C]0.06[/C][C]0.06[/C][C]0.37[/C][C]0.25[/C][C]0.75[/C][C]0.99[/C][C]1.12[/C][C]1.55[/C][C]2.17[/C][C]1.43[/C][C]0.75[/C][C]0.31[/C][C]0.19[/C][/ROW]
[C]15[/C][C]0.05[/C][C]0.05[/C][C]0.3[/C][C]0.2[/C][C]0.6[/C][C]0.8[/C][C]0.89[/C][C]1.24[/C][C]1.74[/C][C]1.14[/C][C]0.6[/C][C]0.25[/C][C]0.15[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=187268&T=2

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=187268&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
Software x Happiness
78910111213141516171819
50.010.010.040.020.070.10.110.160.220.140.070.030.02
60.040.040.220.150.450.60.670.931.30.860.450.190.11
70.020.020.150.10.30.40.450.620.870.570.30.120.07
80.060.060.370.250.750.991.121.552.171.430.750.310.19
90.070.070.450.30.891.191.341.862.611.710.890.370.22
100.120.120.750.51.491.992.243.114.352.861.490.620.37
110.170.171.040.72.092.783.134.356.0942.090.870.52
120.30.31.791.193.584.775.377.4510.436.863.581.490.89
130.090.090.520.351.041.391.572.173.0421.040.430.26
140.060.060.370.250.750.991.121.552.171.430.750.310.19
150.050.050.30.20.60.80.891.241.741.140.60.250.15







Statistical Results
Pearson's Chi-squared test
Pearson Chi Square Statistic151.18
Degrees of Freedom120
P value0.03

\begin{tabular}{lllllllll}
\hline
Statistical Results \tabularnewline
Pearson's Chi-squared test \tabularnewline
Pearson Chi Square Statistic & 151.18 \tabularnewline
Degrees of Freedom & 120 \tabularnewline
P value & 0.03 \tabularnewline
\hline
\end{tabular}
%Source: https://freestatistics.org/blog/index.php?pk=187268&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]151.18[/C][/ROW]
[ROW][C]Degrees of Freedom[/C][C]120[/C][/ROW]
[ROW][C]P value[/C][C]0.03[/C][/ROW]
[/TABLE]
Source: https://freestatistics.org/blog/index.php?pk=187268&T=3

Globally Unique Identifier (entire table): ba.freestatistics.org/blog/index.php?pk=187268&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 Statistic151.18
Degrees of Freedom120
P value0.03



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