Learn R Programming

tigerstats (version 0.1.6)

chisqtestGC: Chi-Square Test (GC version)

Description

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

Usage

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

Arguments

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 ar enot 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). Ignored if user requests R's resampling routines (see below).
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 poulation. Fixed effects assume that the value
B
number of resamples to take.
verbose
If TRUE, include lots of information in the output.

Value

  • No value, just side effects. Future versions may define an S3 object, with print method.

Examples

Run this code
#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)

#For small datasets, severa ltypes 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)

Run the code above in your browser using DataLab