ss4dpH: The required sample size for testing a null hyphotesis for a...

Description Usage Arguments Details Author(s) References See Also Examples

View source: R/ss4dpH.R

Description

This function returns the minimum sample size required for testing a null hyphotesis regarding a single proportion.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
ss4dpH(
  N,
  P1,
  P2,
  D,
  DEFF = 1,
  conf = 0.95,
  power = 0.8,
  T = 0,
  R = 1,
  plot = FALSE
)

Arguments

N

The maximun population size between the groups (strata) that we want to compare.

P1

The value of the first estimated proportion.

P2

The value of the second estimated proportion.

D

The minimun effect to test.

DEFF

The design effect of the sample design. By default DEFF = 1, which corresponds to a simple random sampling design.

conf

The statistical confidence. By default conf = 0.95.

power

The statistical power. By default power = 0.80.

T

The overlap between waves. By default T = 0.

R

The correlation between waves. By default R = 1.

plot

Optionally plot the effect against the sample size.

Details

We assume that it is of interest to test the following set of hyphotesis:

H_0: P_1 - P_2 = 0 \ \ \ \ vs. \ \ \ \ H_a: P_1 - P_2 = D \neq 0

Note that the minimun sample size, restricted to the predefined power β and confidence 1-α, is defined by:

n = \frac{S^2}{\frac{D^2}{(z_{1-α} + z_{β})^2}+\frac{S^2}{N}}

Where S^2 = (P1 * Q1 + P2 * Q2) * (1 - (T * R)) * DEFF and Q_i=1-P_i for i=1,2.

Author(s)

Hugo Andres Gutierrez Rojas <hagutierrezro at gmail.com>

References

Gutierrez, H. A. (2009), Estrategias de muestreo: Diseno de encuestas y estimacion de parametros. Editorial Universidad Santo Tomas

See Also

ss4pH

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
ss4dpH(N = 100000, P1 = 0.5, P2 = 0.55, D=0.03)
ss4dpH(N = 100000, P1 = 0.5, P2 = 0.55, D=0.03, plot=TRUE)
ss4dpH(N = 100000, P1 = 0.5, P2 = 0.55, D=0.03, DEFF = 2, plot=TRUE)
ss4dpH(N = 100000, P1 = 0.5, P2 = 0.55, D=0.03, conf = 0.99, power = 0.9, DEFF = 2, plot=TRUE)

#############################
# Example with BigLucy data #
#############################
data(BigLucy)
attach(BigLucy)

N1 <- table(SPAM)[1]
N2 <- table(SPAM)[2]
N <- max(N1,N2)
P1 <- prop.table(table(SPAM))[1]
P2 <- prop.table(table(SPAM))[2]

# The minimum sample size for testing 
# H_0: P_1 - P_2 = 0   vs.   H_a: P_1 - P_2 = D = 0.05
D = 0.05  
ss4dpH(N, P1, P2, D, DEFF = 2, plot=TRUE)

# The minimum sample size for testing 
# H_0: P - P_0 = 0   vs.   H_a: P - P_0 = D = 0.02
D = 0.01
ss4dpH(N, P1, P2, D, conf = 0.99, power = 0.9, DEFF = 3.45, plot=TRUE)

Example output

Loading required package: TeachingSampling
Loading required package: timeDate
[1] 3305
[1] 3305
[1] 6398
[1] 12581
  no 
2254 
   no 
41792 

samplesize4surveys documentation built on Jan. 18, 2020, 1:11 a.m.