stats: Classical estimates for tables

Description Usage Arguments Details Value Author(s) References Examples

View source: R/stats.R

Description

Some standard/classical (non-compositional) statistics

Usage

1
2
3
4
5
6
stats(
  x,
  margins = NULL,
  statistics = c("phi", "cramer", "chisq", "yates"),
  maggr = mean
)

Arguments

x

a data.frame, matrix or table

margins

margins

statistics

statistics of interest

maggr

a function for calculating the mean margins of a table, default is the arithmetic mean

Details

statistics ‘phi’ is the values of the table divided by the product of margins. ‘cramer’ normalize these values according to the dimension of the table. ‘chisq’ are the expected values according to Pearson while ‘yates’ according to Yates.

For the maggr function argument, arithmetic means (mean) should be chosen to obtain the classical results. Any other user-provided functions should be take with care since the classical estimations relies on the arithmetic mean.

Value

List containing all statistics

Author(s)

Matthias Templ

References

Egozcue, J.J., Pawlowsky-Glahn, V., Templ, M., Hron, K. (2015) Independence in contingency tables using simplicial geometry. Communications in Statistics - Theory and Methods, 44 (18), 3978–3996.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(precipitation) 
tab1 <- indTab(precipitation)
stats(precipitation)
stats(precipitation, statistics = "cramer")
stats(precipitation, statistics = "chisq")
stats(precipitation, statistics = "yates")

## take with care 
## (the provided statistics are not designed for that case):
stats(precipitation, statistics = "chisq", maggr = gmean)

Example output

Loading required package: robustbase
Loading required package: ggplot2
Loading required package: data.table
Loading required package: e1071
Loading required package: pls

Attaching package: 'pls'

The following object is masked from 'package:stats':

    loadings

sROC 0.1-2 loaded

Attaching package: 'robCompositions'

The following object is masked from 'package:robustbase':

    alcohol

          spring      summer     autumn      winter
30   0.011477143 0.016502131 0.01242841 0.009370268
60   0.016959419 0.007930214 0.01086270 0.012706044
125  0.013801646 0.010077609 0.01173410 0.013242376
250  0.015127419 0.005180031 0.01009488 0.018209008
500  0.010658729 0.005657531 0.01297609 0.018945993
1000 0.009055118 0.002577320 0.01642036 0.018750000
          spring      summer      autumn      winter
30   0.006626332 0.009527510 0.007175549 0.005409926
60   0.009791525 0.004578511 0.006271583 0.007335838
125  0.007968384 0.005818310 0.006774686 0.007645489
250  0.008733820 0.002990693 0.005828283 0.010512976
500  0.006153820 0.003266377 0.007491749 0.010938474
1000 0.005227975 0.001488016 0.009480300 0.010825318
        spring    summer    autumn    winter
30   153.01576 133.04755 167.37663 144.00181
60    56.48849  49.82127  62.23317  53.27729
125   60.53416  53.10329  66.41816  56.87925
250   64.55863  56.99054  71.04682  60.43666
500   58.29003  51.19979  63.67261  54.28105
1000  49.94205  43.93191  54.27542  46.44123
        spring    summer    autumn    winter
30   153.01253 133.04385 167.37368 143.99837
60    56.47979  49.81131  62.22522  53.26803
125   60.52601  53.09396  66.41072  56.87058
250   64.55100  56.98181  71.03985  60.42854
500   58.28154  51.19008  63.66485  54.27201
1000  49.93213  43.92056  54.26636  46.43066
        spring   summer    autumn    winter
30   126.17302 78.91394 136.28536 128.97084
60    45.41726 29.33229  49.59548  46.62716
125   49.72864 31.77171  53.95719  50.75981
250   50.25814 32.64018  54.81904  51.07488
500   45.67802 29.40453  49.21792  46.03362
1000  35.67960 23.15341  38.02341  35.79030

robCompositions documentation built on Jan. 13, 2021, 10:07 p.m.