wp.prop: Statistical Power Analysis for Tests of Proportions

Description Usage Arguments Value References Examples

View source: R/webpower.R

Description

Tests of proportions are a technique used to compare proportions of success or agreement in one or two samples. The one-sample test of proportion tests the null proportion of success, usually 0.5. The two-sample test of proportions tests the null hypothesis that the two samples are drawn from populations with the same proportion of success. A z-test is used to evaluate whether the given difference in proportions is statistical significantly different from the null hypothesis. The power calculation is based on the arcsine transformation of the proportion (see Cohen, 1988, p.548).

Usage

1
2
3
wp.prop(h = NULL, n1 = NULL, n2 = NULL, alpha = 0.05, power = NULL,
  type = c("1p", "2p", "2p2n"), alternative = c("two.sided", "less",
  "greater"))

Arguments

h

Effect size of the proportion comparison. Cohen (1992) suggested that effect size values of 0.2, 0.5, and 0.8 represent "small", "medium", and "large" effect sizes, repectively.

n1

Sample size of the first group.

n2

Sample size of the second group if applicable.

alpha

Significance level chosed for the test. It equals 0.05 by default.

power

Statistical power.

type

Type of comparison ("1p" or "2p" or "2p2n"). The default is "1p". 1p: one sample; 2p: two sample with equal sample size; 2p2n: two sample with unequal sample size.

alternative

Direction of the alternative hypothesis ("two.sided" or "less" or "greater"). The default is "two.sided".

Value

An object of the power analysis.

References

Cohen, J. (1992). A power primer. Psychological bulletin, 112(1), 155.

Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd Ed). Hillsdale, NJ: Lawrence Erlbaum Associates.

Zhang, Z., & Yuan, K.-H. (2018). Practical Statistical Power Analysis Using Webpower and R (Eds). Granger, IN: ISDSA Press.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#To calculate the power for two groups of proportion with unequal sample size:
wp.prop(h=0.52,n1=35,n2=50,alternative="greater",type="2p2n")
#  Power for two-sample proportion (unequal n)
#
#       h n1 n2 alpha     power
#    0.52 35 50  0.05 0.7625743
#
#  NOTE: Sample size for each group
#  URL: http://psychstat.org/prop2p2n

#To calculate the power curve with a sequence of sample sizes:
res <- wp.prop(h=0.52,n1=seq(10,100,10),alternative="greater",type="1p")
res
#  Power for one-sample proportion test
#
#       h   n alpha     power
#    0.52  10  0.05 0.4998128
#    0.52  20  0.05 0.7519557
#    0.52  30  0.05 0.8855706
#    0.52  40  0.05 0.9499031
#    0.52  50  0.05 0.9789283
#    0.52  60  0.05 0.9914150
#    0.52  70  0.05 0.9965928
#    0.52  80  0.05 0.9986772
#    0.52  90  0.05 0.9994960
#    0.52 100  0.05 0.9998111
#
#  URL: http://psychstat.org/prop

#To plot the power curve:
plot(res, type='b')

#To estimate the sample size with a given power:
wp.prop(h=0.52,n1=NULL,power=0.8,alternative="greater",type="1p")
#  Power for one-sample proportion test
#
#       h        n alpha power
#    0.52 22.86449  0.05   0.8
#
#  URL: http://psychstat.org/prop

#To estimate the minimum detectable effect size with a given power:
wp.prop(h=NULL,n1=35,power=0.8,alternative="greater",type="1p")
#  Power for one-sample proportion test
#
#            h  n alpha power
#    0.4202907 35  0.05   0.8
#
#  URL: http://psychstat.org/prop

#To calculate the power curve with a sequence of effect sizes:
wp.prop(h=seq(0.1, 0.8, 0.1),n1=100,alternative="greater",type="1p")
#  Power for one-sample proportion test
#
#      h   n alpha     power
#    0.1 100  0.05 0.2595110
#    0.2 100  0.05 0.6387600
#    0.3 100  0.05 0.9123145
#    0.4 100  0.05 0.9907423
#    0.5 100  0.05 0.9996034
#    0.6 100  0.05 0.9999934
#    0.7 100  0.05 1.0000000
#    0.8 100  0.05 1.0000000
#
#  URL: http://psychstat.org/prop

Example output

Loading required package: MASS
Loading required package: lme4
Loading required package: Matrix
Loading required package: lavaan
This is lavaan 0.6-3
lavaan is BETA software! Please report any bugs.
Loading required package: parallel
Loading required package: PearsonDS
Power for two-sample proportion (unequal n)

       h n1 n2 alpha     power
    0.52 35 50  0.05 0.7625743

NOTE: Sample size for each group
URL: http://psychstat.org/prop2p2n
Power for one-sample proportion test

       h   n alpha     power
    0.52  10  0.05 0.4998128
    0.52  20  0.05 0.7519557
    0.52  30  0.05 0.8855706
    0.52  40  0.05 0.9499031
    0.52  50  0.05 0.9789283
    0.52  60  0.05 0.9914150
    0.52  70  0.05 0.9965928
    0.52  80  0.05 0.9986772
    0.52  90  0.05 0.9994960
    0.52 100  0.05 0.9998111

URL: http://psychstat.org/prop
Power for one-sample proportion test

       h        n alpha power
    0.52 22.86449  0.05   0.8

URL: http://psychstat.org/prop
Power for one-sample proportion test

            h  n alpha power
    0.4202907 35  0.05   0.8

URL: http://psychstat.org/prop
Power for one-sample proportion test

      h   n alpha     power
    0.1 100  0.05 0.2595110
    0.2 100  0.05 0.6387600
    0.3 100  0.05 0.9123145
    0.4 100  0.05 0.9907423
    0.5 100  0.05 0.9996034
    0.6 100  0.05 0.9999934
    0.7 100  0.05 1.0000000
    0.8 100  0.05 1.0000000

URL: http://psychstat.org/prop

WebPower documentation built on May 1, 2019, 8:19 p.m.