goodnessOfFitTest

0th

Percentile

Chi-square test against specified probabilities

Convenience function that runs a chi-square goodness of fit test against specified probabilities. This is a wrapper function intended to be used for pedagogical purposes only.

Usage
goodnessOfFitTest( x, p=NULL )
Arguments
x
Factor variable containing the raw outcomes.
p
Numeric variable containing the null-hypothesis probabilities (default = all outcomes equally likely)
Details

The goodnessOfFitTest function runs the chi-square goodness of fit test of the hypothesis that the outcomes in the factor x were generated according to the probabilities in the vector p. The probability vector p must be a numeric variable of length nlevels(x). If no probabilities are specified, all outcomes are assumed to be equally likely.

Value

Warning

This package is under development, and has been released only due to teaching constraints. Until this notice disappears from the help files, you should assume that everything in the package is subject to change. Backwards compatibility is NOT guaranteed. Functions may be deleted in future versions and new syntax may be inconsistent with earlier versions. For the moment at least, this package should be treated with extreme caution.

See Also

chisq.test, associationTest, cramersV

Aliases
  • goodnessOfFitTest
Examples
library(lsr) # raw data gender <- factor( c( "male","male","male","male","female","female", "female","male","male","male" )) # goodness of fit test against the hypothesis that males and # females occur with equal frequency goodnessOfFitTest( gender ) # goodness of fit test against the hypothesis that males appear # with probability .6 and females with probability .4. goodnessOfFitTest( gender, p=c(.4,.6) ) goodnessOfFitTest( gender, p=c(female=.4,male=.6) ) goodnessOfFitTest( gender, p=c(male=.6,female=.4) )
Documentation reproduced from package lsr, version 0.5, License: GPL-3

Community examples

Looks like there are no examples yet.