SimpleChitest: SimpleChitest__question5(Advanced R)

Description Usage Arguments Value Examples

View source: R/SimpleChitest.R

Description

Make a faster version of chisq.test() that only computes the chi-square test statistic when the input is two numeric vectors with no missing values. You can try simplifying chisq.test() or by coding from the mathematical de finition. Here we also have the function SimpleTable

This method simplifies the traditional Chi-square test. An example is given to compare the computational speed of this method with that of the traditional method.

Usage

1

Arguments

x

numeric vector with no missing values

y

numeric vector with no missing values

Value

STATISTIC the chi-square test statistic

p.value the P-value of chi-square test statistic

Examples

1
2
3
4
5
6
x1<-sample(1:10,1000,replace=TRUE)
x2<-sample(10:20,1000,replace=TRUE)
SimpleChitest(x1,x2)
library(microbenchmark)
ts <- microbenchmark(chisq=chisq.test(x1,x2),simple_chitest=SimpleChitest(x1,x2))
summary(ts)[,c(1,3,5,6)]

zhengdat/StatComp18049 documentation built on May 29, 2019, 8:33 a.m.