Explain how to perform a two-sample z-test for the difference between two population proportions
Show
What is two-proportions z-test?The two-proportions z-test is used to compare two observed proportions. This article describes the basics of two-proportions *z-test and provides pratical examples using R sfoftware**. For example, we have two groups of individuals:
The number of smokers in each group is as follow:
In this setting:
We want to know, whether the proportions of smokers are the same in the two groups of individuals?
Research questions and statistical hypothesesTypical research questions are:
In statistics, we can define the corresponding null hypothesis (\(H_0\)) as follow:
The corresponding alternative hypotheses (\(H_a\)) are as follow:
Note that:
Formula of the test statisticCase of large sample sizesThe test statistic (also known as z-test) can be calculated as follow: \[ z = \frac{p_A-p_B}{\sqrt{pq/n_A+pq/n_B}} \] where,
Note that, the formula of z-statistic is valid only when sample size (\(n\)) is large enough. \(n_Ap\), \(n_Aq\), \(n_Bp\) and \(n_Bq\) should be \(\geq\) 5. Case of small sample sizesThe Fisher Exact probability test is an excellent non-parametric technique for comparing proportions, when the two independent samples are small in size. Compute two-proportions z-test in RR functions: prop.test()The R functions prop.test() can be used as follow: prop.test(x, n, p = NULL, alternative = "two.sided", correct = TRUE)
Note that, by default, the function prop.test() used the Yates continuity correction, which is really important if either the expected successes or failures is < 5. If you don’t want the correction, use the additional argument correct = FALSE in prop.test() function. The default value is TRUE. (This option must be set to FALSE to make the test mathematically equivalent to the uncorrected z-test of a proportion.) Compute two-proportions z-testWe want to know, whether the proportions of smokers are the same in the two groups of individuals? res <- prop.test(x = c(490, 400), n = c(500, 500)) # Printing the results res 2-sample test for equality of proportions with continuity correction data: c(490, 400) out of c(500, 500) X-squared = 80.909, df = 1, p-value < 2.2e-16 alternative hypothesis: two.sided 95 percent confidence interval: 0.1408536 0.2191464 sample estimates: prop 1 prop 2 0.98 0.80The function returns:
Note that:
Interpretation of the resultThe p-value of the test is 2.36310^{-19}, which is less than the significance level alpha = 0.05. We can conclude that the proportion of smokers is significantly different in the two groups with a p-value = 2.36310^{-19}. Note that, for 2 x 2 table, the standard chi-square test in chisq.test() is exactly equivalent to prop.test() but it works with data in matrix form. Access to the values returned by prop.test() functionThe result of prop.test() function is a list containing the following components:
The format of the R code to use for getting these values is as follow: # printing the p-value res$p.value [1] 2.363439e-19# printing the mean res$estimateprop 1 prop 2 0.98 0.80 # printing the confidence interval res$conf.int[1] 0.1408536 0.2191464 attr(,"conf.level") [1] 0.95See also
InfosThis analysis has been performed using R software (ver. 3.2.4). Enjoyed this article? I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Twitter, Facebook or Linked In. Show me some love with the like buttons below... Thank you and please don't forget to share and comment below!! Avez vous aimé cet article? Je vous serais très reconnaissant si vous aidiez à sa diffusion en l'envoyant par courriel à un ami ou en le partageant sur Twitter, Facebook ou Linked In. Montrez-moi un peu d'amour avec les like ci-dessous ... Merci et n'oubliez pas, s'il vous plaît, de partager et de commenter ci-dessous! How do we test the difference between two population proportions?A hypothesis test can help determine if a difference in the estimated proportions reflects a difference in the population proportions. The difference of two proportions follows an approximate normal distribution. Generally, the null hypothesis states that the two proportions are the same.
How do you find the Z statistic for the difference of proportions?z=(p−P)σ where P is the hypothesized value of population proportion in the null hypothesis, p is the sample proportion, and σ is the standard deviation of the sampling distribution.
How do you perform a zHow do I run a Z Test?. State the null hypothesis and alternate hypothesis.. Choose an alpha level.. Find the critical value of z in a z table.. Calculate the z test statistic (see below).. Compare the test statistic to the critical z value and decide if you should support or reject the null hypothesis.. How do you find the difference between two sample proportions?The expected value of the difference between all possible sample proportions is equal to the difference between population proportions. Thus, E(p1 - p2) = P1 - P2.
|