wp.logistic: Statistical Power Analysis for Logistic Regression

Description Usage Arguments Value References Examples

View source: R/webpower.R

Description

This function is for Logistic regression models. Logistic regression is a type of generalized linear models where the outcome variable follows Bernoulli distribution. Here, Maximum likelihood methods is used to estimate the model parameters. The estimated regression coefficent is assumed to follow a normal distribution. A Wald test is use to test the mean difference between the estimated parameter and the null parameter (tipically the null hypothesis assumes it equals 0). The procedure introduced by Demidenko (2007) is adopted here for computing the statistical power.

Usage

1
2
3
4
wp.logistic(n = NULL, p0 = NULL, p1 = NULL, alpha = 0.05,
  power = NULL, alternative = c("two.sided", "less", "greater"),
  family = c("Bernoulli", "exponential", "lognormal", "normal", "Poisson",
  "uniform"), parameter = NULL)

Arguments

n

Sample size.

p0

Prob(Y=1|X=0): the probobility of observieng 1 for the outcome variable Y when the predictor X equals 0.

p1

Prob(Y=1|X=1): the probobility of observieng 1 for the outcome variable Y when the predictor X equals 1.

alpha

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

power

Statistical power.

alternative

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

family

Distribution of the predictor ("Bernoulli","exponential", "lognormal", "normal", "Poisson", "uniform"). The default is "Bernoulli".

parameter

Corresponding parameter for the predictor's distribution. The default is 0.5 for "Bernoulli", 1 for "exponential", (0,1) for "lognormal" or "normal", 1 for "Poisson", and (0,1) for "uniform".

Value

An object of the power analysis.

References

Demidenko, E. (2007). Sample size determination for logistic regression revisited. Statistics in medicine, 26(18), 3385-3397.

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
#To calculate the statistical power given sample size and effect size:
wp.logistic(n = 200, p0 = 0.15, p1 = 0.1, alpha = 0.05,
            power = NULL, family = "normal", parameter = c(0,1))
#  Power for logistic regression
#
#      p0  p1     beta0      beta1   n alpha     power
#    0.15 0.1 -1.734601 -0.4626235 200  0.05 0.6299315
#
#  URL: http://psychstat.org/logistic

#To generate a power curve given a sequence of sample sizes:
res <- wp.logistic(n = seq(100,500,50), p0 = 0.15, p1 = 0.1, alpha = 0.05,
                power = NULL, family = "normal", parameter = c(0,1))
res
#  Power for logistic regression
#
#      p0  p1     beta0      beta1   n alpha     power
#    0.15 0.1 -1.734601 -0.4626235 100  0.05 0.3672683
#    0.15 0.1 -1.734601 -0.4626235 150  0.05 0.5098635
#    0.15 0.1 -1.734601 -0.4626235 200  0.05 0.6299315
#    0.15 0.1 -1.734601 -0.4626235 250  0.05 0.7264597
#    0.15 0.1 -1.734601 -0.4626235 300  0.05 0.8014116
#    0.15 0.1 -1.734601 -0.4626235 350  0.05 0.8580388
#    0.15 0.1 -1.734601 -0.4626235 400  0.05 0.8998785
#    0.15 0.1 -1.734601 -0.4626235 450  0.05 0.9302222
#    0.15 0.1 -1.734601 -0.4626235 500  0.05 0.9518824
#
#  URL: http://psychstat.org/logistic

#To plot the power curve:
plot(res)

#To calculate the required sample size given power and effect size:
wp.logistic(n = NULL, p0 = 0.15, p1 = 0.1, alpha = 0.05,
              power = 0.8, family = "normal", parameter = c(0,1))
#  Power for logistic regression
#
#      p0  p1     beta0      beta1        n alpha power
#    0.15 0.1 -1.734601 -0.4626235 298.9207  0.05   0.8
#
#  URL: http://psychstat.org/logistic

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