Wednesday, March 14, 2018

Kiểm định khác biệt giữa hai tỷ lệ: binomial test

14-3-2018 --- Kiểm định khác biệt giữa hai tỷ lệ (one sample binomial test/binomial test) cho phép kiểm tra xem tỷ lệ của hai biến phân loại 2 mức (bảng tần suất 2x2) có khác ý nghĩa thống kê với nhau hay không.

Chẳng hạn, trong bộ dữ liệu, tỷ lệ nam và tỷ lệ nữ, muốn kiểm định xem sự khác nhau trong hai tỷ lệ đó có ý nghĩa thống kê không, ta dùng cặp giả thiết:
Ho:p=0,5
H1:p#0,5
H1: p>0,5
H1:p<0,5
Cod trong R dưới đây:
binom.test {stats}R Documentation

Exact Binomial Test

Description

Performs an exact test of a simple null hypothesis about the probability of success in a Bernoulli experiment.

Usage

binom.test(x, n, p = 0.5,
           alternative = c("two.sided", "less", "greater"),
           conf.level = 0.95)

Arguments

xnumber of successes, or a vector of length 2 giving the numbers of successes and failures, respectively.
nnumber of trials; ignored if x has length 2.
phypothesized probability of success.
alternativeindicates the alternative hypothesis and must be one of "two.sided""greater" or "less". You can specify just the initial letter.
conf.levelconfidence level for the returned confidence interval.

Details

Confidence intervals are obtained by a procedure first given in Clopper and Pearson (1934). This guarantees that the confidence level is at least conf.level, but in general does not give the shortest-length confidence intervals.

Value

A list with class "htest" containing the following components:
statisticthe number of successes.
parameterthe number of trials.
p.valuethe p-value of the test.
conf.inta confidence interval for the probability of success.
estimatethe estimated probability of success.
null.valuethe probability of success under the null, p.
alternativea character string describing the alternative hypothesis.
methodthe character string "Exact binomial test".
data.namea character string giving the names of the data.

References

Clopper, C. J. & Pearson, E. S. (1934). The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika26, 404–413. doi: 10.2307/2331986.
William J. Conover (1971), Practical nonparametric statistics. New York: John Wiley & Sons. Pages 97–104.
Myles Hollander & Douglas A. Wolfe (1973), Nonparametric Statistical Methods. New York: John Wiley & Sons. Pages 15–22.

See Also

prop.test for a general (approximate) test for equal or given proportions.

Examples

## Conover (1971), p. 97f.
## Under (the assumption of) simple Mendelian inheritance, a cross
##  between plants of two particular genotypes produces progeny 1/4 of
##  which are "dwarf" and 3/4 of which are "giant", respectively.
##  In an experiment to determine if this assumption is reasonable, a
##  cross results in progeny having 243 dwarf and 682 giant plants.
##  If "giant" is taken as success, the null hypothesis is that p =
##  3/4 and the alternative that p != 3/4.
binom.test(c(682, 243), p = 3/4)
binom.test(682, 682 + 243, p = 3/4)   # The same.
## => Data are in agreement with the null hypothesis.

No comments:

Post a Comment