Description Usage Arguments Value Note Author(s) Examples

Perform a *chi-squared* goodness-of-fit test or a
*chi-squared* test on independence on variables of
a data set. The output is printed as a LaTeX table that mimics
the look of SPSS output (version <24).

1 2 3 4 |

`data` |
a data frame containing the variables. |

`variables` |
a character vector specifying the categorical variable(s) of interest. If only one variable is specified, a goodness-of-fit test is performed. If two variables are specified, a test on independence is performed (with the first variable used for the rows and the second variable for the columns of the crosstabulation). |

`p` |
a vector of probabilities for the categories in the goodness-of-fit test. |

`x` |
an object of class |

`digits` |
an integer vector giving the number of digits after the comma to be printed in the LaTeX tables. The first element corresponds to the number of digits in the table of frequencies, and the second element corresponds to the number of digits in the table for the test. |

`statistics` |
a character vector specifying which LaTeX tables should
be printed. Available options are |

`...` |
currently ignored. |

An object of class `"chisqTestSPSS"`

with the following components:

`chisq`

a list containing the results of the

*chi-squared*test.`lr`

a list containing the results of a likelihood ratio test (only test on independence).

`observed`

a table containing the observed frequencies.

`expected`

a vector or matrix containing the expected frequencies.

`n`

an integer giving the number of observations.

`k`

an integer giving the number of groups (only goodness-of-fit test).

`r`

an integer giving the number of groups in the first variable corresponding to the rows (only test on independence).

`c`

an integer giving the number of groups in the second variable corresponding to the columns (only test on independence).

`variables`

a character vector containing the name(s) of the categorical variable(s) of interest.

`type`

a character string giving the type of

*chi-squared*test performed (`"goodness-of-fit"`

or`"independence"`

).

The `print`

method produces a LaTeX table that mimics the look of SPSS
output (version <24).

The test on independence also reports the results of a likelihood ratio test.

Andreas Alfons

1 2 3 4 5 6 7 8 9 10 | ```
# load data
data("Eredivisie")
# test whether playing position and dummy variable for
# foreign players are independent
chisqTest(Eredivisie, c("Position", "Foreign"))
# test whether the traditional Dutch 4-3-3 (total football)
# is still reflected in player composition
chisqTest(Eredivisie, "Position", p = c(1, 4, 3, 3)/11)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.