Rev 68948 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/stats/man/prop.test.Rd% Part of the R package, https://www.R-project.org% Copyright 1995-2010 R Core Team% Distributed under GPL 2 or later\name{prop.test}\title{Test of Equal or Given Proportions}\usage{prop.test(x, n, p = NULL,alternative = c("two.sided", "less", "greater"),conf.level = 0.95, correct = TRUE)}\alias{prop.test}\arguments{\item{x}{a vector of counts of successes, a one-dimensional table withtwo entries, or a two-dimensional table (or matrix) with 2 columns,giving the counts of successes and failures, respectively.}\item{n}{a vector of counts of trials; ignored if \code{x} is amatrix or a table.}\item{p}{a vector of probabilities of success. The length of\code{p} must be the same as the number of groups specified by\code{x}, and its elements must be greater than 0 and less than 1.}\item{alternative}{a character string specifying the alternativehypothesis, must be one of \code{"two.sided"} (default),\code{"greater"} or \code{"less"}. You can specify just the initialletter. Only used for testing the null that a single proportionequals a given value, or that two proportions are equal; ignoredotherwise.}\item{conf.level}{confidence level of the returned confidenceinterval. Must be a single number between 0 and 1. Only usedwhen testing the null that a single proportion equals a givenvalue, or that two proportions are equal; ignored otherwise.}\item{correct}{a logical indicating whether Yates' continuitycorrection should be applied where possible.}}\description{\code{prop.test} can be used for testing the null that theproportions (probabilities of success) in several groups are thesame, or that they equal certain given values.}\details{Only groups with finite numbers of successes and failures are used.Counts of successes and failures must be nonnegative and hence notgreater than the corresponding numbers of trials which must bepositive. All finite counts should be integers.If \code{p} is \code{NULL} and there is more than one group, the nulltested is that the proportions in each group are the same. If thereare two groups, the alternatives are that the probability of successin the first group is less than, not equal to, or greater than theprobability of success in the second group, as specified by\code{alternative}. A confidence interval for the difference ofproportions with confidence level as specified by \code{conf.level}and clipped to \eqn{[-1,1]} is returned. Continuity correction isused only if it does not exceed the difference of the sampleproportions in absolute value. Otherwise, if there are more than 2groups, the alternative is always \code{"two.sided"}, the returnedconfidence interval is \code{NULL}, and continuity correction is neverused.If there is only one group, then the null tested is that theunderlying probability of success is \code{p}, or .5 if \code{p} isnot given. The alternative is that the probability of success is lessthan, not equal to, or greater than \code{p} or 0.5, respectively, asspecified by \code{alternative}. A confidence interval for theunderlying proportion with confidence level as specified by\code{conf.level} and clipped to \eqn{[0,1]} is returned. Continuitycorrection is used only if it does not exceed the difference betweensample and null proportions in absolute value. The confidence intervalis computed by inverting the score test.Finally, if \code{p} is given and there are more than 2 groups, thenull tested is that the underlying probabilities of success are thosegiven by \code{p}. The alternative is always \code{"two.sided"}, thereturned confidence interval is \code{NULL}, and continuity correctionis never used.}\value{A list with class \code{"htest"} containing the followingcomponents:\item{statistic}{the value of Pearson's chi-squared test statistic.}\item{parameter}{the degrees of freedom of the approximatechi-squared distribution of the test statistic.}\item{p.value}{the p-value of the test.}\item{estimate}{a vector with the sample proportions \code{x/n}.}\item{conf.int}{a confidence interval for the true proportion ifthere is one group, or for the difference in proportions ifthere are 2 groups and \code{p} is not given, or \code{NULL}otherwise. In the cases where it is not \code{NULL}, thereturned confidence interval has an asymptotic confidence levelas specified by \code{conf.level}, and is appropriate to thespecified alternative hypothesis.}\item{null.value}{the value of \code{p} if specified by the null, or\code{NULL} otherwise.}\item{alternative}{a character string describing the alternative.}\item{method}{a character string indicating the method used, andwhether Yates' continuity correction was applied.}\item{data.name}{a character string giving the names of the data.}}\references{Wilson, E.B. (1927) Probable inference, the law of succession, andstatistical inference.\emph{J. Am. Stat. Assoc.}, \bold{22}, 209--212.Newcombe R.G. (1998) Two-Sided Confidence Intervals for the SingleProportion: Comparison of Seven Methods.\emph{Statistics in Medicine} \bold{17}, 857--872.Newcombe R.G. (1998) Interval Estimation for the Difference BetweenIndependent Proportions: Comparison of Eleven Methods.\emph{Statistics in Medicine} \bold{17}, 873--890.}\seealso{\code{\link{binom.test}} for an \emph{exact} test of a binomialhypothesis.}\examples{heads <- rbinom(1, size = 100, prob = .5)prop.test(heads, 100) # continuity correction TRUE by defaultprop.test(heads, 100, correct = FALSE)## Data from Fleiss (1981), p. 139.## H0: The null hypothesis is that the four populations from which## the patients were drawn have the same true proportion of smokers.## A: The alternative is that this proportion is different in at## least one of the populations.smokers <- c( 83, 90, 129, 70 )patients <- c( 86, 93, 136, 82 )prop.test(smokers, patients)}\keyword{htest}