Skip to contents

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::tibble(diff = x-y)

descr(dat_wilcox.test_1_sample, test_options = c(nonparametric=TRUE))
Variable
Total
p
(N=9)
diff
N 9 0.039Wil1
mean 0.432
sd 0.427
median 0.49
Q1 - Q3 0.01 – 0.62
min - max -0.147 – 1.02
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::tibble(var=c(x,y), group=group)

descr(dat_wilcox.test_2_sample, "group", test_options = c(nonparametric=TRUE))
Variable
Trt
Ctrl
Total
p
(N=10) (N=5) (N=15)
var
N 10 5 15 0.254MWU
mean 1.31 0.976 1.2
sd 0.441 0.197 0.404
median 1.42 0.9 1.15
Q1 - Q3 0.83 – 1.64 0.88 – 1.15 0.83 – 1.46
min - max 0.73 – 1.91 0.74 – 1.21 0.73 – 1.91
MWU Mann-Whitney’s U test

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::tibble(var=c(x,y,z), group=group)

descr(dat_kruskal.test, "group", test_options = c(nonparametric=TRUE)) 
Variable
Trt
Ctrl
Placebo
Total
p
(N=5) (N=4) (N=5) (N=14)
var
N 5 4 5 14 0.680KW
mean 2.84 3.23 2.82 2.94
sd 0.288 0.793 0.736 0.61
median 2.9 3.25 2.8 2.85
Q1 - Q3 2.6 – 3 2.55 – 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
#> Warning: `includeHTML()` was provided a `path` that appears to be a complete HTML document.
#>  Path: /home/runner/work/DescrTab2/DescrTab2/vignettes/validation_report/kruskal.test/kruskal.test_example_1.html
#>  Use `tags$iframe()` to include an HTML document. You can either ensure `path` is accessible in your app or document (see e.g. `shiny::addResourcePath()`) and pass the relative path to the `src` argument. Or you can read the contents of `path` and pass the contents to `srcdoc`.
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::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.
Variable
Round Out
Narrow Angle
Wide Angle
p
(N=22) (N=22) (N=22)
var
N 22 22 22 0.004Frie
mean 5.54 5.53 5.46
sd 0.272 0.26 0.273
median 5.5 5.53 5.45
Q1 - Q3 5.4 – 5.65 5.45 – 5.6 5.35 – 5.55
min - max 5.05 – 6.3 5 – 6.3 4.95 – 6.25
Frie Friedman test
#> Warning: `includeHTML()` was provided a `path` that appears to be a complete HTML document.
#>  Path: /home/runner/work/DescrTab2/DescrTab2/vignettes/validation_report/friedman.test/friedman.test_example_1.html
#>  Use `tags$iframe()` to include an HTML document. You can either ensure `path` is accessible in your app or document (see e.g. `shiny::addResourcePath()`) and pass the relative path to the `src` argument. Or you can read the contents of `path` and pass the contents to `srcdoc`.
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] |> dplyr::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.
Variable
A
B
C
p
(N=46) (N=46) (N=46)
resp
F 28 (60.9%) 28 (60.9%) 16 (34.8%) 0.014CocQ
U 18 (39.1%) 18 (39.1%) 30 (65.2%)
CocQ Cochran’s Q test
#> Warning: `includeHTML()` was provided a `path` that appears to be a complete HTML document.
#>  Path: /home/runner/work/DescrTab2/DescrTab2/vignettes/validation_report/CochraneQTest/CochraneQTest_example_1.html
#>  Use `tags$iframe()` to include an HTML document. You can either ensure `path` is accessible in your app or document (see e.g. `shiny::addResourcePath()`) and pass the relative path to the `src` argument. Or you can read the contents of `path` and pass the contents to `srcdoc`.
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.
Variable
first
second
p
(N=1600) (N=1600)
var
Approve 944 (59.0%) 880 (55.0%) McN
Disapprove 656 (41.0%) 720 (45.0%)
McN McNemar’s test
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.
Variable
first
second
p
(N=1600) (N=1600)
var
Approve 944 (59.0%) 880 (55.0%) eMcN
Disapprove 656 (41.0%) 720 (45.0%)
eMcN 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
#> Warning: `includeHTML()` was provided a `path` that appears to be a complete HTML document.
#>  Path: /home/runner/work/DescrTab2/DescrTab2/vignettes/validation_report/mcnemar.test/mcnemar.test_example_1.html
#>  Use `tags$iframe()` to include an HTML document. You can either ensure `path` is accessible in your app or document (see e.g. `shiny::addResourcePath()`) and pass the relative path to the `src` argument. Or you can read the contents of `path` and pass the contents to `srcdoc`.
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::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")
Variable
F
M
Total
p
(N=1557) (N=1200) (N=2757)
party
Democrat 762 (48.9%) 484 (40.3%) 1246 (45.2%) chi2
Independent 327 (21.0%) 239 (19.9%) 566 (20.5%)
Republican 468 (30.1%) 477 (39.8%) 945 (34.3%)
chi2 Pearson’s chi-squared test
descr(dat)
Variable
Total
p
(N=2757)
gender
F 1557 (56.5%) chi1
M 1200 (43.5%)
party
Democrat 1246 (45.2%) chi1
Independent 566 (20.5%)
Republican 945 (34.3%)
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::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
Variable
0
1
Total
p
(N=3) (N=8) (N=11)
a
0 2 (66.7%) 6 (75.0%) 8 (72.7%) 0.782chi2
1 1 (33.3%) 2 (25.0%) 3 (27.3%)
chi2 Pearson’s chi-squared test
#> Warning: `includeHTML()` was provided a `path` that appears to be a complete HTML document.
#>  Path: /home/runner/work/DescrTab2/DescrTab2/vignettes/validation_report/chisq.test/chisq.test_example_1.html
#>  Use `tags$iframe()` to include an HTML document. You can either ensure `path` is accessible in your app or document (see e.g. `shiny::addResourcePath()`) and pass the relative path to the `src` argument. Or you can read the contents of `path` and pass the contents to `srcdoc`.
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"]) 
Variable
Total
p
(N=20)
value
N 20 0.003tt1
mean 1.54
sd 2.02
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")
Variable
1
2
Total
p
(N=10) (N=10) (N=20)
extra
N 10 10 20 0.079tt2
mean 0.75 2.33 1.54
sd 1.79 2 2.02
median 0.35 1.75 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
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.
Variable
1
2
p
(N=10) (N=10)
extra
N 10 10 0.003tpar
mean 0.75 2.33
sd 1.79 2
median 0.35 1.75
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
#> Warning: `includeHTML()` was provided a `path` that appears to be a complete HTML document.
#>  Path: /home/runner/work/DescrTab2/DescrTab2/vignettes/validation_report/t.test/t.test_example_1.html
#>  Use `tags$iframe()` to include an HTML document. You can either ensure `path` is accessible in your app or document (see e.g. `shiny::addResourcePath()`) and pass the relative path to the `src` argument. Or you can read the contents of `path` and pass the contents to `srcdoc`.
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") 
Variable
1
2
3
Total
p
(N=24) (N=24) (N=24) (N=72)
y
N 24 24 24 72 >0.999F
mean 54.9 54.9 54.9 54.9
sd 6.17 6.17 6.17 6.09
median 55.6 55.6 55.6 55.6
Q1 - Q3 49.6 – 58.8 49.6 – 58.8 49.6 – 58.8 49.6 – 58.8
min - max 44.2 – 69.5 44.2 – 69.5 44.2 – 69.5 44.2 – 69.5
F F-test (ANOVA)
descr(dat[, c("y", "N")], "N") 
Variable
1
2
3
Total
p
(N=24) (N=24) (N=24) (N=72)
y
N 24 24 24 72 0.346F
mean 54.1 56.4 54.2 54.9
sd 5.56 6.94 5.63 6.09
median 55.6 54.6 55.5 55.6
Q1 - Q3 49.6 – 58 50.4 – 61.3 49.1 – 57.9 49.6 – 58.8
min - max 44.2 – 62 48.8 – 69.5 45.5 – 62.8 44.2 – 69.5
F F-test (ANOVA)
#> Warning: `includeHTML()` was provided a `path` that appears to be a complete HTML document.
#>  Path: /home/runner/work/DescrTab2/DescrTab2/vignettes/validation_report/aov/aov_example_1.html
#>  Use `tags$iframe()` to include an HTML document. You can either ensure `path` is accessible in your app or document (see e.g. `shiny::addResourcePath()`) and pass the relative path to the `src` argument. Or you can read the contents of `path` and pass the contents to `srcdoc`.
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 <- stringr::str_replace_all(dat2$Subject, "M", "D")
dat <- dplyr::bind_rows(dat, dat2)
dat <- tibble::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.
Variable
Male
Female
Divers
p
(N=64) (N=44) (N=64)
distance
N 64 44 64 0.003MiAn
mean 25 22.6 25.2
sd 2.9 2.4 2.93
median 24.8 22.8 25
Q1 - Q3 23 – 26.5 21 – 24.2 23.1 – 26.8
min - max 17 – 31.5 16.5 – 28 17 – 31.7
MiAn Mixed model ANOVA
#> Warning: `includeHTML()` was provided a `path` that appears to be a complete HTML document.
#>  Path: /home/runner/work/DescrTab2/DescrTab2/vignettes/validation_report/mixed/mixed_example_1.html
#>  Use `tags$iframe()` to include an HTML document. You can either ensure `path` is accessible in your app or document (see e.g. `shiny::addResourcePath()`) and pass the relative path to the `src` argument. Or you can read the contents of `path` and pass the contents to `srcdoc`.
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::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))
Variable
F
M
Total
p
(N=5) (N=6) (N=11)
party
A 3 (60.0%) 2 (33.3%) 5 (45.5%) 0.491Bolo
B 2 (40.0%) 4 (66.7%) 6 (54.5%)
Bolo Boschloo’s 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