r3dtable: Simulations for generating three-way contingency tables

Description Usage Arguments Value Note Author(s) References Examples

View source: R/r3dtable.R

Description

It allows 1) the generation of nboots=1000 randomly tables where the row, column, tube probabilities can be prescribed by the analyst. By default, they are uniform.

Usage

1
2
r3dtable(I = 3, J = 3, K = 3, pi=rep(1/I,I), pj=rep(1/J,J), pk=rep(1/K,K), nboots = 1000, 
nran = 10000, digits = 3)

Arguments

I

The number I is set equal to the rows of the input table X.

J

The number J is set equal to the columns of the input table X.

K

The number K is set equal to the tubes of the input three-way table X.

pi

The prescribed row probabilities. By default, they are homogeneous.

pj

The prescribed column probabilities. By default, they are homogeneous.

pk

The prescribed tube probabilities. By default, they are homogeneous.

nboots

The number of the random three-way tables that you want to generate.

nran

The total number of individuals of each generated three-way table.

digits

The minimum number of decimal places, digits, used for displaying the numerical summaries of the analysis. By default, digits = 3.

Value

XB

The nboots=1000 randomly generated three-way tables.

XB[[i]]$pi

The row, prescribed probabilities of the i.th randomly generated three-way table.

XB[[i]]$pj

The column, prescribed probabilities of the i.th randomly generated three-way table.

XB[[i]]$pk

The tube, prescribed probabilities of the i.th randomly generated three-way table.

margI

The row observed margins of the randomly generated three-way table.

margJ

The column observed margins of the randomly generated three-way table.

margK

The tube observed margins of the randomly generated three-way table.

Note

This function allows the generation of random tables under the complete independence with different theoretical probabilities.

Author(s)

Lombardo R, Takane Y, Beh EJ

References

Beh EJ and Lombardo R (2014) Correspondence Analysis: Theory, Practice and New Strategies. John Wiley & Sons. Lancaster H O (1951) Complex contingency tables treated by the partition of the chi-square. Journal of Royal Statistical Society, Series B, 13, 242-249.
Loisel S and Takane Y (2016) Partitions of Pearson's chi-square ststistic for frequency tables: A comprehensive account. Computational Statistics, 31, 1429-1452.

Examples

1
2
r3dtable(I = 3, J = 3, K = 3, pi=rep(1/3,3), pj=rep(1/3,3), pk=rep(1/3,3), 
nboots = 10, nran = 1000, digits = 3) 

Example output

Loading required package: tools
$XB
$XB[[1]]
$XB[[1]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   38   29   42
[2,]   32   43   36
[3,]   31   42   39

, , 2

     [,1] [,2] [,3]
[1,]   44   24   29
[2,]   49   41   30
[3,]   36   34   45

, , 3

     [,1] [,2] [,3]
[1,]   35   44   42
[2,]   49   31   39
[3,]   44   19   33


$XB[[1]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[1]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[1]]$pk
[1] 0.3333333 0.3333333 0.3333333


$XB[[2]]
$XB[[2]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   45   34   36
[2,]   27   38   45
[3,]   28   31   45

, , 2

     [,1] [,2] [,3]
[1,]   47   40   43
[2,]   32   39   36
[3,]   30   34   41

, , 3

     [,1] [,2] [,3]
[1,]   40   47   37
[2,]   46   27   34
[3,]   38   32   28


$XB[[2]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[2]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[2]]$pk
[1] 0.3333333 0.3333333 0.3333333


$XB[[3]]
$XB[[3]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   43   34   36
[2,]   43   28   34
[3,]   39   34   40

, , 2

     [,1] [,2] [,3]
[1,]   42   30   40
[2,]   25   50   36
[3,]   36   32   44

, , 3

     [,1] [,2] [,3]
[1,]   40   37   26
[2,]   30   43   32
[3,]   41   44   41


$XB[[3]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[3]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[3]]$pk
[1] 0.3333333 0.3333333 0.3333333


$XB[[4]]
$XB[[4]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   29   45   31
[2,]   39   41   34
[3,]   35   28   36

, , 2

     [,1] [,2] [,3]
[1,]   40   29   34
[2,]   46   32   47
[3,]   35   36   33

, , 3

     [,1] [,2] [,3]
[1,]   48   42   39
[2,]   35   30   29
[3,]   43   40   44


$XB[[4]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[4]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[4]]$pk
[1] 0.3333333 0.3333333 0.3333333


$XB[[5]]
$XB[[5]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   40   38   36
[2,]   33   34   35
[3,]   51   37   36

, , 2

     [,1] [,2] [,3]
[1,]   38   37   45
[2,]   43   30   28
[3,]   38   31   21

, , 3

     [,1] [,2] [,3]
[1,]   28   43   38
[2,]   40   49   39
[3,]   31   41   40


$XB[[5]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[5]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[5]]$pk
[1] 0.3333333 0.3333333 0.3333333


$XB[[6]]
$XB[[6]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   33   34   30
[2,]   38   35   45
[3,]   38   46   32

, , 2

     [,1] [,2] [,3]
[1,]   37   27   39
[2,]   37   38   35
[3,]   42   20   37

, , 3

     [,1] [,2] [,3]
[1,]   40   47   30
[2,]   38   30   47
[3,]   36   43   46


$XB[[6]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[6]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[6]]$pk
[1] 0.3333333 0.3333333 0.3333333


$XB[[7]]
$XB[[7]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   41   35   33
[2,]   38   42   33
[3,]   41   41   39

, , 2

     [,1] [,2] [,3]
[1,]   31   35   45
[2,]   42   24   36
[3,]   45   39   31

, , 3

     [,1] [,2] [,3]
[1,]   31   32   32
[2,]   33   57   41
[3,]   38   30   35


$XB[[7]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[7]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[7]]$pk
[1] 0.3333333 0.3333333 0.3333333


$XB[[8]]
$XB[[8]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   28   40   38
[2,]   32   31   37
[3,]   36   47   46

, , 2

     [,1] [,2] [,3]
[1,]   48   32   33
[2,]   46   42   46
[3,]   30   37   35

, , 3

     [,1] [,2] [,3]
[1,]   46   34   40
[2,]   41   41   30
[3,]   24   25   35


$XB[[8]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[8]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[8]]$pk
[1] 0.3333333 0.3333333 0.3333333


$XB[[9]]
$XB[[9]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   39   37   33
[2,]   30   36   47
[3,]   40   29   29

, , 2

     [,1] [,2] [,3]
[1,]   51   35   31
[2,]   36   44   29
[3,]   36   42   45

, , 3

     [,1] [,2] [,3]
[1,]   34   37   39
[2,]   36   30   40
[3,]   36   41   38


$XB[[9]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[9]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[9]]$pk
[1] 0.3333333 0.3333333 0.3333333


$XB[[10]]
$XB[[10]]$Fijk
, , 1

     [,1] [,2] [,3]
[1,]   41   38   34
[2,]   33   35   41
[3,]   52   33   37

, , 2

     [,1] [,2] [,3]
[1,]   46   43   32
[2,]   38   37   33
[3,]   38   42   38

, , 3

     [,1] [,2] [,3]
[1,]   35   32   35
[2,]   32   29   37
[3,]   45   36   28


$XB[[10]]$pi
[1] 0.3333333 0.3333333 0.3333333

$XB[[10]]$pj
[1] 0.3333333 0.3333333 0.3333333

$XB[[10]]$pk
[1] 0.3333333 0.3333333 0.3333333



$margI
$margI[[1]]
[1] 0.327 0.350 0.323

$margI[[2]]
[1] 0.369 0.324 0.307

$margI[[3]]
[1] 0.328 0.321 0.351

$margI[[4]]
[1] 0.337 0.333 0.330

$margI[[5]]
[1] 0.343 0.331 0.326

$margI[[6]]
[1] 0.317 0.343 0.340

$margI[[7]]
[1] 0.315 0.346 0.339

$margI[[8]]
[1] 0.339 0.346 0.315

$margI[[9]]
[1] 0.336 0.328 0.336

$margI[[10]]
[1] 0.336 0.315 0.349


$margJ
$margJ[[1]]
[1] 0.358 0.307 0.335

$margJ[[2]]
[1] 0.333 0.322 0.345

$margJ[[3]]
[1] 0.339 0.332 0.329

$margJ[[4]]
[1] 0.350 0.323 0.327

$margJ[[5]]
[1] 0.342 0.340 0.318

$margJ[[6]]
[1] 0.339 0.320 0.341

$margJ[[7]]
[1] 0.340 0.335 0.325

$margJ[[8]]
[1] 0.331 0.329 0.340

$margJ[[9]]
[1] 0.338 0.331 0.331

$margJ[[10]]
[1] 0.360 0.325 0.315


$margK
$margK[[1]]
[1] 0.332 0.332 0.336

$margK[[2]]
[1] 0.329 0.342 0.329

$margK[[3]]
[1] 0.331 0.335 0.334

$margK[[4]]
[1] 0.318 0.332 0.350

$margK[[5]]
[1] 0.340 0.311 0.349

$margK[[6]]
[1] 0.331 0.312 0.357

$margK[[7]]
[1] 0.343 0.328 0.329

$margK[[8]]
[1] 0.335 0.349 0.316

$margK[[9]]
[1] 0.320 0.349 0.331

$margK[[10]]
[1] 0.344 0.347 0.309

chi2x3way documentation built on May 2, 2019, 4:16 a.m.