Description Usage Arguments Value Author(s) Examples

Perform chi-square test, either goodness of fit or test for association. Enter either formula-data input or a summary table. Simulation is optional.

1 2 | ```
chisqtestGC(x, data = parent.frame(), p = NULL, graph = FALSE,
simulate.p.value = FALSE, B = 2000, verbose = TRUE)
``` |

`x` |
Could be a formula. If so, either ~var (for goodness of fit) or ~var1+var2 (for test for association). Otherwise either a table, matrix or vector of summary data. |

`data` |
dataframe supplying variables for formula x. If variables in x are not found in the data, then they will be searched for in the parent environment. |

`p` |
For goodness of fit, a vector of probabilities. This will be automatically scaled so as to sum to 1. Negative elements result in an error message. |

`graph` |
produce relevant graph for P-value (chi-square curve or histogram of simulation results). |

`simulate.p.value` |
If FALSE, use a chi-square distribution to estimate the P-value. Other possible values are "random" and "fixed" and TRUE. Random effects are suitable for resampling when the data are a random sample from a population. Fixed effects assume that the values of the explanatory variable (row variable for table, var1 in formula ~var1+var2) remain fixed in resampling, and values of response variable are random with null distribution estimated from the data. When set to TRUE, we implement an equivalent to R's routine. In our view procedure is most suitable when the data come from a randomized experiment in which the treatment groups are the values of the explanatory variable. |

`B` |
number of resamples to take. |

`verbose` |
If TRUE, include lots of information in the output. |

an object of class GCchisqtest

Homer White hwhite0@georgetowncollege.edu

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
#Goodness of fit test for one factor variable:
chisqtestGC(~seat,data=m111survey,p=c(1/3,1/3,1/3))
#Test for relationship between two factor variables:
chisqtestGC(~sex+seat,data=m111survey)
#You can input a two-way table directly into chisqtestGC():
SexSeat <- xtabs(~sex+seat,data=m111survey)
chisqtestGC(SexSeat)
#Several types of simulation are possible, e.g.:
chisqtestGC(~weather+crowd.behavior,data=ledgejump,simulate.p.value="fixed",B=2500)
#For less ouptut, set argument verbose to FALSE:
chisqtestGC(~sex+seat,data=m111survey,verbose=FALSE)
``` |

```
Loading required package: abd
Loading required package: nlme
Loading required package: lattice
Loading required package: grid
Loading required package: mosaic
Loading required package: dplyr
Attaching package: 'dplyr'
The following object is masked from 'package:nlme':
collapse
The following objects are masked from 'package:stats':
filter, lag
The following objects are masked from 'package:base':
intersect, setdiff, setequal, union
Loading required package: ggformula
Loading required package: ggplot2
Loading required package: ggstance
Attaching package: 'ggstance'
The following objects are masked from 'package:ggplot2':
GeomErrorbarh, geom_errorbarh
New to ggformula? Try the tutorials:
learnr::run_tutorial("introduction", package = "ggformula")
learnr::run_tutorial("refining", package = "ggformula")
Loading required package: mosaicData
Loading required package: Matrix
The 'mosaic' package masks several functions from core packages in order to add
additional features. The original behavior of these functions should not be affected by this.
Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.
Attaching package: 'mosaic'
The following object is masked from 'package:Matrix':
mean
The following object is masked from 'package:ggplot2':
stat
The following objects are masked from 'package:dplyr':
count, do, tally
The following objects are masked from 'package:stats':
IQR, binom.test, cor, cor.test, cov, fivenum, median, prop.test,
quantile, sd, t.test, var
The following objects are masked from 'package:base':
max, mean, min, prod, range, sample, sum
Welcome to tigerstats!
To learn more about this package, consult its website:
http://homerhanumat.github.io/tigerstats
Chi-squared test for given probabilities
Observed counts Expected by Null Contr to chisq stat
1_front 27 23.67 0.47
2_middle 32 23.67 2.93
3_back 12 23.67 5.75
Chi-Square Statistic = 9.1549
Degrees of Freedom of the table = 2
P-Value = 0.0103
Pearson's Chi-squared test
Observed Counts:
seat
sex 1_front 2_middle 3_back
female 19 16 5
male 8 16 7
Counts Expected by Null:
seat
sex 1_front 2_middle 3_back
female 15.21 18.03 6.76
male 11.79 13.97 5.24
Contributions to the chi-square statistic:
seat
sex 1_front 2_middle 3_back
female 0.94 0.23 0.46
male 1.22 0.29 0.59
Chi-Square Statistic = 3.734
Degrees of Freedom of the table = 2
P-Value = 0.1546
Pearson's Chi-squared test
Observed Counts:
seat
sex 1_front 2_middle 3_back
female 19 16 5
male 8 16 7
Counts Expected by Null:
seat
sex 1_front 2_middle 3_back
female 15.21 18.03 6.76
male 11.79 13.97 5.24
Contributions to the chi-square statistic:
seat
sex 1_front 2_middle 3_back
female 0.94 0.23 0.46
male 1.22 0.29 0.59
Chi-Square Statistic = 3.734
Degrees of Freedom of the table = 2
P-Value = 0.1546
Pearson's chi-squared test with simulated p-value, fixed row sums
(based on 2500 resamples)
Observed Counts:
crowd.behavior
weather baiting polite
cool 2 7
warm 8 4
Counts Expected by Null:
crowd.behavior
weather baiting polite
cool 4.29 4.71
warm 5.71 6.29
Contributions to the chi-square statistic:
crowd.behavior
weather baiting polite
cool 1.22 1.11
warm 0.91 0.83
Chi-Square Statistic = 4.0727
Degrees of Freedom of the table = 1
P-Value = 0.0604
Pearson's Chi-squared test
Chi-Square Statistic = 3.734
Degrees of Freedom of the table = 2
P-Value = 0.1546
```

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.