Pearson's Chi-squared test for comparison of response probabilities to given values

Share:

Description

Performs a Pearson's Chi-squared test for comparing response probabilities (i.e. when the response variable is a binary variable) to given values. The function is in fact a wrapper to the chi-squared test for comparison of proportions to given values on a contingency table.

Usage

1
chisq.theo.bintest(formula, data, p)

Arguments

formula

a formula of the form a ~ b, where a and b give the data values and corresponding groups, respectively. a can be a numeric vector or a factor, with only two possible values (except NA).

data

an optional data frame containing the variables in the formula formula. By default the variables are taken from environment(formula).

p

theoretical probabilities.

Details

If the response is a 0/1 variable, the probability of the '1' group is tested. In any other cases, the response is transformed into a factor and the probability of the second level is tested.

Value

method.test

a character string giving the name of the test.

data.name

a character string giving the name(s) of the data.

alternative

a character string describing the alternative hypothesis, always two-sided.

estimate

the estimated probabilities.

null.value

the theoretical probabilities.

statistic

test statistics.

parameter

test degrees of freedom.

p.value

p-value of the test.

Author(s)

Maxime Herv<e9> <mx.herve@gmail.com>

See Also

prop.test, chisq.bin.exp, prop.bin.multcomp

Examples

1
2
3
4
response <- c(rep(0:1,c(40,60)),rep(0:1,c(55,45)),rep(0:1,c(65,35)))
fact <- gl(3,100,labels=LETTERS[1:3])
p.theo <- c(0.5,0.45,0.2)
chisq.theo.bintest(response~fact,p=p.theo)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.