Date: 2022-09-06

# Comparison with other software

#### 2022-09-06

# Introduction

In this document, we compare various DescrTab2 tests and descriptive statistics with their SAS equivalents.

These comparisons are not automated. The user may check if the results presented within this document are according to the users preferences.

The datasets used in these comparisons are taken mostly from the `?help` pages of the underlying test functions used within `DescrTab2`. For the SAS comparisons, these datasets are then written to `.csv` format and read into SAS with help of the `?foreign` package.

The origin of these datasets is described in the respective sections.

# A note about the layout

This document is created by including in the .html SAS output. Unfortunately, this has ugly side effects for the formatting of this document, but everything should still be readable.

# Wilcoxon one-sample signed-rank test

Dataset origin: `?wilcox.test` (accessed on R-version 4.0.3).

    x <- c(1.83,  0.50,  1.62,  2.48, 1.68, 1.88, 1.55, 3.06, 1.30)
    y <- c(0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29)
    dat_wilcox.test_1_sample <- tibble(diff = x-y)

    descr(dat_wilcox.test_1_sample, test_options = c(nonparametric=TRUE))

Variables | Total | p
--- | --- | ---
| (N=9) |
diff
N | 9 | 0.039Wil1
mean | 0.43 |
sd | 0.43 |
median | 0.49 |
Q1 - Q3 | 0.01 – 0.62 |
min - max | -0.15 – 1 |
Wil1 Wilcoxon’s one-sample signed-rank test

# Mann-Whitney U test

Dataset origin: `?wilcox.test` (accessed on R-version 4.0.3).

    x <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46)
    y <- c(1.15, 0.88, 0.90, 0.74, 1.21)
    group <- c(rep("Trt", length(x)), rep("Ctrl", length(y)))
    dat_wilcox.test_2_sample <- tibble(var=c(x,y), group=group)

    descr(dat_wilcox.test_2_sample, "group", test_options = c(nonparametric=TRUE))

Variables | Trt | Ctrl | Total | p | CI
--- | --- | --- | --- | --- | ---
| (N=10) | (N=5) | (N=15) |  |
var
N | 10 | 5 | 15 | 0.254MWU | [-0.15, 0.76]HL
mean | 1.3 | 0.98 | 1.2 |  |
sd | 0.44 | 0.2 | 0.4 |  |
median | 1.4 | 0.9 | 1.1 |  |
Q1 - Q3 | 0.83 – 1.6 | 0.88 – 1.1 | 0.83 – 1.5 |  |
min - max | 0.73 – 1.9 | 0.74 – 1.2 | 0.73 – 1.9 |  |
MWU Mann-Whitney’s U test
HL CI for the Hodges-Lehmann estimator

# Kruskal-Wallis one-way ANOVA

Dataset origin: `?kruskal.test` (accessed on R-version 4.0.3).

    x <- c(2.9, 3.0, 2.5, 2.6, 3.2) # normal subjects
    y <- c(3.8, 2.7, 4.0, 2.4)      # with obstructive airway disease
    z <- c(2.8, 3.4, 3.7, 2.2, 2.0) # with asbestosis
    group <- c(rep("Trt", length(x)), rep("Ctrl", length(y)), rep("Placebo", length(z)))
    dat_kruskal.test <- tibble(var=c(x,y,z), group=group)

    descr(dat_kruskal.test, "group", test_options = c(nonparametric=TRUE))

Variables | Trt | Ctrl | Placebo | Total | p
--- | --- | --- | --- | --- | ---
| (N=5) | (N=4) | (N=5) | (N=14) |
var
N | 5 | 4 | 5 | 14 | 0.680KW
mean | 2.8 | 3.2 | 2.8 | 2.9 |
sd | 0.29 | 0.79 | 0.74 | 0.61 |
median | 2.9 | 3.2 | 2.8 | 2.8 |
Q1 - Q3 | 2.6 – 3 | 2.5 – 3.9 | 2.2 – 3.4 | 2.5 – 3.4 |
min - max | 2.5 – 3.2 | 2.4 – 4 | 2 – 3.7 | 2 – 4 |
KW Kruskal-Wallis’s one-way ANOVA

SAS Output

The SAS System

The NPAR1WAY Procedure

Kruskal-Wallis Test
Chi-Square | DF | Pr > ChiSq
--- | --- | ---
0.7714 | 2 | 0.6800

# Friedman test

Dataset origin: `?friedman.test` (accessed on R-version 4.0.3).

    RoundingTimes <-
    matrix(c(5.40, 5.50, 5.55,
             5.85, 5.70, 5.75,
             5.20, 5.60, 5.50,
             5.55, 5.50, 5.40,
             5.90, 5.85, 5.70,
             5.45, 5.55, 5.60,
             5.40, 5.40, 5.35,
             5.45, 5.50, 5.35,
             5.25, 5.15, 5.00,
             5.85, 5.80, 5.70,
             5.25, 5.20, 5.10,
             5.65, 5.55, 5.45,
             5.60, 5.35, 5.45,
             5.05, 5.00, 4.95,
             5.50, 5.50, 5.40,
             5.45, 5.55, 5.50,
             5.55, 5.55, 5.35,
             5.45, 5.50, 5.55,
             5.50, 5.45, 5.25,
             5.65, 5.60, 5.40,
             5.70, 5.65, 5.55,
             6.30, 6.30, 6.25),
           nrow = 22,
           byrow = TRUE,
           dimnames = list(1 : 22,
                           c("Round Out", "Narrow Angle", "Wide Angle")))

    idx <- rep(1:22, 3)
    dat <- tibble(var = c(RoundingTimes[,1], RoundingTimes[,2], RoundingTimes[,3]),
                  group = c(rep("Round Out", 22), rep("Narrow Angle", 22), rep("Wide Angle", 22)))

    descr(dat, "group", test_options = list(nonparametric=TRUE, indices=idx, paired=TRUE))
    #> You specified paired tests and did not explicitly
    #> specify format_options$print_Total. print_Total is set to FALSE.

Variables | Round Out | Narrow Angle | Wide Angle | p
--- | --- | --- | --- | ---
| (N=22) | (N=22) | (N=22) |
var
N | 22 | 22 | 22 | 0.004Frie
mean | 5.5 | 5.5 | 5.5 |
sd | 0.27 | 0.26 | 0.27 |
median | 5.5 | 5.5 | 5.4 |
Q1 - Q3 | 5.4 – 5.6 | 5.4 – 5.6 | 5.3 – 5.5 |
min - max | 5 – 6.3 | 5 – 6.3 | 5 – 6.2 |
Frie Friedman test

SAS Output

The SAS System

The FREQ Procedure

Summary Statistics for group by var Controlling for indices

Cochran-Mantel-Haenszel Statistics (Based on Rank Scores)
Statistic | Alternative Hypothesis | DF | Value | Prob
--- | --- | --- | --- | ---
1 | Nonzero Correlation | 1 | 5.3571 | 0.0206
2 | Row Mean Scores Differ | 2 | 11.1429 | 0.0038

Total Sample Size = 66

# Cochrans Q test

Dataset origin: This is a replicate of the dataset from the SAS documentation of the Cochrane Q test from proc freq.

    d.frm <- DescTools::Untable(xtabs(c(6,2,2,6,16,4,4,6) ~ .,
        expand.grid(rep(list(c("F","U")), times=3))),
        colnames = LETTERS[1:3])

    # rearrange to long shape
    d.long <- reshape(d.frm, varying=1:3, times=names(d.frm)[c(1:3)],
                      v.names="resp", direction="long")
    idx <- d.long$id
    dat <- d.long[, 1:2] %>% mutate(time=as.character(time), resp=as.character(resp))

    descr(dat, "time", test_options = list(indices=idx, paired=TRUE))
    #> You specified paired tests and did not explicitly
    #> specify format_options$print_Total. print_Total is set to FALSE.

Variables | A | B | C | p
--- | --- | --- | --- | ---
| (N=46) | (N=46) | (N=46) |
resp
F | 28 (61%) | 28 (61%) | 16 (35%) | 0.014CocQ
U | 18 (39%) | 18 (39%) | 30 (65%) |
CocQ Cochran’s Q test

SAS Output

The SAS System

The FREQ Procedure
Summary Statistics for B by C
Controlling for A

Cochran's Q, for A by B by C
Chi-Square | DF | Pr > ChiSq
--- | --- | ---
8.4706 | 2 | 0.0145

# McNemars test

Dataset origin: `?mcnemar.test` (accessed on R-version 4.0.3). Note that this dataset is not explicitly defined in `?mcnemar.test`. It is constructed to reflect the cross table defined there.

    dat <- tibble::tibble(var = c(rep("Approve", 794), rep("Approve", 150), rep("Disapprove", 86), rep("Disapprove", 570),
                          rep("Approve", 794), rep("Disapprove", 150), rep("Approve", 86), rep("Disapprove", 570)),
                  group= c(rep("first", 1600), rep("second",1600)))

    descr(dat, "group", test_options = list(paired=TRUE, indices=c(1:1600, 1:1600)))
    #> You specified paired tests and did not explicitly
    #> specify format_options$print_Total. print_Total is set to FALSE.
    #> Warning in sig_test(var, group, test_options, test_override, var_name): Confidence intervals for differences in proportions ignore the paired structure of the data.
    #> Use Exact McNemar's test if you want confidence intervals which use the test statistic of the
    #> exact McNemar's test.

Variables | first | second | p | CI
--- | --- | --- | --- | ---
| (N=1600) | (N=1600) |  |
var
Approve | 944 (59%) | 880 (55%) | <0.001McN | [0.0057, 0.074]PWa
Disapprove | 656 (41%) | 720 (45%) |  |
McN McNemar’s test
PWa CI for difference in proportions derived from a normal (“Wald”) approximation

    descr(dat, "group", test_options = list(paired=TRUE, exact=TRUE, indices=c(1:1600, 1:1600)))
    #> You specified paired tests and did not explicitly
    #> specify format_options$print_Total. print_Total is set to FALSE.

Variables | first | second | p | CI
--- | --- | --- | --- | ---
| (N=1600) | (N=1600) |  |
var
Approve | 944 (59%) | 880 (55%) | <0.001eMcN | [0.021, 0.059]PMcN
Disapprove | 656 (41%) | 720 (45%) |  |
eMcN Exact McNemar’s test
PMcN CI for difference in proportions derived from an exact McNemar’s test

    dat <-
      tibble::tibble(x = c(
        rep("Approve", 794),
        rep("Approve", 150),
        rep("Disapprove", 86),
        rep("Disapprove", 570)
      ),
      y = c(
        rep("Approve", 794),
        rep("Disapprove", 150),
        rep("Approve", 86),
        rep("Disapprove", 570)
      ))

    mcnemar.test(dat$x, dat$y, correct = FALSE)
    #>
    #>  McNemar's Chi-squared test
    #>
    #> data:  dat$x and dat$y
    #> McNemar's chi-squared = 17.356, df = 1, p-value = 3.099e-05

SAS Output

The SAS System

The FREQ Procedure

Frequency
Percent
Row Pct
Col Pct
Table of x by y
x | y
--- | ---
Approve | Disapprove | Total
Approve |
794
49.63
84.11
90.23
150
9.38
15.89
20.83
944
59.00
Disapprove |
86
5.38
13.11
9.77
570
35.63
86.89
79.17
656
41.00
Total |
880
55.00
720
45.00
1600
100.00

Statistics for Table of x by y

McNemar's Test
Chi-Square | DF | Pr > ChiSq | Exact Pr >= ChiSq
--- | --- | --- | ---
17.3559 | 1 | <.0001 | .000037159

Simple Kappa Coefficient
Estimate | Standard Error | 95% Confidence Limits
--- | --- | ---
0.6996 | 0.0180 | 0.6644 | 0.7348

Sample Size = 1600

# Chi-squared test

Dataset origin: “Gender-Party dataset”:`?chisq.test` (accessed on R-version 4.0.3). “a-b dataset”: selfmade.

    dat <- tibble(gender=c(rep("F",sum(c(762, 327, 468)) ), rep("M", sum( c(484, 239, 477)))),
                  party=c(rep("Democrat", 762), rep("Independent", 327), rep("Republican", 468),
                          rep("Democrat", 484), rep("Independent", 239), rep("Republican", 477)))

    descr(dat, "gender")

Variables | F | M | Total | p | CI
--- | --- | --- | --- | --- | ---
| (N=1557) | (N=1200) | (N=2757) |  |
party
Democrat | 762 (49%) | 484 (40%) | 1246 (45%) | <0.001chi2 |
Independent | 327 (21%) | 239 (20%) | 566 (21%) |  |
Republican | 468 (30%) | 477 (40%) | 945 (34%) |  |
chi2 Pearson’s chi-squared test

    descr(dat)

Variables | Total | p
--- | --- | ---
| (N=2757) |
gender
F | 1557 (56%) | <0.001chi1
M | 1200 (44%) |
party
Democrat | 1246 (45%) | <0.001chi1
Independent | 566 (21%) |
Republican | 945 (34%) |
chi1 Chi-squared goodness-of-fit test

    chisq.test(dat$gender, dat$party)
    #>
    #>  Pearson's Chi-squared test
    #>
    #> data:  dat$gender and dat$party
    #> X-squared = 30.07, df = 2, p-value = 2.954e-07
    chisq.test(table(dat$gender))
    #>
    #>  Chi-squared test for given probabilities
    #>
    #> data:  table(dat$gender)
    #> X-squared = 46.227, df = 1, p-value = 1.053e-11
    chisq.test(table(dat$party))
    #>
    #>  Chi-squared test for given probabilities
    #>
    #> data:  table(dat$party)
    #> X-squared = 252.68, df = 2, p-value < 2.2e-16

    dat <- tibble(

      a = factor(c(0,
                   0,
                   1,
                   1,
                   0,
                   0,
                   0,
                   0,
                   0,
                   0,
                   1)),
      b = factor(c(1,
                   1,
                   1,
                   1,
                   1,
                   1,
                   1,
                   0,
                   0,
                   1,
                   0))

    )
    descr(dat, "b")
    #> Warning in (function (x, y = NULL, correct = TRUE, p = rep(1/length(x), : Chi-
    #> squared approximation may be incorrect
    #> Warning in stats::prop.test(table(group, var), correct = FALSE): Chi-squared
    #> approximation may be incorrect

Variables | 0 | 1 | Total | p | CI
--- | --- | --- | --- | --- | ---
| (N=3) | (N=8) | (N=11) |  |
a
0 | 2 (67%) | 6 (75%) | 8 (73%) | 0.782chi2 | [-0.7, 0.53]PWa
1 | 1 (33%) | 2 (25%) | 3 (27%) |  |
chi2 Pearson’s chi-squared test
PWa CI for difference in proportions derived from a normal (“Wald”) approximation

SAS Output

The SAS System

The FREQ Procedure

gender | Frequency | Percent | Cumulative Frequency | Cumulative Percent
--- | --- | --- | --- | ---
F | 1557 | 56.47 | 1557 | 56.47
M | 1200 | 43.53 | 2757 | 100.00

Chi-Square Test for Equal Proportions
Chi-Square | 46.2274
DF | 1
Pr > ChiSq | <.0001

Sample Size = 2757

party | Frequency | Percent | Cumulative Frequency | Cumulative Percent
--- | --- | --- | --- | ---
Democrat | 1246 | 45.19 | 1246 | 45.19
Independent | 566 | 20.53 | 1812 | 65.72
Republican | 945 | 34.28 | 2757 | 100.00

Chi-Square Test for Equal Proportions
Chi-Square | 252.6812
DF | 2
Pr > ChiSq | <.0001

Sample Size = 2757

Frequency
Percent
Row Pct
Col Pct
Table of gender by party
gender | party
--- | ---
Democrat | Independent | Republican | Total
F |
762
27.64
48.94
61.16
327
11.86
21.00
57.77
468
16.97
30.06
49.52
1557
56.47
M |
484
17.56
40.33
38.84
239
8.67
19.92
42.23
477
17.30
39.75
50.48
1200
43.53
Total |
1246
45.19
566
20.53
945
34.28
2757
100.00

Statistics for Table of gender by party

Statistic | DF | Value | Prob
--- | --- | --- | ---
Chi-Square | 2 | 30.0701 | <.0001
Likelihood Ratio Chi-Square | 2 | 30.0167 | <.0001
Mantel-Haenszel Chi-Square | 1 | 28.9797 | <.0001
Phi Coefficient |  | 0.1044 |
Contingency Coefficient |  | 0.1039 |
Cramer's V |  | 0.1044 |

Sample Size = 2757

The SAS System

The FREQ Procedure

Frequency
Percent
Row Pct
Col Pct
Table of a by b
a | b
--- | ---
0 | 1 | Total
0 |
2
18.18
25.00
66.67
6
54.55
75.00
75.00
8
72.73
1 |
1
9.09
33.33
33.33
2
18.18
66.67
25.00
3
27.27
Total |
3
27.27
8
72.73
11
100.00

Statistics for Table of a by b

Statistic | DF | Value | Prob
--- | --- | --- | ---
Chi-Square | 1 | 0.0764 | 0.7823
Likelihood Ratio Chi-Square | 1 | 0.0745 | 0.7849
Continuity Adj. Chi-Square | 1 | 0.0000 | 1.0000
Mantel-Haenszel Chi-Square | 1 | 0.0694 | 0.7921
Phi Coefficient |  | -0.0833 |
Contingency Coefficient |  | 0.0830 |
Cramer's V |  | -0.0833 |
WARNING: 75% of the cells have expected counts less than 5. Chi-Square may not be a valid test.

Fisher's Exact Test
Cell (1,1) Frequency (F) | 2
Left-sided Pr <= F | 0.6606
Right-sided Pr >= F | 0.8485
Table Probability (P) | 0.5091
Two-sided Pr <= P | 1.0000

Sample Size = 11

# t-test

Dataset origin: `?t.test`, which references `?sleep` (accessed on R-version 4.0.3).

    dat <- sleep[, c("extra", "group")]

    descr(dat[, "extra"])

Variables | Total | p
--- | --- | ---
| (N=20) |
value
N | 20 | 0.003tt1
mean | 1.5 |
sd | 2 |
median | 0.95 |
Q1 - Q3 | -0.05 – 3.4 |
min - max | -1.6 – 5.5 |
tt1 Student’s one-sample t-test

    descr(dat, "group")

Variables | 1 | 2 | Total | p | CI
--- | --- | --- | --- | --- | ---
| (N=10) | (N=10) | (N=20) |  |
extra
N | 10 | 10 | 20 | 0.079tt2 | [-3.4, 0.21]t
mean | 0.75 | 2.3 | 1.5 |  |
sd | 1.8 | 2 | 2 |  |
median | 0.35 | 1.8 | 0.95 |  |
Q1 - Q3 | -0.2 – 2 | 0.8 – 4.4 | -0.05 – 3.4 |  |
min - max | -1.6 – 3.7 | -0.1 – 5.5 | -1.6 – 5.5 |  |
tt2 Welch’s two-sample t-test
t CI for difference in means derived from the t-distribution

    descr(dat, "group", test_options = list(paired=TRUE, indices=rep(1:10, 2)))
    #> You specified paired tests and did not explicitly
    #> specify format_options$print_Total. print_Total is set to FALSE.

Variables | 1 | 2 | p | CI
--- | --- | --- | --- | ---
| (N=10) | (N=10) |  |
extra
N | 10 | 10 | 0.003tpar | [-2.5, -0.7]t
mean | 0.75 | 2.3 |  |
sd | 1.8 | 2 |  |
median | 0.35 | 1.8 |  |
Q1 - Q3 | -0.2 – 2 | 0.8 – 4.4 |  |
min - max | -1.6 – 3.7 | -0.1 – 5.5 |  |
tpar Student’s paired t-test
t CI for difference in means derived from the t-distribution

SAS Output

The SAS System

The UNIVARIATE Procedure
Variable: extra

Moments
N | 20 | Sum Weights | 20
Mean | 1.54 | Sum Observations | 30.8
Std Deviation | 2.01791972 | Variance | 4.072
Skewness | 0.45185739 | Kurtosis | -0.7747436
Uncorrected SS | 124.8 | Corrected SS | 77.368
Coeff Variation | 131.033748 | Std Error Mean | 0.45122057

Basic Statistical Measures
Location | Variability
--- | ---
Mean | 1.54000 | Std Deviation | 2.01792
Median | 0.95000 | Variance | 4.07200
Mode | -0.10000 | Range | 7.10000
|  | Interquartile Range | 3.45000

Note: The mode displayed is the smallest of 3 modes with a count of 2.

Tests for Location: Mu0=0
Test | Statistic | p Value
--- | --- | ---
Student's t | t | 3.412965 | Pr > |t| | 0.0029
Sign | M | 4.5 | Pr >= |M| | 0.0636
Signed Rank | S | 67.5 | Pr >= |S| | 0.0048

Quantiles (Definition 5)
Level | Quantile
--- | ---
100% Max | 5.50
99% | 5.50
95% | 5.05
90% | 4.50
75% Q3 | 3.40
50% Median | 0.95
25% Q1 | -0.05
10% | -0.70
5% | -1.40
1% | -1.60
0% Min | -1.60

Extreme Observations
Lowest | Highest
--- | ---
Value | Obs | Value | Obs
-1.6 | 2 | 3.4 | 20
-1.2 | 4 | 3.7 | 7
-0.2 | 3 | 4.4 | 16
-0.1 | 15 | 4.6 | 19
-0.1 | 5 | 5.5 | 17

The SAS System

The TTEST Procedure
Variable: extra

group | Method | N | Mean | Std Dev | Std Err | Minimum | Maximum
--- | --- | --- | --- | --- | --- | --- | ---
1 |  | 10 | 0.7500 | 1.7890 | 0.5657 | -1.6000 | 3.7000
2 |  | 10 | 2.3300 | 2.0022 | 0.6332 | -0.1000 | 5.5000
Diff (1-2) | Pooled |  | -1.5800 | 1.8986 | 0.8491 |  |
Diff (1-2) | Satterthwaite |  | -1.5800 |  | 0.8491 |  |

group | Method | Mean | 95% CL Mean | Std Dev | 95% CL Std Dev
--- | --- | --- | --- | --- | ---
1 |  | 0.7500 | -0.5298 | 2.0298 | 1.7890 | 1.2305 | 3.2660
2 |  | 2.3300 | 0.8977 | 3.7623 | 2.0022 | 1.3772 | 3.6553
Diff (1-2) | Pooled | -1.5800 | -3.3639 | 0.2039 | 1.8986 | 1.4346 | 2.8077
Diff (1-2) | Satterthwaite | -1.5800 | -3.3655 | 0.2055 |  |  |

Method | Variances | DF | t Value | Pr > |t|
--- | --- | --- | --- | ---
Pooled | Equal | 18 | -1.86 | 0.0792
Satterthwaite | Unequal | 17.776 | -1.86 | 0.0794

Equality of Variances
Method | Num DF | Den DF | F Value | Pr > F
--- | --- | --- | --- | ---
Folded F | 9 | 9 | 1.25 | 0.7427

# F-test

Dataset origin: Modified version of `?datasets::npk`. `npk` is used in `?aov` (accessed on R-version 4.0.3).

    dat <- data.frame(
      y = npk$yield,
      P = ordered(gl(3, 24)),
      N = ordered(gl(3, 1, 24))
    )

    descr(dat[, c("y", "P")], "P")

Variables | 1 | 2 | 3 | Total | p
--- | --- | --- | --- | --- | ---
| (N=24) | (N=24) | (N=24) | (N=72) |
y
N | 24 | 24 | 24 | 72 | >0.999F
mean | 55 | 55 | 55 | 55 |
sd | 6.2 | 6.2 | 6.2 | 6.1 |
median | 56 | 56 | 56 | 56 |
Q1 - Q3 | 50 – 59 | 50 – 59 | 50 – 59 | 50 – 59 |
min - max | 44 – 70 | 44 – 70 | 44 – 70 | 44 – 70 |
F F-test (ANOVA)

    descr(dat[, c("y", "N")], "N")

Variables | 1 | 2 | 3 | Total | p
--- | --- | --- | --- | --- | ---
| (N=24) | (N=24) | (N=24) | (N=72) |
y
N | 24 | 24 | 24 | 72 | 0.346F
mean | 54 | 56 | 54 | 55 |
sd | 5.6 | 6.9 | 5.6 | 6.1 |
median | 56 | 55 | 56 | 56 |
Q1 - Q3 | 50 – 58 | 50 – 61 | 49 – 58 | 50 – 59 |
min - max | 44 – 62 | 49 – 70 | 46 – 63 | 44 – 70 |
F F-test (ANOVA)

SAS Output

The SAS System

The ANOVA Procedure

Class Level Information
Class | Levels | Values
--- | --- | ---
P | 3 | 1 2 3

Number of Observations Read | 72
Number of Observations Used | 72

The SAS System

The ANOVA Procedure
Dependent Variable: y

Source | DF | Sum of Squares | Mean Square | F Value | Pr > F
--- | --- | --- | --- | --- | ---
Model | 2 | 0.000000 | 0.000000 | 0.00 | 1.0000
Error | 69 | 2629.095000 | 38.102826 |  |
Corrected Total | 71 | 2629.095000 |  |  |

R-Square | Coeff Var | Root MSE | y Mean
--- | --- | --- | ---
0.000000 | 11.24874 | 6.172749 | 54.87500

Source | DF | Anova SS | Mean Square | F Value | Pr > F
--- | --- | --- | --- | --- | ---
P | 2 | 0 | 0 | 0.00 | 1.0000

The SAS System

The ANOVA Procedure

Class Level Information
Class | Levels | Values
--- | --- | ---
N | 3 | 1 2 3

Number of Observations Read | 72
Number of Observations Used | 72

The SAS System

The ANOVA Procedure
Dependent Variable: y

Source | DF | Sum of Squares | Mean Square | F Value | Pr > F
--- | --- | --- | --- | --- | ---
Model | 2 | 79.702500 | 39.851250 | 1.08 | 0.3457
Error | 69 | 2549.392500 | 36.947717 |  |
Corrected Total | 71 | 2629.095000 |  |  |

R-Square | Coeff Var | Root MSE | y Mean
--- | --- | --- | ---
0.030316 | 11.07693 | 6.078463 | 54.87500

Source | DF | Anova SS | Mean Square | F Value | Pr > F
--- | --- | --- | --- | --- | ---
N | 2 | 79.70250000 | 39.85125000 | 1.08 | 0.3457

# Mixed model ANOVA

Dataset origin: Modified version of `?nlme::Orthodont`. `Orthodont` is used in `?lme` (accessed on R-version 4.0.3).

    dat <- nlme::Orthodont
    dat2 <- nlme::Orthodont[1:64,]
    dat2$Sex <- "Divers"
    dat2$distance <- dat2$distance + c(rep(0.1*c(1,4,3,2), 10), 0.1*rep(c(0.4,2,1.5, 2.3), 6) )
    dat2$Subject <- str_replace_all(dat2$Subject, "M", "D")
    dat <- bind_rows(dat, dat2)
    dat <- as_tibble(dat)

    descr(dat[, c("Sex", "distance")], "Sex", test_options = list(paired=TRUE, indices=dat$Subject))
    #> You specified paired tests and did not explicitly
    #> specify format_options$print_Total. print_Total is set to FALSE.

Variables | Male | Female | Divers | p
--- | --- | --- | --- | ---
| (N=64) | (N=44) | (N=64) |
distance
N | 64 | 44 | 64 | 0.003MiAn
mean | 25 | 23 | 25 |
sd | 2.9 | 2.4 | 2.9 |
median | 25 | 23 | 25 |
Q1 - Q3 | 23 – 26 | 21 – 24 | 23 – 27 |
min - max | 17 – 32 | 16 – 28 | 17 – 32 |
MiAn Mixed model ANOVA

SAS Output

The SAS System

The Mixed Procedure

Model Information
Data Set | WORK.RDATA
Dependent Variable | distance
Covariance Structure | Variance Components
Subject Effect | Subject
Estimation Method | REML
Residual Variance Method | Profile
Fixed Effects SE Method | Model-Based
Degrees of Freedom Method | Satterthwaite

Class Level Information
Class | Levels | Values
--- | --- | ---
Sex | 3 | Divers Female Male
Subject | 43 | D01 D02 D03 D04 D05 D06 D07 D08 D09 D10 D11 D12 D13 D14 D15 D16 F01 F02 F03 F04 F05 F06 F07 F08 F09 F10 F11 M01 M02 M03 M04 M05 M06 M07 M08 M09 M10 M11 M12 M13 M14 M15 M16

Dimensions
Covariance Parameters | 2
Columns in X | 4
Columns in Z per Subject | 1
Subjects | 43
Max Obs per Subject | 4

Number of Observations
Number of Observations Read | 172
Number of Observations Used | 172
Number of Observations Not Used | 0

Iteration History
Iteration | Evaluations | -2 Res Log Like | Criterion
--- | --- | --- | ---
0 | 1 | 838.60158118 |
1 | 1 | 823.17375628 | 0.00000000

Convergence criteria met.

Covariance Parameter Estimates
Cov Parm | Subject | Estimate
--- | --- | ---
Intercept | Subject | 2.2123
Residual |  | 5.6941

Fit Statistics
-2 Res Log Likelihood | 823.2
AIC (Smaller is Better) | 827.2
AICC (Smaller is Better) | 827.2
BIC (Smaller is Better) | 830.7

Type 3 Tests of Fixed Effects
Effect | Num DF | Den DF | F Value | Pr > F
--- | --- | --- | --- | ---
Sex | 2 | 40 | 6.69 | 0.0031

# Boschloos test

Dataset origin: selfmade.

DescrTab2 uses the exact2x2::boschloo with option `tsmethod=central` to calculate p-values. There is no comparison for this option readily available.

    dat <- tibble(gender=factor(c("M", "M", "M", "M", "M", "M", "F", "F", "F", "F", "F")),
                  party=factor(c("A", "A", "B", "B", "B", "B", "A", "A", "A", "B", "B")))
    descr(dat, "gender", test_options = c(exact=TRUE))

Variables | F | M | Total | p | CI
--- | --- | --- | --- | --- | ---
| (N=5) | (N=6) | (N=11) |  |
party
A | 3 (60%) | 2 (33%) | 5 (45%) | 0.491Bolo | [-0.76, 0.37]PUnc
B | 2 (40%) | 4 (67%) | 6 (55%) |  |
Bolo Boschloo’s test
PUnc CI for difference in proportions derived from an unconditional exact test

    exact2x2::boschloo(3, 5, 2, 6, tsmethod="central")
    #>
    #>  Boschloo's test
    #>
    #> data:  x1/n1=(3/5) and x2/n2= (2/6)
    #> proportion 1 = 0.6, proportion 2 = 0.33333, p-value = 0.4909
    #> alternative hypothesis: true p2(1-p1)/[p1(1-p2)] is less than 1
    #>  percent confidence interval:
    #>  NA NA
    #> sample estimates:
    #> p2(1-p1)/[p1(1-p2)]
    #>           0.3333333

However, we can compare the exact2x2::boschloo with `tsmethod=minlike` to `Exact::exact.test`:

    exact2x2::boschloo(3, 5, 2, 6, tsmethod="minlike")
    #>
    #>  Boschloo's test
    #>
    #> data:  x1/n1=(3/5) and x2/n2= (2/6)
    #> proportion 1 = 0.6, proportion 2 = 0.33333, p-value = 0.5488
    #> alternative hypothesis: true p2(1-p1)/[p1(1-p2)] is not equal to 1
    #> 95 percent confidence interval:
    #>  NA NA
    #> sample estimates:
    #> p2(1-p1)/[p1(1-p2)]
    #>           0.3333333
    Exact::exact.test(table(dat), method="boschloo", to.plot = FALSE)
    #>
    #>  Boschloo's Exact Test
    #>
    #> data:  3 out of 5 vs. 2 out of 6
    #> test statistic = 0.5671, first sample size = 5, second sample size = 6,
    #> p-value = 0.5488
    #> alternative hypothesis: true difference in proportion is not equal to 0
    #> sample estimates:
    #> difference in proportion
    #>                0.2666667