How do you conduct a power analysis for logistic regression in R?
Asked Answered
r
P

3

6

I'm familiar with G*Power as a tool for power analyses, but have yet to find a resource on the internet describing how to compute a power analysis for for logistic regression in R. The pwr package doesn't list logistic regression as an option.

Pru answered 1/12, 2014 at 18:20 Comment(0)
D
6

You will very likely need to "roll your own".

  • Specify your hypothesized relationship between predictors and outcome.
  • Specify what values of your predictors you are likely to observe in your study. Will they be correlated?
  • Specify the effect size you would like to detect, e.g., odds ratios corresponding to two specific settings of your predictors.
  • Specify a power level, e.g., beta=0.80.
  • For different sample sizes n:
    • Simulate predictors as specified
    • Simulate outcomes
    • Run your analysis
    • Record whether you detect a statistically significant effect
    • Do these steps many times, on the order of 1000 or more times. Count how often you did detect an effect. If you detected an effect more than (e.g.) 80% of the time, you are overpowered - reduce n and start over. If you detected an effect less than 80%, you are underpowered - increase n and start over. Rinse & repeat until you have a good n.

And then think some more about whether all your assumptions really make sense. Vary them a bit. Is the resulting value of n sensitive to your assumptions?

Yes, this will be quite a bit of work. But it will be worth it. On the one hand, it will keep you from running an over- or underpowered study. On the other hand, as I wrote, this will force you to think deeply about your assumptions, and this is the path to enlightenment. (Which is a painful path to travel. Sorry.)

If you don't get any better answers specifically helping you to do this in R, you may want to look to CrossValidated for more help. Good luck!

Detrimental answered 1/12, 2014 at 20:16 Comment(0)
G
4

This question and answers on Crossvalidated discuss power for logistic regression and include R code as well as additional discussion and links for more information.

Gossipmonger answered 1/12, 2014 at 20:56 Comment(0)
J
0

To compute power for logistic regression with a single predictor in R (without resorting to simulations) you can use "wp.logistic" in package "WebPower". For dichotomous predictor the power for test for binomial proportions provided by bpower in package "Hmisc" may be more accurate.

Joby answered 8/9, 2024 at 17:25 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.