chisqtestGC: Chi-Square Test (GC version)

Description Usage Arguments Value Author(s) Examples

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

1
2
3
chisqtestGC(x, data = parent.frame(), p = NULL, correct = TRUE, 
             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 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.

correct

If set to TRUE then Yates' continuity correction is used to compute the test statistic for 2 by 2 tables in a test for association.

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.

Value

an object of class GCchisqtest

Author(s)

Homer White hwhite0@georgetowncollege.edu

Examples

 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)

homerhanumat/tigerstats documentation built on Sept. 27, 2020, 3:21 a.m.