Skip to main content
Correcting my p-value calculation for 2-tailed vs 1-tailed
Source Link
Rez99
  • 283
  • 1
  • 9
2*(1 - pnorm(0.01536376, mean = 0, sd = se_h0))

# [1]  0.0157003545304680314007090609361
1 - pnorm(0.01536376, mean = 0, sd = se_h0)

# [1]  0.015700354530468
2*(1 - pnorm(0.01536376, mean = 0, sd = se_h0))

# [1]  0.0314007090609361
added 18 characters in body
Source Link
kjetil b halvorsen
  • 82.8k
  • 32
  • 201
  • 663
prop_baseline <- 0.05          
prop_treatment <- 0.07
alpha <- 0.05
beta <- 0.2 

n <- ceiling(
        power.prop.test(
            p1 = prop_baseline, 
            p2 = prop_treatment, 
            sig.level = alpha, 
            power = 1-beta, 
            alternative = c("two.sided")
        )$n
      )
n

# [1]  2213
# R code
prop_baseline <- 0.05          
prop_treatment <- 0.07
alpha <- 0.05
beta <- 0.2 

n <- ceiling(
        power.prop.test(
            p1 = prop_baseline, 
            p2 = prop_treatment, 
            sig.level = alpha, 
            power = 1-beta, 
            alternative = c("two.sided")
        )$n
      )
n

# [1]  2213
prop_pooled <- (prop_baseline+prop_treatment)/2
se_h0 <- sqrt(prop_pooled * (1-prop_pooled) * (1/n + 1/n))
se_ha <- sqrt((prop_baseline*(1-prop_baseline))/n + (prop_treatment*(1-prop_treatment))/n)
critical_value <- qnorm(alpha / 2, mean = 0, sd = se_h0, lower.tail = FALSE)
critical_value

# [1]  0.0139930354339993
prop_pooled <- (prop_baseline+prop_treatment)/2
se_h0 <- sqrt(prop_pooled * (1-prop_pooled) * (1/n + 1/n))
se_ha <- sqrt((prop_baseline*(1-prop_baseline))/n + 
    (prop_treatment*(1-prop_treatment))/n)
critical_value <- qnorm(alpha / 2, mean = 0, sd = se_h0, 
    lower.tail = FALSE)
critical_value

# [1]  0.0139930354339993
1 - pnorm(0.01536376, mean = 0, sd = se_h0)

# [1]  0.015700354530468
1 - pnorm(0.01536376, mean = 0, sd = se_h0)

# [1]  0.015700354530468
prop.test(x=c(141, 175), n=c(n,n))$p.value

# [1]  0.0540496200600176
prop.test(x=c(141, 175), n=c(n,n))$p.value

# [1]  0.0540496200600176
prop_baseline <- 0.05          
prop_treatment <- 0.07
alpha <- 0.05
beta <- 0.2 

n <- ceiling(
        power.prop.test(
            p1 = prop_baseline, 
            p2 = prop_treatment, 
            sig.level = alpha, 
            power = 1-beta, 
            alternative = c("two.sided")
        )$n
      )
n

# [1]  2213
prop_pooled <- (prop_baseline+prop_treatment)/2
se_h0 <- sqrt(prop_pooled * (1-prop_pooled) * (1/n + 1/n))
se_ha <- sqrt((prop_baseline*(1-prop_baseline))/n + (prop_treatment*(1-prop_treatment))/n)
critical_value <- qnorm(alpha / 2, mean = 0, sd = se_h0, lower.tail = FALSE)
critical_value

# [1]  0.0139930354339993
1 - pnorm(0.01536376, mean = 0, sd = se_h0)

# [1]  0.015700354530468
prop.test(x=c(141, 175), n=c(n,n))$p.value

# [1]  0.0540496200600176
# R code
prop_baseline <- 0.05          
prop_treatment <- 0.07
alpha <- 0.05
beta <- 0.2 

n <- ceiling(
        power.prop.test(
            p1 = prop_baseline, 
            p2 = prop_treatment, 
            sig.level = alpha, 
            power = 1-beta, 
            alternative = c("two.sided")
        )$n
      )
n

# [1]  2213
prop_pooled <- (prop_baseline+prop_treatment)/2
se_h0 <- sqrt(prop_pooled * (1-prop_pooled) * (1/n + 1/n))
se_ha <- sqrt((prop_baseline*(1-prop_baseline))/n + 
    (prop_treatment*(1-prop_treatment))/n)
critical_value <- qnorm(alpha / 2, mean = 0, sd = se_h0, 
    lower.tail = FALSE)
critical_value

# [1]  0.0139930354339993
1 - pnorm(0.01536376, mean = 0, sd = se_h0)

# [1]  0.015700354530468
prop.test(x=c(141, 175), n=c(n,n))$p.value

# [1]  0.0540496200600176
edited title
Link
Rez99
  • 283
  • 1
  • 9

Are p-values computed from the a priori or a posteriori datasampling distribution?

Became Hot Network Question
edited body
Source Link
Rez99
  • 283
  • 1
  • 9
Loading
Source Link
Rez99
  • 283
  • 1
  • 9
Loading