diffproportion.test {LearningStats} | R Documentation |
Two Sample Proportion Test
Description
diffproportion.test
allows to compute hypothesis tests about two population proportions.
Usage
diffproportion.test(x1, x2, n1, n2, alternative = "two.sided",
alpha = 0.05, plot = TRUE, lwd = 1)
Arguments
x1 |
a single numeric value corresponding with either the proportion estimate or the number of successes of one of the samples. |
x2 |
a single numeric value corresponding with either the proportion estimate or the number of successes of the other sample. |
n1 |
a single positive integer value corresponding with one sample size. |
n2 |
a single positive integer value corresponding with the other sample size. |
alternative |
a character string specifying the alternative hypothesis, must be one of
" |
alpha |
single number in (0,1) corresponding with the significance level. |
plot |
a logical value indicating whether to display a graph including the test statistic value for the sample, its distribution, the rejection region and p-value. |
lwd |
single number indicating the line width of the plot. |
Details
Counts of successes and failures must be nonnegative and hence not greater than the corresponding numbers of trials which must be positive. All finite counts should be integers. If the number of successes is given, then the proportion estimate is computed.
Value
A list with class "lstest
" and "htest
" containing the following components:
statistic |
the value of the test statistic. |
parameter |
the sample size |
p.value |
the p-value of the test. |
estimate |
the difference of sample proportions. |
null.value |
the value specified by the null. |
alternative |
a character string describing the alternative. |
method |
a character string indicating the method used. |
data.name |
a character string giving the names of the data. |
alpha |
the significance level. |
dist.name |
a character string indicating the distribution of the test statistic. |
statformula |
a character string with the statistic's formula. |
reject.region |
a character string with the reject region. |
Examples
x1 <- rbinom(1, 120, 0.6)
x2 <- rbinom(1, 100, 0.6)
diffproportion.test(x1 = x1, x2 = x2, n1 = 120, n2 = 100)
diffproportion.test(x1 = 0.6, x2 = 0.65, n1 = 120, n2 = 100)