Package 'PSIndependenceTest'

Title: Independence Tests for Two-Way, Three-Way and Four-Way Contingency Tables
Description: Presentation two independence tests for two-way, three-way and four-way contingency tables. These tests are: the modular test and the logarithmic minimum test. For details on this method see: Sulewski (2017) <doi:10.18778/0208-6018.330.04>, Sulewski (2018) <doi:10.1080/02664763.2018.1424122>, Sulewski (2019) <doi:10.2478/bile-2019-0003>, Sulewski (2021) <doi:10.1080/00949655.2021.1908286>.
Authors: Piotr Sulewski [aut, cre]
Maintainer: Piotr Sulewski <[email protected]>
License: GPL-3
Version: 0.0.1
Built: 2024-11-27 06:56:51 UTC
Source: CRAN

Help Index


Two-way contingency table r x c - generation

Description

Generating a two-way contingency table r x c

Usage

GenTab2(pij, n)

Arguments

pij

a numeric matrix with non-negative probability values of the two-way contingency table

n

a sample size

Details

Generating a two-way contingency table r x c using the probability matrix pij. If Ho is true then pij equals 1 / r / c.

Value

The function returns the two-way contingency table r x c

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2016). Moc testów niezależności w tablicy dwudzielczej większej niż 2×2, Przegląd statystyczny 63(2), 190-210

Examples

r = 6; c = 2
GenTab2(array(1 / r / c, dim = c(r, c)), 93)
GenTab2(matrix(c(0.125,0.25,0.25,0.375), nrow=2), 100)

Three-way contingency table r x c x t - generation

Description

Generating a three-way contingency table r x c x t.

Usage

GenTab3(pijt, n)

Arguments

pijt

a numeric matrix with non-negative probability values of the three-way contingency table

n

a sample size

Details

Generating a three-way contingency table r x c x t using the probability matrix pijt. If Ho is true then pijt equals 1 / r / c / t.

Value

The function returns the three-way contingency table r x c x t

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

r = 2; c = 3; t = 4
GenTab3(array(1 / (r * c * t), dim = c(r, c, t)),250)
table = GenTab3(array(0.125, dim = c(2, 2, 2)), 100)
GenTab3(prop.table(table),100)

Four-way contingency table r x c x t x u - generation

Description

Generating a four-way contingency table r x c x t x u.

Usage

GenTab4(pijtu, n)

Arguments

pijtu

a numeric matrix with non-negative probability values of the four-way contingency table

n

a sample size

Details

Generating a four-way contingency table r x c x t x u using the probability matrix pijtu. If Ho is true then pijtu equals 1 / r / c / t / u.

Value

The function returns the four-way contingency table r x c x t x u

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Extension of the information contained in Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

r = 2; c = 2; t = 2; u = 3
GenTab4(array(1 / (r * c * t * u), dim = c(r, c, t, u)),150)
table = GenTab4(array(1/16, dim = c(2, 2, 2, 2)), 200)
GenTab4(prop.table(table),200)

Logarithmic Minimum Test for Independence in Two-Way Contingency Table

Description

Calculates the critical values of the logarithmic minimum test.

Usage

Lms2.cv(nr, nc, n, alfa, B = 10000)

Arguments

nr

a number of rows

nc

a number of columns

n

a sample size

alfa

a significance level

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the logarithmic minimum test for independence in r x c contingency table,

Value

The function returns the critical value of the logarithmic minimum test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2019). The LMS for Testing Independence in Two-way Contingency Tables. Biometrical Letters 56(1), 17-43 #'

Examples

Lms2.cv(2, 2, 40, 0.05, B = 1e3)
Lms2.cv(2, 3, 60, 0.1, B = 1e2)

Logarithmic Minimum Test for Independence in Two-Way Contingency Table

Description

Calculates the p-value of the logarithmic minimum test.

Usage

Lms2.pvalue(stat, nr, nc, n, B = 10000)

Arguments

stat

a logarithmic minimum statistic value

nr

a number of rows

nc

a number of columns

n

a sample size

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The p-value of the logarithmic minimum test for independence in r x c contingency table, data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAWElEQVR42mNgGPTAxsZmJsVqQApgmGw1yApwKcQiT7phRBuCzzCSDSHGMKINIeDNmWQlA2IigKJwIssQkHdINgxfmBBtGDEBS3KCxBc7pMQgMYE5c/AXPwAwSX4lV3pTWwAAAABJRU5ErkJggg==

Value

The function returns the p-value of the logarithmic minimum test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2019). The LMS for Testing Independence in Two-way Contingency Tables. Biometrical Letters 56(1), 17-43

Examples

Lms2.pvalue(Lms2.stat(table1), 2, 2, 40, B = 1e3)
Lms2.pvalue(Lms2.stat(table2), 2, 3, 60, B = 1e2)

Logarithmic Minimum Test for Independence in Two-Way Contingency Table

Description

Calculates the logarithmic minimum statistics (see Sulewski P. (2019)).

Usage

Lms2.stat(nij)

Arguments

nij

a numeric matrix with non-negative values of the two-way contingency table cells

Details

The statistic of the logarithmic minimum test for independence in r x c contingency table, see formula (4) and example 3 in the article.

Value

The function returns the value of the logarithmic minimum test statistic

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2019). The LMS for Testing Independence in Two-way Contingency Tables. Biometrical Letters 56(1), 17-43

Examples

Lms2.stat(table1)
Lms2.stat(table2)

Logarithmic Minimum Test for Independence in Two-Way Contingency Table

Description

Calculates the test statistic and p-value of the logarithmic minimum test.

Usage

Lms2.test(nij, B = 10000)

Arguments

nij

a numeric matrix with non-negative values of the two-way contingency table cells

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The test statistic and p-value of he logarithmic minimum test for independence in r x c contingency table,

Value

The function returns values of the test statistic and p-value of the logarithmic minimum test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2019). The LMS for Testing Independence in Two-way Contingency Tables. Biometrical Letters 56(1), 17-43

Examples

Lms2.test(GenTab2(matrix(1/6, nrow = 2, ncol = 3), 50), B = 1e2)
Lms2.test(table2, B = 1e3)

Logarithmic minimum test for independence in three-way contingency table

Description

Calculates the critical value of the Logarithmic minimum test for independence in three-way contingency table (see Sulewski P. (2018)).

Usage

Lms3.cv(nr, nc, nt, n, alfa, B = 10000)

Arguments

nr

a number of rows

nc

a number of columns

nt

a number of tubes

n

a sample size

alfa

a significance level

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the Logarithmic minimum test for independence in r x c x t contingency table,

Value

The function returns the critical value of the logarithmic minimum test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2021). Logarithmic Minimum Test for Independence in Three Way Con-tingency Table of Small Sizes, Journal of Statistical Computation and Simulation 91(13), 2780-2799

Examples

Lms3.cv(2, 2, 2, 80, 0.05, B = 1e2)
Lms3.cv(2, 2, 2, 80, 0.1, B = 1e3)

Logarithmic minimum test for independence in three-way contingency table

Description

Calculates the p-value of the Logarithmic minimum test for independence in three-way contingency table

Usage

Lms3.pvalue(stat, nr, nc, nt, n, B = 10000)

Arguments

stat

a Logarithmic minimum statistic value

nr

a number of rows

nc

a number of columns

nt

a number of tubes

n

a sample size

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the modular test for independence in r x c x t contingency table,

Value

The function returns the p-value of the logarithmic minimum test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2021). Logarithmic Minimum Test for Independence in Three Way Con-tingency Table of Small Sizes, Journal of Statistical Computation and Simulation 91(13), 2780-2799

Examples

tab1 = GenTab3(array(0.125, dim = c(2, 2, 2)), 100)
Lms3.pvalue(Lms3.stat(tab1), 2, 2, 2, 100, B=1e2)
Lms3.pvalue(Lms3.stat(table4), 2, 2, 2, 80, B = 1e3)

Logarithmic minimum test for independence in three-way contingency table

Description

Calculates the statistic of the Logarithmic minimum test for independence in three-way contingency table (see Sulewski P. (2018)).

Usage

Lms3.stat(nijt)

Arguments

nijt

a numeric matrix with non-negative values of the three-way contingency table cells

Details

The statistic of Logarithmic minimum test for independence in r x c x t contingency table, see formula (6) in the article.

Value

The function returns the value of the logarithmic minimum test statistic.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2021). Logarithmic Minimum Test for Independence in Three Way Con-tingency Table of Small Sizes, Journal of Statistical Computation and Simulation 91(13), 2780-2799

Examples

Lms3.stat(table3)
Lms3.stat(GenTab3(array(1/12, dim=c(2,2,3)), 120))

Logarithmic minimum test for independence in three-way contingency table

Description

Calculates the test statistic and p-value of the Logarithmic minimum test for independence in three-way contingency table

Usage

Lms3.test(nijt, B = 10000)

Arguments

nijt

a numeric matrix with non-negative values of the three-way contingency table cells

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The test statistic and p-value of the Logarithmic minimum test for independence in r x c x t contingency table,

Value

The function returns values of the test statistic and p-value of the logarithmic minimum test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2021). Logarithmic Minimum Test for Independence in Three Way Con-tingency Table of Small Sizes, Journal of Statistical Computation and Simulation 91(13), 2780-2799

Examples

Lms3.test(GenTab3(array(0.125, dim = c(2, 2, 2)), 80), B = 1e2)
Lms3.test(table4, B = 1e3)

Logarithmic minimum test for independence in four-way contingency table

Description

Calculates the critical value of the Logarithmic minimum test for independence in four-way contingency table

Usage

Lms4.cv(nr, nc, nt, nu, n, alfa, B = 10000)

Arguments

nr

a number of rows

nc

a number of columns

nt

a number of tubes

nu

a number of tubes

n

a sample size

alfa

a significance level

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the Logarithmic minimum test for independence in r x c x t contingency table,

Value

The function returns the critical value of the logarithmic minimum test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Extension of the information contained in Sulewski, P. (2021). Logarithmic Minimum Test for Independence in Three Way Con-tingency Table of Small Sizes, Journal of Statistical Computation and Simulation 91(13), 2780-2799

Examples

Lms4.cv(2, 2, 2, 2, 160, 0.05, B = 1e2)
Lms4.cv(2, 2, 2, 2, 160, 0.1, B = 1e3)

Logarithmic minimum test for independence in four-way contingency table

Description

Calculates the p-value of the Logarithmic minimum test for independence in four-way contingency table

Usage

Lms4.pvalue(stat, nr, nc, nt, nu, n, B = 10000)

Arguments

stat

a Logarithmic minimum statistic value

nr

a number of rows

nc

a number of columns

nt

a number of tubes

nu

a number of

n

a sample size

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the modular test for independence in r x c x t x u contingency table,

Value

The function returns the p-value of the logarithmic minimum test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Extension of the information contained in Sulewski, P. (2021). Logarithmic Minimum Test for Independence in Three Way Con-tingency Table of Small Sizes, Journal of Statistical Computation and Simulation 91(13), 2780-2799

Examples

data = GenTab4(array(1/16, dim = c(2, 2, 2, 2)), 160)
Lms4.pvalue(Lms4.stat(data), 2, 2, 2, 2, 160, B=1e3)
Lms4.pvalue(Lms4.stat(table6), 2, 2, 2, 2, 160, B = 1e2)

Logarithmic minimum test for independence in four-way contingency table

Description

Calculates the statistic of the Logarithmic minimum test for independence in four-way contingency table

Usage

Lms4.stat(nijtu)

Arguments

nijtu

a numeric matrix with non-negative values of the four-way contingency table cells

Details

The statistic of Logarithmic minimum test for independence in r x c x t x u contingency table,

Value

The function returns the value of the logarithmic minimum test statistic.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Extension of the information contained in Sulewski, P. (2021). Logarithmic Minimum Test for Independence in Three Way Con-tingency Table of Small Sizes, Journal of Statistical Computation and Simulation 91(13), 2780-2799

Examples

Lms4.stat(GenTab4(array(1/16, dim = c(2, 2, 2, 2)), 160))
Lms4.stat(table5)

Logarithmic minimum test for independence in four-way contingency table

Description

Calculates the test statistic and p-value of the Logarithmic minimum test for independence in four-way contingency table

Usage

Lms4.test(nijtu, B = 10000)

Arguments

nijtu

a numeric matrix with non-negative values of the four-way contingency table cells

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The test statistic and p-value of the Logarithmic minimum test for independence in r x c x t x u contingency table,

Value

The function returns values of the test statistic and p-value of the logarithmic minimum test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Extension of the information contained in Sulewski, P. (2021). Logarithmic Minimum Test for Independence in Three Way Con-tingency Table of Small Sizes, Journal of Statistical Computation and Simulation 91(13), 2780-2799

Examples

Lms4.test(GenTab4(array(1/16, dim = c(2, 2, 2, 2)), 160), B = 1e2)
Lms4.test(table6, B = 1e3)

Modular test for independence in two-way contingency table

Description

Calculates the critical value of the modular test for independence in two-way contingency table see formula (9) in the article.

Usage

Mod2.cv(nr, nc, n, alfa, B = 10000)

Arguments

nr

a number of rows

nc

a number of columns

n

a sample size

alfa

a significance level

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the modular test for independence in r x c contingency table, see formula (2) in the article.

Value

The function returns the critical value of the modular test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2016). Moc testów niezależności w tablicy dwudzielczej większej niż 2×2, Przegląd statystyczny 63(2), 190-210

Examples

Mod2.cv(2, 2, 40, 0.05, B = 1e2)
Mod2.cv(2, 3, 60, 0.1)

Modular test for independence in two-way contingency table

Description

Calculates the p-value of the modular test for independence in two-way contingency table

Usage

Mod2.pvalue(stat, nr, nc, n, B = 10000)

Arguments

stat

a modular statistic value

nr

a number of rows

nc

a number of columns

n

a sample size

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The p-value of the modular test for independence in r x c contingency table,

Value

The function returns the p-value of the modular test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2016). Moc testów niezależności w tablicy dwudzielczej większej niż 2×2, Przegląd statystyczny 63(2), 190-210

Examples

pij=matrix(1/4, nrow = 2, ncol = 2)
tab4=GenTab2(pij, 30)
Mod2.pvalue(Mod2.stat(tab4), 2, 2, 30, B=1e3)
Mod2.pvalue(2.5, 3, 2, 60)

Modular test for independence in two-way contingency table

Description

Calculates the statistic of the modular test for independence in two-way contingency table (see Sulewski P. (2016)).

Usage

Mod2.stat(nij)

Arguments

nij

a numeric matrix with non-negative values of the two-way contingency table cells

Details

The statistic of the modular test for independence in r x c contingency table, see formula (2) in the article.

Value

The function returns the value of the modular test statistic.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2016). Moc testów niezależności w tablicy dwudzielczej większej niż 2×2, Przegląd statystyczny 63(2), 190-210

Examples

tab5=GenTab2(matrix(1/12, nrow = 3, ncol = 4), 60)
Mod2.stat(tab5)
Mod2.stat(table1)

Modular test for independence in two-way contingency table

Description

Calculates the test statistic and p-value of the modular test for independence in two-way contingency table

Usage

Mod2.test(nij, B = 10000)

Arguments

nij

a numeric matrix with non-negative values of the two-way contingency table cells

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The test statistic and p-value of the modular test for independence in r x c contingency table,

Value

The function returns values of the test statistic and p-value of the modular test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2016). Moc testów niezależności w tablicy dwudzielczej większej niż 2×2, Przegląd statystyczny 63(2), 190-210

Examples

pij=matrix(1/4, nrow = 2, ncol = 2)
Mod2.test(GenTab2(pij, 50), B = 1e3)
Mod2.test(table1, B = 1e2)

Modular test for independence in three-way contingency table

Description

Calculates the critical value of the modular test for independence in three-way contingency table (see Sulewski P. (2018)).

Usage

Mod3.cv(nr, nc, nt, n, alfa, B = 10000)

Arguments

nr

a number of rows

nc

a number of columns

nt

a number of tubes

n

a sample size

alfa

a significance level

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the modular test for independence in r x c x t contingency table,

Value

The function returns the critical value of the modular test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

Mod3.cv(2, 2, 2, 80, 0.05, B = 1e2)
Mod3.cv(2, 2, 2, 80, 0.1, B = 1e3)

Modular test for independence in three-way contingency table

Description

Calculates the p-value of the modular test for independence in three-way contingency table

Usage

Mod3.pvalue(stat, nr, nc, nt, n, B = 10000)

Arguments

stat

a modular statistic value

nr

a number of rows

nc

a number of columns

nt

a number of tubes

n

a sample size

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the modular test for independence in r x c x t contingency table,

Value

The function returns the p-value of the modular test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

data = GenTab3(array(0.125, dim = c(2, 2, 2)), 80)
Mod3.pvalue(Mod3.stat(data), 2, 2, 2, 80, B = 1e2)
Mod3.pvalue(Mod3.stat(table4), 2, 2, 2, 80, B = 1e3)

Modular test for independence in three-way contingency table

Description

Calculates the statistic of the modular test for independence in three-way contingency table (see Sulewski P. (2018)).

Usage

Mod3.stat(nijt)

Arguments

nijt

a numeric matrix with non-negative values of the three-way contingency table cells

Details

The statistic of the modular test for independence in r x c x t contingency table, see formula (6) in the article.

Value

The function returns the value of the modular test statistic.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

Mod3.stat(GenTab3(array(0.125, dim = c(2, 2, 2)), 100))
Mod3.stat(table4)

Modular test for independence in three-way contingency table

Description

Calculates the test statistic and p-value of the modular test for independence in three-way contingency table

Usage

Mod3.test(nijt, B = 10000)

Arguments

nijt

a numeric matrix with non-negative values of the three-way contingency table cells

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The test statistic and p-value of the modular test for independence in r x c x t contingency table,

Value

The function returns values of the test statistic and p-value of the modular test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

Mod3.test(GenTab3(array(0.125, dim = c(2, 2, 2)), 80), B = 1e3)
Mod3.test(table4, B = 1e3)

Modular test for independence in four-way contingency table

Description

Calculates the critical value of the modular test for independence in four-way contingency table

Usage

Mod4.cv(nr, nc, nt, nu, n, alfa, B = 10000)

Arguments

nr

a number of rows

nc

a number of columns

nt

a number of tubes

nu

a number of tubes

n

a sample size

alfa

a significance level

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the Logarithmic minimum test for independence in r x c x t contingency table,

Value

The function returns the critical value of the modular test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Extension of the information contained in Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

Mod4.cv(2, 2, 2, 2, 160, 0.05, B = 1e2)
Mod4.cv(2, 2, 2, 2, 160, 0.1, B = 1e3)

MOdular test for independence in four-way contingency table

Description

Calculates the p-value of the modular test for independence in four-way contingency table

Usage

Mod4.pvalue(stat, nr, nc, nt, nu, n, B = 10000)

Arguments

stat

a Logarithmic minimum statistic value

nr

a number of rows

nc

a number of columns

nt

a number of tubes

nu

a number of

n

a sample size

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The Critical value of the modular test for independence in r x c x t x u contingency table,

Value

The function returns the p-value of the modular test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Extension of the information contained in Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

Mod4.pvalue(Mod4.stat(table6), 2, 2, 2, 2, 160, B = 1e2)
Mod4.pvalue(Mod4.stat(table6), 2, 2, 2, 2, 160, B = 1e3)

Modular test for independence in four-way contingency table

Description

Calculates the statistic of the modular test for independence in four-way contingency table

Usage

Mod4.stat(nijtu)

Arguments

nijtu

a numeric matrix with non-negative values of the four-way contingency table cells

Details

The statistic of Logarithmic minimum test for independence in r x c x t x u contingency table,

Value

The function returns the value of the modular test statistic.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Extension of the information contained in Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

Mod4.stat(GenTab4(array(1/16, dim = c(2, 2, 2, 2)), 100))
Mod4.stat(table6)

Modular test for independence in four-way contingency table

Description

Calculates the test statistic and p-value of the modular test for independence in four-way contingency table

Usage

Mod4.test(nijtu, B = 10000)

Arguments

nijtu

a numeric matrix with non-negative values of the four-way contingency table cells

B

an integer specifying the number of replicates used in the Monte Carlo test (optional)

Details

The test statistic and p-value of the modular test for independence in r x c x t x u contingency table,

Value

The function returns values of the test statistic and p-value of the modular test.

Author(s)

Piotr Sulewski, [email protected], Pomeranian University in Slupsk.

References

Extension of the information contained in Sulewski, P. (2018). Power Analysis Of Independence Testing for the Three-Way Con-tingency Tables of Small Sizes. Journal of Applied Statistics 45(13), 2481-2498

Examples

Mod4.test(GenTab4(array(1/16, dim = c(2, 2, 2, 2)), 160), B = 1e2)
Mod4.test(table6, B = 1e2)

The list of package functions and their demonstration

Description

The PSIndependenceTest package puts into practice the modular and logarithmic minimum tests for independence in two-way, three-way and four-way contingency tables. Statistic value, cv value and p-value are calculated. This package also includes three table generation functions and six data sets. The list of package functions is as follows:

Data sets in the package and generating two-way, three-way and four-way contingemcy tables

table1

table2

table3

table4

table5

table6

GenTab2

GenTab3

GenTab4

Functions for the modular independence test and two-way contingency table

Mod2.stat

Mod2.cv

Mod2.pvalue

Mod2.test

Functions for the modular independence test and three-way contingency table

Mod3.stat

Mod3.cv

Mod3.pvalue

Mod3.test

Functions for the modular independence test and four-way contingency table

Mod4.stat

Mod4.cv

Mod4.pvalue

Mod4.test

Functions for the logarithmic minimum independence test and two-way contingency table

Lms2.stat

Lms2.cv

Lms2.pvalue

Lms2.test

Functions for the logarithmic minimum independence test and three-way contingency table

Lms3.stat

Lms3.cv

Lms3.pvalue

Lms3.test

Functions for the logarithmic minimum independence test and four-way contingency table

Lms4.stat

Lms4.cv

Lms4.pvalue

Lms4.test


First data set as two-way contingency table 2 x 2

Description

The first data set from Sulewski, P. (2017) A new test for independence in 2x2 contingency tables, Acta Universitatis Lodziensis. Folia Oeconomica, 4(330), 55–75 consist of 40 observations described the effect of a treatment for rheumatoid arthritis vs. a placebo. See Table 17 in the paper.

Usage

table1

Format

two-way contingency table 2 x 2


Second data set as two-way contingency table 2 x 3

Description

The second data set obtained using the Monte Carlo method consist of 60 observations when Ho is true, i.e. all probabilities equal 1/6

Usage

table2

Format

two-way contingency table 2 x 3


Third data set: three-way contingency table 3 x 3 x 2

Description

The third data set from Sulewski, P. (2021). Logarithmic Minimum Test for Independence in Three Way Con-tingency Table of Small Sizes. Journal of Statistical Computation and Simulation 91(13), 2780-2799 consist of 695 observations described the frequency of watching videos at home or at friends’ homes for young people between 7 and 15 years of age, cross-classified according to age and sex. See Table 10 in the paper.

Usage

table3

Format

three-way contingency table 3 x 3 x 2


Fourth data set: three-way contingency table 2 x 2 x 2

Description

The fourth data set obtained using the Monte Carlo method consist of 80 observations when Ho is true, i.e. all probabilities equal 1/8.

Usage

table4

Format

three-way contingency table 2 x 2 x 2


Fifth data set: four-way contingency table 4 x 2 x 2 x 2

Description

The fifth data set provides information on the fate of 2201 passengers on the fatal maiden voyage of the ocean liner ‘Titanic’, summarized according to economic status (class), sex, age and survival.

Usage

table5

Format

four-way contingency table 4 x 2 x 2 x 2


Sixth data set: four-way contingency table 2 x 2 x 2 x 2

Description

The sixth data set obtained using the Monte Carlo method consist of 160 observations when Ho is true, i.e. all probabilities equal 1/16.

Usage

table6

Format

four-way contingency table 2 x 2 x 2 x 2