Some of the functions that Deducer (http://www.deducer.org) GUI provides are also useful for CUI use. I asked the author, Dr. Ian Fellows about this, and he kindly provided how to load Deducer in the CUI environment.
Sys.setenv(NOAWT = 1)
## options(DeducerNoGUI = TRUE) # This is not necessary. If used, Deducer on JGR is inactivated.
## It's certainly not a usual way of using Deducer.
library(Deducer)
Note: On Mac OS X we strongly recommend using iplots from within JGR.
Proceed at your own risk as iplots cannot resolve potential ev.loop deadlocks.
'Yes' is assumed for all dialogs as they cannot be shown without a deadlock,
also ievent.wait() is disabled.
## Load Arthritis dataset from vcd package
library(vcd)
data(Arthritis)
## frequencies function in Deducer
frequencies(Arthritis[,-1])
$Treatment
------------------------------------------------------------
-- Frequencies --
-- --
Value # of Cases % Cumulative %
1 Placebo 43 51.2 51.2
2 Treated 41 48.8 100.0
-- --
-- Case Summary --
-- --
Valid Missing Total
# of cases 84 0 84
-- --
-- --
------------------------------------------------------------
$Sex
------------------------------------------------------------
-- Frequencies --
-- --
Value # of Cases % Cumulative %
1 Female 59 70.2 70.2
2 Male 25 29.8 100.0
-- --
-- Case Summary --
-- --
Valid Missing Total
# of cases 84 0 84
-- --
-- --
------------------------------------------------------------
$Age
------------------------------------------------------------
-- Frequencies --
-- --
Value # of Cases % Cumulative %
1 23 2 2.4 2.4
2 27 1 1.2 3.6
3 29 1 1.2 4.8
4 30 3 3.6 8.3
5 31 1 1.2 9.5
6 32 3 3.6 13.1
7 33 1 1.2 14.3
8 37 3 3.6 17.9
9 41 2 2.4 20.2
10 44 2 2.4 22.6
11 45 1 1.2 23.8
12 46 2 2.4 26.2
13 48 3 3.6 29.8
14 49 1 1.2 31.0
15 50 1 1.2 32.1
16 51 2 2.4 34.5
17 52 1 1.2 35.7
18 53 2 2.4 38.1
19 54 3 3.6 41.7
20 55 3 3.6 45.2
21 56 1 1.2 46.4
22 57 5 6.0 52.4
23 58 3 3.6 56.0
24 59 8 9.5 65.5
25 60 1 1.2 66.7
26 61 2 2.4 69.0
27 62 4 4.8 73.8
28 63 4 4.8 78.6
29 64 3 3.6 82.1
30 65 1 1.2 83.3
31 66 4 4.8 88.1
32 67 1 1.2 89.3
33 68 3 3.6 92.9
34 69 3 3.6 96.4
35 70 2 2.4 98.8
36 74 1 1.2 100.0
-- --
-- Case Summary --
-- --
Valid Missing Total
# of cases 84 0 84
-- --
-- --
------------------------------------------------------------
$Improved
------------------------------------------------------------
-- Frequencies --
-- --
Value # of Cases % Cumulative %
1 None 42 50.0 50.0
2 Some 14 16.7 66.7
3 Marked 28 33.3 100.0
-- --
-- Case Summary --
-- --
Valid Missing Total
# of cases 84 0 84
-- --
-- --
------------------------------------------------------------
Rosner's bone density data are used. ' http://www.cengage.com/cgi-wadsworth/course_products_wp.pl?fid=M20bI&product_isbn_issn=9780538733496
## Bone density
bone <- read.csv("~/statistics/bio206Rosner7th/ASCII-comma/BONEDEN.DAT.txt", quote = "'")
desc.res <- descriptive.table(vars = d(age, ht1, wt1, ht2, wt2) ,
strata = d(zyg),
data= bone)
desc.res
$`zyg: 1 `
Mean St. Deviation Median 25th Percentile 75th Percentile Minimum Maximum Skew Kurtosis Valid N
age 51.38 10.740 49 44 55 36 73 0.8487 0.1566 21
ht1 160.76 5.656 162 157 165 149 169 -0.6389 -0.3984 21
wt1 66.95 13.629 66 61 70 48 112 1.6906 5.3044 21
ht2 162.38 4.353 163 160 165 153 169 -0.7922 0.1180 21
wt2 65.19 12.995 62 55 73 43 94 0.5322 -0.2492 21
$`zyg: 2 `
Mean St. Deviation Median 25th Percentile 75th Percentile Minimum Maximum Skew Kurtosis Valid N
age 46.20 12.480 44.0 39.25 48.25 27 76 1.0072 0.8581 20
ht1 162.10 4.789 162.5 160.50 164.25 150 171 -0.7649 1.6018 20
wt1 63.75 16.293 58.5 56.50 65.75 47 114 2.0587 4.4823 20
ht2 160.75 4.962 161.5 157.75 164.00 150 170 -0.2192 -0.1060 20
wt2 58.30 9.701 56.0 53.00 60.00 43 88 1.6712 3.9242 20
## Two-sample t-test
two.sample.test(formula = d(age, ht1, wt1, ht2, wt2) ~ zyg, data = bone, test = t.test, var.equal = TRUE)
Two Sample t-test
mean of 1 mean of 2 Difference 95% CI Lower 95% CI Upper t df p-value
age 51.38 46.20 5.181 -2.1627 12.525 1.4270 39 0.16153
ht1 160.76 162.10 -1.338 -4.6570 1.981 -0.8155 39 0.41974
wt1 66.95 63.75 3.202 -6.2684 12.673 0.6839 39 0.49806
ht2 162.38 160.75 1.631 -1.3137 4.576 1.1203 39 0.26943
wt2 65.19 58.30 6.890 -0.3826 14.164 1.9163 39 0.06268
HA: two.sided
H0: difference in means = 0
## Welch Two-sample t-test (not assuming equal variance)
two.sample.test(formula = d(age, ht1, wt1, ht2, wt2) ~ zyg, data = bone, test = t.test, var.equal = FALSE)
Welch Two Sample t-test
mean of 1 mean of 2 Difference 95% CI Lower 95% CI Upper t df p-value
age 51.38 46.20 5.181 -2.199 12.561 1.4217 37.52 0.16337
ht1 160.76 162.10 -1.338 -4.645 1.969 -0.8189 38.49 0.41790
wt1 66.95 63.75 3.202 -6.326 12.731 0.6809 37.11 0.50015
ht2 162.38 160.75 1.631 -1.326 4.588 1.1167 37.78 0.27119
wt2 65.19 58.30 6.890 -0.344 14.125 1.9300 36.94 0.06132
HA: two.sided
H0: difference in means = 0
## Wilcoxon test
two.sample.test(formula = d(age, ht1, wt1, ht2, wt2) ~ zyg, data = bone, test = wilcox.test, correct = FALSE)
Wilcoxon rank sum test
W p-value
age 280 0.06747
ht1 188 0.56483
wt1 272 0.10545
ht2 255 0.23900
wt2 283 0.05652
HA: two.sided
H0: location shift = 0
## Classical ANOVA (here it is just two groups)
k.sample.test(formula = d(age, ht1, wt1, ht2, wt2) ~ zyg, data = bone, test = oneway.test, var.equal = TRUE)
One-way analysis of means
F (num df,denom df) p-value
age 2.0364 (1,39) 0.16153
ht1 0.6650 (1,39) 0.41974
wt1 0.4678 (1,39) 0.49806
ht2 1.2551 (1,39) 0.26943
wt2 3.6722 (1,39) 0.06268
## ANOVA without assuming equal variance
k.sample.test(formula = d(age, ht1, wt1, ht2, wt2) ~ zyg, data = bone, test = oneway.test, var.equal = FALSE)
One-way analysis of means (not assuming equal variances)
F (num df,denom df) p-value
age 2.0212 (1,37.522) 0.16337
ht1 0.6705 (1,38.487) 0.41790
wt1 0.4637 (1,37.106) 0.50015
ht2 1.2470 (1,37.779) 0.27119
wt2 3.7247 (1,36.941) 0.06132
table.result <- contingency.tables(row.vars = d(Sex,Improved),
col.vars = d(Treatment),
data = Arthritis)
## Add Fisher exact test
table.result <- add.fishers.exact(table.result)
## Full result
table.result
====================================================================================================================
======================================================================================
========== Table: Sex by Treatment ==========
| Treatment
Sex | Placebo | Treated | Row Total |
-----------------------|-----------|-----------|-----------|
Female Count | 32 | 27 | 59 |
Row % | 54.237% | 45.763% | 70.238% |
Column % | 74.419% | 65.854% | |
Total % | 38.095% | 32.143% | |
-----------------------|-----------|-----------|-----------|
Male Count | 11 | 14 | 25 |
Row % | 44.000% | 56.000% | 29.762% |
Column % | 25.581% | 34.146% | |
Total % | 13.095% | 16.667% | |
-----------------------|-----------|-----------|-----------|
Column Total | 43 | 41 | 84 |
Column % | 51.190% | 48.810% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.476
======================================================================================
========== Table: Improved by Treatment ==========
| Treatment
Improved | Placebo | Treated | Row Total |
-----------------------|-----------|-----------|-----------|
None Count | 29 | 13 | 42 |
Row % | 69.048% | 30.952% | 50.000% |
Column % | 67.442% | 31.707% | |
Total % | 34.524% | 15.476% | |
-----------------------|-----------|-----------|-----------|
Some Count | 7 | 7 | 14 |
Row % | 50.000% | 50.000% | 16.667% |
Column % | 16.279% | 17.073% | |
Total % | 8.333% | 8.333% | |
-----------------------|-----------|-----------|-----------|
Marked Count | 7 | 21 | 28 |
Row % | 25.000% | 75.000% | 33.333% |
Column % | 16.279% | 51.220% | |
Total % | 8.333% | 25.000% | |
-----------------------|-----------|-----------|-----------|
Column Total | 43 | 41 | 84 |
Column % | 51.190% | 48.810% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.001
====================================================================================================================
## Simplified result
print(table.result, prop.r = F, prop.t = F)
====================================================================================================================
======================================================================================
========== Table: Sex by Treatment ==========
| Treatment
Sex | Placebo | Treated | Row Total |
-----------------------|-----------|-----------|-----------|
Female Count | 32 | 27 | 59 |
Column % | 74.419% | 65.854% | |
-----------------------|-----------|-----------|-----------|
Male Count | 11 | 14 | 25 |
Column % | 25.581% | 34.146% | |
-----------------------|-----------|-----------|-----------|
Column Total | 43 | 41 | 84 |
Column % | 51.190% | 48.810% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.476
======================================================================================
========== Table: Improved by Treatment ==========
| Treatment
Improved | Placebo | Treated | Row Total |
-----------------------|-----------|-----------|-----------|
None Count | 29 | 13 | 42 |
Column % | 67.442% | 31.707% | |
-----------------------|-----------|-----------|-----------|
Some Count | 7 | 7 | 14 |
Column % | 16.279% | 17.073% | |
-----------------------|-----------|-----------|-----------|
Marked Count | 7 | 21 | 28 |
Column % | 16.279% | 51.220% | |
-----------------------|-----------|-----------|-----------|
Column Total | 43 | 41 | 84 |
Column % | 51.190% | 48.810% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.001
====================================================================================================================
all.by.all.table <-
contingency.tables(row.vars = d(Sex,Improved,Treatment),
col.vars = d(Sex,Improved,Treatment),
data = Arthritis)
## Add Fisher exact test
all.by.all.table <- add.fishers.exact(all.by.all.table)
## Full table
all.by.all.table
====================================================================================================================
======================================================================================
========== Table: Sex by Sex ==========
| Sex
Sex | Female | Male | Row Total |
-----------------------|-----------|-----------|-----------|
Female Count | 59 | 0 | 59 |
Row % | 100.000% | 0.000% | 70.238% |
Column % | 100.000% | 0.000% | |
Total % | 70.238% | 0.000% | |
-----------------------|-----------|-----------|-----------|
Male Count | 0 | 25 | 25 |
Row % | 0.000% | 100.000% | 29.762% |
Column % | 0.000% | 100.000% | |
Total % | 0.000% | 29.762% | |
-----------------------|-----------|-----------|-----------|
Column Total | 59 | 25 | 84 |
Column % | 70.238% | 29.762% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | <0.001
======================================================================================
========== Table: Sex by Improved ==========
| Improved
Sex | None | Some | Marked | Row Total |
-----------------------|-----------|-----------|-----------|-----------|
Female Count | 25 | 12 | 22 | 59 |
Row % | 42.373% | 20.339% | 37.288% | 70.238% |
Column % | 59.524% | 85.714% | 78.571% | |
Total % | 29.762% | 14.286% | 26.190% | |
-----------------------|-----------|-----------|-----------|-----------|
Male Count | 17 | 2 | 6 | 25 |
Row % | 68.000% | 8.000% | 24.000% | 29.762% |
Column % | 40.476% | 14.286% | 21.429% | |
Total % | 20.238% | 2.381% | 7.143% | |
-----------------------|-----------|-----------|-----------|-----------|
Column Total | 42 | 14 | 28 | 84 |
Column % | 50.000% | 16.667% | 33.333% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.109
======================================================================================
========== Table: Sex by Treatment ==========
| Treatment
Sex | Placebo | Treated | Row Total |
-----------------------|-----------|-----------|-----------|
Female Count | 32 | 27 | 59 |
Row % | 54.237% | 45.763% | 70.238% |
Column % | 74.419% | 65.854% | |
Total % | 38.095% | 32.143% | |
-----------------------|-----------|-----------|-----------|
Male Count | 11 | 14 | 25 |
Row % | 44.000% | 56.000% | 29.762% |
Column % | 25.581% | 34.146% | |
Total % | 13.095% | 16.667% | |
-----------------------|-----------|-----------|-----------|
Column Total | 43 | 41 | 84 |
Column % | 51.190% | 48.810% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.476
======================================================================================
========== Table: Improved by Sex ==========
| Sex
Improved | Female | Male | Row Total |
-----------------------|-----------|-----------|-----------|
None Count | 25 | 17 | 42 |
Row % | 59.524% | 40.476% | 50.000% |
Column % | 42.373% | 68.000% | |
Total % | 29.762% | 20.238% | |
-----------------------|-----------|-----------|-----------|
Some Count | 12 | 2 | 14 |
Row % | 85.714% | 14.286% | 16.667% |
Column % | 20.339% | 8.000% | |
Total % | 14.286% | 2.381% | |
-----------------------|-----------|-----------|-----------|
Marked Count | 22 | 6 | 28 |
Row % | 78.571% | 21.429% | 33.333% |
Column % | 37.288% | 24.000% | |
Total % | 26.190% | 7.143% | |
-----------------------|-----------|-----------|-----------|
Column Total | 59 | 25 | 84 |
Column % | 70.238% | 29.762% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.109
======================================================================================
========== Table: Improved by Improved ==========
| Improved
Improved | None | Some | Marked | Row Total |
-----------------------|-----------|-----------|-----------|-----------|
None Count | 42 | 0 | 0 | 42 |
Row % | 100.000% | 0.000% | 0.000% | 50.000% |
Column % | 100.000% | 0.000% | 0.000% | |
Total % | 50.000% | 0.000% | 0.000% | |
-----------------------|-----------|-----------|-----------|-----------|
Some Count | 0 | 14 | 0 | 14 |
Row % | 0.000% | 100.000% | 0.000% | 16.667% |
Column % | 0.000% | 100.000% | 0.000% | |
Total % | 0.000% | 16.667% | 0.000% | |
-----------------------|-----------|-----------|-----------|-----------|
Marked Count | 0 | 0 | 28 | 28 |
Row % | 0.000% | 0.000% | 100.000% | 33.333% |
Column % | 0.000% | 0.000% | 100.000% | |
Total % | 0.000% | 0.000% | 33.333% | |
-----------------------|-----------|-----------|-----------|-----------|
Column Total | 42 | 14 | 28 | 84 |
Column % | 50.000% | 16.667% | 33.333% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | <0.001
======================================================================================
========== Table: Improved by Treatment ==========
| Treatment
Improved | Placebo | Treated | Row Total |
-----------------------|-----------|-----------|-----------|
None Count | 29 | 13 | 42 |
Row % | 69.048% | 30.952% | 50.000% |
Column % | 67.442% | 31.707% | |
Total % | 34.524% | 15.476% | |
-----------------------|-----------|-----------|-----------|
Some Count | 7 | 7 | 14 |
Row % | 50.000% | 50.000% | 16.667% |
Column % | 16.279% | 17.073% | |
Total % | 8.333% | 8.333% | |
-----------------------|-----------|-----------|-----------|
Marked Count | 7 | 21 | 28 |
Row % | 25.000% | 75.000% | 33.333% |
Column % | 16.279% | 51.220% | |
Total % | 8.333% | 25.000% | |
-----------------------|-----------|-----------|-----------|
Column Total | 43 | 41 | 84 |
Column % | 51.190% | 48.810% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.001
======================================================================================
========== Table: Treatment by Sex ==========
| Sex
Treatment | Female | Male | Row Total |
-----------------------|-----------|-----------|-----------|
Placebo Count | 32 | 11 | 43 |
Row % | 74.419% | 25.581% | 51.190% |
Column % | 54.237% | 44.000% | |
Total % | 38.095% | 13.095% | |
-----------------------|-----------|-----------|-----------|
Treated Count | 27 | 14 | 41 |
Row % | 65.854% | 34.146% | 48.810% |
Column % | 45.763% | 56.000% | |
Total % | 32.143% | 16.667% | |
-----------------------|-----------|-----------|-----------|
Column Total | 59 | 25 | 84 |
Column % | 70.238% | 29.762% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.476
======================================================================================
========== Table: Treatment by Improved ==========
| Improved
Treatment | None | Some | Marked | Row Total |
-----------------------|-----------|-----------|-----------|-----------|
Placebo Count | 29 | 7 | 7 | 43 |
Row % | 67.442% | 16.279% | 16.279% | 51.190% |
Column % | 69.048% | 50.000% | 25.000% | |
Total % | 34.524% | 8.333% | 8.333% | |
-----------------------|-----------|-----------|-----------|-----------|
Treated Count | 13 | 7 | 21 | 41 |
Row % | 31.707% | 17.073% | 51.220% | 48.810% |
Column % | 30.952% | 50.000% | 75.000% | |
Total % | 15.476% | 8.333% | 25.000% | |
-----------------------|-----------|-----------|-----------|-----------|
Column Total | 42 | 14 | 28 | 84 |
Column % | 50.000% | 16.667% | 33.333% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | 0.001
======================================================================================
========== Table: Treatment by Treatment ==========
| Treatment
Treatment | Placebo | Treated | Row Total |
-----------------------|-----------|-----------|-----------|
Placebo Count | 43 | 0 | 43 |
Row % | 100.000% | 0.000% | 51.190% |
Column % | 100.000% | 0.000% | |
Total % | 51.190% | 0.000% | |
-----------------------|-----------|-----------|-----------|
Treated Count | 0 | 41 | 41 |
Row % | 0.000% | 100.000% | 48.810% |
Column % | 0.000% | 100.000% | |
Total % | 0.000% | 48.810% | |
-----------------------|-----------|-----------|-----------|
Column Total | 43 | 41 | 84 |
Column % | 51.190% | 48.810% | |
| Exact
Test | Statistic DF p-value
Fishers Exact | <0.001
====================================================================================================================